diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-12-28 06:24:59 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-12-28 06:24:59 +0100 |
commit | 232c41ad8b34f054583505f83f3b7aa3ebbba2b7 (patch) | |
tree | 385815fe7fe2a6ac5ef35ed8c0b5df8324845619 /ftnoir_tracker_aruco | |
parent | be1c43cf934cbe4db7a3ad0e857fe1addd4c3329 (diff) |
remove ewma frame support, too little gain
Diffstat (limited to 'ftnoir_tracker_aruco')
-rw-r--r-- | ftnoir_tracker_aruco/aruco-trackercontrols.ui | 109 | ||||
-rw-r--r-- | ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 49 | ||||
-rw-r--r-- | ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 |
3 files changed, 52 insertions, 108 deletions
diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 340ed0ad..6cc8c29d 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -105,6 +105,45 @@ </layout> </widget> </item> + <item row="7" column="1"> + <widget class="QComboBox" name="ewma"> + <item> + <property name="text"> + <string>0</string> + </property> + </item> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>2</string> + </property> + </item> + <item> + <property name="text"> + <string>3</string> + </property> + </item> + <item> + <property name="text"> + <string>4</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>6</string> + </property> + </item> + </widget> + </item> <item row="1" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> @@ -254,6 +293,13 @@ </property> </widget> </item> + <item row="7" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Frame EWMA</string> + </property> + </widget> + </item> <item row="6" column="2" rowspan="3" colspan="3"> <widget class="QLabel" name="label_6"> <property name="sizePolicy"> @@ -285,30 +331,6 @@ </property> </widget> </item> - <item row="6" column="1"> - <widget class="QComboBox" name="resolution"> - <item> - <property name="text"> - <string>640x480</string> - </property> - </item> - <item> - <property name="text"> - <string>320x240</string> - </property> - </item> - <item> - <property name="text"> - <string>320x200</string> - </property> - </item> - <item> - <property name="text"> - <string>Default (not recommended!)</string> - </property> - </item> - </widget> - </item> <item row="9" column="4"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="standardButtons"> @@ -323,57 +345,30 @@ </property> </widget> </item> - <item row="7" column="1"> - <widget class="QComboBox" name="ewma"> - <item> - <property name="text"> - <string>0</string> - </property> - </item> - <item> - <property name="text"> - <string>1</string> - </property> - </item> - <item> - <property name="text"> - <string>2</string> - </property> - </item> - <item> - <property name="text"> - <string>3</string> - </property> - </item> + <item row="6" column="1"> + <widget class="QComboBox" name="resolution"> <item> <property name="text"> - <string>4</string> + <string>640x480</string> </property> </item> <item> <property name="text"> - <string>5</string> + <string>320x240</string> </property> </item> <item> <property name="text"> - <string>6</string> + <string>320x200</string> </property> </item> <item> <property name="text"> - <string>7</string> + <string>Default (not recommended!)</string> </property> </item> </widget> </item> - <item row="7" column="0"> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Frame EWMA</string> - </property> - </widget> - </item> </layout> </widget> <tabstops> diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index c6d45f35..4c900ab4 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -16,7 +16,6 @@ #include <opencv/highgui.h> #include <vector> #include <cstdio> -#include <vector> #if defined(_WIN32) # define NO_DSHOW_STRSAFE @@ -129,14 +128,12 @@ void Tracker::load_settings() headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } headpitch = iniFile.value("pitch", 0).toDouble(); - N_hyst = iniFile.value("ewma", 0).toInt(); iniFile.endGroup(); } Tracker::Tracker() { - N_hyst = 0; layout = nullptr; stop = false; videoWidget = NULL; @@ -212,28 +209,6 @@ void Tracker::run() int last_fps = 0; cv::Point2f last_centroid; - bool first_run = true; - - std::vector<cv::Mat> lasts; - - for (int i = 0; i < N_hyst; i++) - lasts.push_back(cv::Mat()); - - vector<float> weights; - { - const float a = 0.25; - float sum = 0; - float k = 1; - for (int i = 0; i < N_hyst; i++) - { - sum += k; - weights.push_back(k); - k *= 1./(a*N_hyst); - } - for (int i = 0; i < N_hyst; i++) - qDebug() << i << "w" << (weights[i] /= sum); - } - while (!stop) { if (!camera.read(color_)) @@ -242,28 +217,6 @@ void Tracker::run() color_.copyTo(color); cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); - if (N_hyst > 0) - { - if (first_run) - { - first_run = false; - for (int i = 0; i < N_hyst; i++) - lasts[i] = grayscale; - } - cv::Mat hyst(grayscale.rows, grayscale.cols, CV_32F); - hyst.setTo(0); - for (int i = 0; i < N_hyst-1; i++) - lasts[i] = lasts[i+1]; - lasts[N_hyst-1] = grayscale; - for (int i = 0; i < N_hyst; i++) - for (int y = 0; y < grayscale.rows; y++) - for (int x = 0; x < grayscale.cols; x++) - hyst.at<float>(y, x) += lasts[i].at<unsigned char>(y, x) * weights[i]; - hyst.convertTo(grayscale, CV_8U); - } - - cv::cvtColor(grayscale, color, cv::COLOR_GRAY2BGR); - const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); @@ -593,7 +546,6 @@ void TrackerControls::loadSettings() } ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); - ui.ewma->setCurrentIndex(iniFile.value("ewma", 0).toInt()); iniFile.endGroup(); settingsDirty = false; @@ -634,7 +586,6 @@ void TrackerControls::save() iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); iniFile.setValue("pitch", ui.pitch_deg->value()); - iniFile.setValue("ewma", ui.ewma->currentIndex()); QDoubleSpinBox* headpos[] = { ui.cx, diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 249c8829..be2ad3d7 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -42,8 +42,6 @@ private: cv::Mat frame; double headpos[3], headpitch; cv::VideoCapture camera; - int N_hyst; - cv::Mat lasts; }; // Widget that has controls for FTNoIR protocol client-settings. |