summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT
diff options
context:
space:
mode:
authorPatrick Ruoff <c14-radioactive@19e81ba0-9b1a-49c3-bd6c-561e1906d5fb>2012-09-29 13:18:52 +0000
committerPatrick Ruoff <c14-radioactive@19e81ba0-9b1a-49c3-bd6c-561e1906d5fb>2012-09-29 13:18:52 +0000
commit2836141124cf065387bbc7e59ddcfa238ea0a26f (patch)
tree011851f51eb22971a411de8d888f3ba7ce397764 /FTNoIR_Tracker_PT
parent71736d2d3bf639096c3c1b51565fd4c45239e44a (diff)
Updated vc9 project files.
PT: Undo of Wim's last wrong commit, some code cleanup, added preliminary resolution change support. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@184 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FTNoIR_Tracker_PT')
-rw-r--r--FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui261
-rw-r--r--FTNoIR_Tracker_PT/camera.cpp28
-rw-r--r--FTNoIR_Tracker_PT/camera.h3
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp62
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.h23
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp64
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h31
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp4
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h13
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp28
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h10
-rw-r--r--FTNoIR_Tracker_PT/point_extractor.cpp8
-rw-r--r--FTNoIR_Tracker_PT/point_tracker.cpp4
13 files changed, 364 insertions, 175 deletions
diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
index 77e3ada7..6ba6a1db 100644
--- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
+++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
@@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>395</width>
- <height>450</height>
+ <height>511</height>
</rect>
</property>
<property name="sizePolicy">
@@ -51,7 +51,7 @@
</size>
</property>
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -67,11 +67,15 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
- <widget class="QCheckBox" name="videowidget_check">
- <property name="text">
- <string>Show VideoWidget</string>
- </property>
- </widget>
+ <layout class="QFormLayout" name="formLayout_3">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="videowidget_check">
+ <property name="text">
+ <string>Show VideoWidget</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item>
<spacer name="horizontalSpacer_7">
@@ -87,28 +91,70 @@
</spacer>
</item>
<item>
- <widget class="QLabel" name="label_39">
- <property name="text">
- <string>Sleep time</string>
- </property>
- <property name="buddy">
- <cstring>sleep_spin</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="sleep_spin">
- <property name="maximum">
- <number>999</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label_40">
- <property name="text">
- <string>ms</string>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
- </widget>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_39">
+ <property name="text">
+ <string>Sleep time</string>
+ </property>
+ <property name="buddy">
+ <cstring>sleep_spin</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QSpinBox" name="sleep_spin">
+ <property name="suffix">
+ <string/>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_40">
+ <property name="text">
+ <string>ms</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_43">
+ <property name="text">
+ <string>Auto-reset time</string>
+ </property>
+ <property name="buddy">
+ <cstring>reset_spin</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item>
+ <widget class="QSpinBox" name="reset_spin">
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_42">
+ <property name="text">
+ <string>s</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</item>
</layout>
</item>
@@ -168,6 +214,70 @@
</item>
</layout>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <item>
+ <widget class="QLabel" name="label_36">
+ <property name="text">
+ <string>Resolution</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="res_x_spin">
+ <property name="maximum">
+ <number>2000</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_41">
+ <property name="text">
+ <string>x</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="res_y_spin">
+ <property name="maximum">
+ <number>2000</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_9">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_37">
+ <property name="text">
+ <string>FPS</string>
+ </property>
+ <property name="buddy">
+ <cstring>fps_spin</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="fps_spin"/>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
@@ -285,18 +395,27 @@
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QFormLayout" name="formLayout">
- <item row="1" column="0">
- <widget class="QLabel" name="label_3">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_38">
<property name="text">
- <string>Extracted Points:</string>
+ <string>Camera Info:</string>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QLabel" name="pointinfo_label">
+ <item row="0" column="1">
+ <widget class="QLabel" name="caminfo_label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
- <width>50</width>
+ <width>120</width>
<height>0</height>
</size>
</property>
@@ -305,24 +424,18 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_38">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
<property name="text">
- <string>Camera Info:</string>
+ <string>Extracted Points:</string>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLabel" name="caminfo_label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
+ <item row="1" column="1">
+ <widget class="QLabel" name="pointinfo_label">
<property name="minimumSize">
<size>
- <width>120</width>
+ <width>50</width>
<height>0</height>
</size>
</property>
@@ -335,10 +448,32 @@
</item>
</layout>
<zorder></zorder>
- <zorder>caminfo_label</zorder>
- <zorder>formLayoutWidget</zorder>
</widget>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <widget class="QPushButton" name="reset_button">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="center_button">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Center</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
@@ -663,10 +798,16 @@
</spacer>
</item>
<item>
- <widget class="QPushButton" name="pushButton">
+ <widget class="QPushButton" name="tcalib_button">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Calibrate</string>
</property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
@@ -719,11 +860,6 @@
</layout>
</item>
</layout>
- <zorder>groupBox_3</zorder>
- <zorder>groupBox_4</zorder>
- <zorder>label_32</zorder>
- <zorder>horizontalLayoutWidget_3</zorder>
- <zorder>label_33</zorder>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
@@ -739,7 +875,7 @@
</rect>
</property>
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;FTNoIR PointTracker Plugin&lt;br/&gt;Version 0.1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;by Patrick Ruoff&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://ftnoirpt.sourceforge.net/&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline; color:#0000ff;&quot;&gt;Manual (external)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;FTNoIR PointTracker Plugin&lt;br/&gt;Version 0.2&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;by Patrick Ruoff&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://ftnoirpt.sourceforge.net/&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline; color:#0000ff;&quot;&gt;Manual (external)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
@@ -767,13 +903,6 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
- <widget class="QPushButton" name="center_button">
- <property name="text">
- <string>Center</string>
- </property>
- </widget>
- </item>
- <item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -810,11 +939,17 @@
<tabstop>cancel_button</tabstop>
<tabstop>videowidget_check</tabstop>
<tabstop>sleep_spin</tabstop>
+ <tabstop>reset_spin</tabstop>
<tabstop>camindex_spin</tabstop>
<tabstop>f_dspin</tabstop>
+ <tabstop>res_x_spin</tabstop>
+ <tabstop>res_y_spin</tabstop>
+ <tabstop>fps_spin</tabstop>
<tabstop>threshold_slider</tabstop>
<tabstop>mindiam_spin</tabstop>
<tabstop>maxdiam_spin</tabstop>
+ <tabstop>reset_button</tabstop>
+ <tabstop>center_button</tabstop>
<tabstop>m1x_spin</tabstop>
<tabstop>m1y_spin</tabstop>
<tabstop>m1z_spin</tabstop>
@@ -824,7 +959,7 @@
<tabstop>tx_spin</tabstop>
<tabstop>ty_spin</tabstop>
<tabstop>tz_spin</tabstop>
- <tabstop>pushButton</tabstop>
+ <tabstop>tcalib_button</tabstop>
</tabstops>
<resources>
<include location="ftnoir_tracker_pt.qrc"/>
diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp
index c1d0149c..1a233cef 100644
--- a/FTNoIR_Tracker_PT/camera.cpp
+++ b/FTNoIR_Tracker_PT/camera.cpp
@@ -4,7 +4,7 @@ using namespace cv;
// ----------------------------------------------------------------------------
Camera::Camera()
- : dt_valid(0), dt_mean(0), cap(NULL)
+ : dt_valid(0), dt_mean(0), cap(NULL), active_index(-1)
{}
Camera::~Camera()
@@ -14,6 +14,7 @@ Camera::~Camera()
void Camera::set_index(int index)
{
+ if (index == active_index) return;
if (cap) cvReleaseCapture(&cap);
cap = cvCreateCameraCapture(index);
@@ -25,8 +26,27 @@ void Camera::set_index(int index)
cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT);
}
- // reset fps calculation
- dt_mean = 0;
+ active_index = index;
+ dt_mean = 0; // reset fps calculation
+}
+
+bool Camera::set_fps(int fps)
+{
+ return cap && cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, fps);
+}
+
+bool Camera::set_res(int x_res, int y_res)
+{
+ if (cap)
+ {
+ if (x_res == cam_info.res_x && y_res == cam_info.res_y) return true;
+ cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH, x_res);
+ cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, y_res);
+ cam_info.res_x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH);
+ cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT);
+ if (x_res == cam_info.res_x && y_res == cam_info.res_y) return true;
+ }
+ return false;
}
cv::Mat Camera::get_frame(float dt)
@@ -54,7 +74,7 @@ cv::Mat Camera::get_frame(float dt)
if (!frame.empty())
{
dt_mean = dt_smoothing_const * dt_mean + (1.0 - dt_smoothing_const) * dt_valid;
- cam_info.fps = 1.0 / (dt_mean + 1e-6);
+ cam_info.fps = 1.0 / dt_mean;
dt_valid = 0;
}
diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h
index 69719fcc..f26a7a8f 100644
--- a/FTNoIR_Tracker_PT/camera.h
+++ b/FTNoIR_Tracker_PT/camera.h
@@ -29,6 +29,8 @@ public:
void set_index(int index);
void set_f(float f) { cam_info.f = f; }
+ bool set_fps(int fps);
+ bool set_res(int x_res, int y_res);
// gets a frame from the camera, dt: time since last call in seconds
cv::Mat get_frame(float dt);
@@ -37,6 +39,7 @@ public:
const CamInfo& get_info() const { return cam_info; }
protected:
+ int active_index;
CvCapture* cap;
CamInfo cam_info;
float dt_valid;
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index db1512cb..aa0e4272 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -58,13 +58,12 @@ void Tracker::run()
if (commands & PAUSE) continue;
commands = 0;
- float dt = time.elapsed();
+ float dt = time.elapsed() / 1000.0;
time.restart();
frame = camera.get_frame(dt);
if (!frame.empty())
{
- qDebug()<<"processing frame";
const std::vector<cv::Vec2f>& points = point_extractor.extract_points(frame, dt, draw_frame);
point_tracker.track(points, camera.get_info().f, dt);
frame_count++;
@@ -77,24 +76,33 @@ void Tracker::run()
void Tracker::apply(const TrackerSettings& settings)
{
- apply_without_camindex(settings);
+ qDebug()<<"Tracker::apply";
QMutexLocker lock(&mutex);
- qDebug()<<"Tracker: setting cam index "<<settings.cam_index;
camera.set_index(settings.cam_index);
- qDebug()<<"Tracker: done setting cam index";
-}
-
-void Tracker::apply_without_camindex(const TrackerSettings& settings)
-{
- qDebug()<<"Tracker::apply_without_camindex";
- QMutexLocker lock(&mutex);
camera.set_f(settings.cam_f);
+ camera.set_res(settings.cam_res_x, settings.cam_res_y);
+ camera.set_fps(settings.cam_fps);
point_extractor.threshold_val = settings.threshold;
point_extractor.min_size = settings.min_point_size;
point_extractor.max_size = settings.max_point_size;
point_tracker.point_model = boost::shared_ptr<PointModel>(new PointModel(settings.M01, settings.M02));
sleep_time = settings.sleep_time;
+ // TODO: reset time
draw_frame = settings.video_widget;
+ t_MH = settings.t_MH;
+}
+
+void Tracker::reset()
+{
+ //TODO
+}
+
+void Tracker::center()
+{
+ QMutexLocker lock(&mutex);
+ FrameTrafo X_CM_0 = point_tracker.get_pose();
+ FrameTrafo X_MH(Matx33f::eye(), t_MH);
+ X_CH_0 = X_CM_0 * X_MH;
}
//-----------------------------------------------------------------------------
@@ -123,7 +131,6 @@ void Tracker::refreshVideo()
{
Mat frame_copy;
shared_ptr< vector<Vec2f> > points;
- qDebug("Tracker::refreshVideo()");
{
QMutexLocker lock(&mutex);
if (!draw_frame || frame.empty()) return;
@@ -152,21 +159,6 @@ bool Tracker::GiveHeadPoseData(THeadPoseData *data)
const float rad2deg = 180.0/3.14159265;
{
QMutexLocker lock(&mutex);
-<<<<<<< .mine
- // convert to cm
- data->x = pose.t[0] / 10.0;
- data->y = pose.t[1] / 10.0;
- data->z = pose.t[2] / 10.0;
- const Matx33f& R = pose.R;
- data->yaw = atan2( -R(2,0), sqrt(R(0,0)*R(0,0) + R(1,0)*R(1,0)) );
- float cos_beta = cos(data->yaw);
- if (cos_beta != 0)
- {
- data->pitch = rad2deg * atan2( R(2,1)/cos_beta, R(2,2)/cos_beta);
- data->roll = rad2deg * atan2( R(1,0)/cos_beta, R(0,0)/cos_beta);
- }
- data->yaw *= rad2deg;
-=======
FrameTrafo X_CM = point_tracker.get_pose();
FrameTrafo X_MH(Matx33f::eye(), t_MH);
@@ -194,23 +186,13 @@ bool Tracker::GiveHeadPoseData(THeadPoseData *data)
alpha = atan2( R(1,0), R(0,0));
gamma = atan2( R(2,1), R(2,2));
- data->yaw = rad2deg * alpha;
- data->pitch = rad2deg * beta;
- data->roll = rad2deg * gamma;
->>>>>>> .r148
+ data->yaw = rad2deg * alpha;
+ data->pitch = -rad2deg * beta; // this is what ftnoir expects?
+ data->roll = rad2deg * gamma;
}
return true;
}
-void Tracker::CenterTracker()
-{
- QMutexLocker lock(&mutex);
- FrameTrafo X_CM_0 = point_tracker.get_pose();
- FrameTrafo X_MH(Matx33f::eye(), t_MH);
- X_CH_0 = X_CM_0 * X_MH;
-
-}
-
//-----------------------------------------------------------------------------
#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
index 6b6af060..5461d133 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
@@ -27,9 +27,6 @@ public:
Tracker();
~Tracker();
- void CenterTracker();
-
-
// ITracker interface
void Initialize(QFrame *videoframe);
void StartTracker(HWND parent_window);
@@ -38,9 +35,14 @@ public:
void refreshVideo();
void apply(const TrackerSettings& settings);
- void apply_without_camindex(const TrackerSettings& settings); // changing the camindex is expensive and not suitable for realtime editing
+ void center();
+ void reset(); // reset the trackers internal state variables
void run();
+ void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_pose(); }
+ int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); }
+ void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); }
+
protected:
FrameTrafo X_CH_0; // for centering
@@ -58,7 +60,7 @@ protected:
Camera camera;
PointExtractor point_extractor;
PointTracker point_tracker;
- FrameTrafo X_MH;
+ cv::Vec3f t_MH;
bool draw_frame;
int sleep_time;
@@ -68,15 +70,4 @@ protected:
QTime time;
};
-//-----------------------------------------------------------------------------
-class TrackerDll : public ITrackerDll
-{
- // ITrackerDll interface
- void Initialize() {}
- void getFullName(QString *strToBeFilled);
- void getShortName(QString *strToBeFilled);
- void getDescription(QString *strToBeFilled);
- void getIcon(QIcon *icon);
-};
-
#endif // FTNOIR_TRACKER_PT_H
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
index a76a33d9..fca18fee 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
@@ -14,6 +14,7 @@
TrackerDialog::TrackerDialog()
: settings_dirty(false), tracker(NULL), timer(this), trans_calib_running(false)
{
+ qDebug()<<"TrackerDialog::TrackerDialog";
setAttribute(Qt::WA_DeleteOnClose, false);
ui.setupUi( this );
@@ -23,8 +24,12 @@ TrackerDialog::TrackerDialog()
// initialize ui values
ui.videowidget_check->setChecked(settings.video_widget);
ui.sleep_spin->setValue(settings.sleep_time);
+ ui.reset_spin->setValue(settings.reset_time);
ui.camindex_spin->setValue(settings.cam_index);
ui.f_dspin->setValue(settings.cam_f);
+ ui.res_x_spin->setValue(settings.cam_res_x);
+ ui.res_y_spin->setValue(settings.cam_res_y);
+ ui.fps_spin->setValue(settings.cam_fps);
ui.threshold_slider->setValue(settings.threshold);
ui.mindiam_spin->setValue(settings.min_point_size);
ui.maxdiam_spin->setValue(settings.max_point_size);
@@ -38,14 +43,16 @@ TrackerDialog::TrackerDialog()
ui.tx_spin->setValue(settings.t_MH[0]);
ui.ty_spin->setValue(settings.t_MH[1]);
ui.tz_spin->setValue(settings.t_MH[2]);
-
- ui.tcalib_button->setEnabled(false);
// connect Qt signals and slots
connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) );
connect( ui.sleep_spin,SIGNAL(valueChanged(int)), this,SLOT(set_sleep_time(int)) );
+ connect( ui.reset_spin,SIGNAL(valueChanged(int)), this,SLOT(set_reset_time(int)) );
connect( ui.camindex_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_index(int)) );
connect( ui.f_dspin,SIGNAL(valueChanged(double)), this,SLOT(set_cam_f(double)) );
+ connect( ui.res_x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_x(int)) );
+ connect( ui.res_y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_y(int)) );
+ connect( ui.fps_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_fps(int)) );
connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) );
connect( ui.mindiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_min_point_size(int)) );
connect( ui.maxdiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_max_point_size(int)) );
@@ -56,16 +63,18 @@ TrackerDialog::TrackerDialog()
connect( ui.m2x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2x(int)) );
connect( ui.m2y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2y(int)) );
connect( ui.m2z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2z(int)) );
- connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) );
- connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) );
- connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) );
+ connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) );
+ connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) );
+ connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) );
connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) );
- connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel()));
+ connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset()));
connect(ui.center_button, SIGNAL(clicked()), this, SLOT(doCenter()));
+ connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel()));
+
connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info()));
timer.start(100);
}
@@ -79,13 +88,13 @@ void TrackerDialog::startstop_trans_calib(bool start)
{
if (start)
{
- qDebug()<<"TrackerDialog:: starting translation calibration";
+ qDebug()<<"TrackerDialog:: Starting translation calibration";
trans_calib.reset();
trans_calib_running = true;
}
else
{
- qDebug()<<"TrackerDialog:: stoppping translation calibration";
+ qDebug()<<"TrackerDialog:: Stoppping translation calibration";
trans_calib_running = false;
settings.t_MH = trans_calib.get_estimate();
settings_changed();
@@ -100,32 +109,27 @@ void TrackerDialog::trans_calib_step()
tracker->get_pose(&X_CM);
trans_calib.update(X_CM.R, X_CM.t);
cv::Vec3f t_MH = trans_calib.get_estimate();
- //qDebug()<<"TrackerDialog:: current translation estimate: "<<t_MH[0]<<t_MH[1]<<t_MH[2];
+ //qDebug()<<"TrackerDialog:: Current translation estimate: "<<t_MH[0]<<t_MH[1]<<t_MH[2];
ui.tx_spin->setValue(t_MH[0]);
ui.ty_spin->setValue(t_MH[1]);
ui.tz_spin->setValue(t_MH[2]);
}
}
-void TrackerDialog::set_cam_index(int val)
-{
- settings.cam_index = val;
- settings_dirty = true;
- if (tracker)
- tracker->apply(settings);
-}
-
void TrackerDialog::settings_changed()
{
settings_dirty = true;
- if (tracker)
- tracker->apply_without_camindex(settings);
+ if (tracker) tracker->apply(settings);
}
void TrackerDialog::doCenter()
{
- if (tracker)
- tracker->CenterTracker();
+ if (tracker) tracker->center();
+}
+
+void TrackerDialog::doReset()
+{
+ if (tracker) tracker->reset();
}
void TrackerDialog::doOK()
@@ -164,10 +168,12 @@ void TrackerDialog::poll_tracker_info()
{
if (tracker)
{
+ // display caminfo
CamInfo info;
tracker->get_cam_info(&info);
ui.caminfo_label->setText(QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS");
+ // display pointinfo
int n_points = tracker->get_n_points();
QString to_print = QString::number(n_points);
if (n_points == 3)
@@ -176,6 +182,7 @@ void TrackerDialog::poll_tracker_info()
to_print += " BAD!";
ui.pointinfo_label->setText(to_print);
+ // update calibration
if (trans_calib_running) trans_calib_step();
}
else
@@ -199,18 +206,21 @@ void TrackerDialog::Initialize(QWidget *parent)
void TrackerDialog::registerTracker(ITracker *t)
{
- qDebug()<<"tracker registerd";
+ qDebug()<<"TrackerDialog:: Tracker registerd";
tracker = static_cast<Tracker*>(t);
- if (isVisible() && settings_dirty)
- tracker->apply(settings);
- ui.tcalib_button->setEnabled(true);
+ if (isVisible() && settings_dirty) tracker->apply(settings);
+ ui.tcalib_button->setEnabled(true);
+ ui.center_button->setEnabled(true);
+ ui.reset_button->setEnabled(true);
}
void TrackerDialog::unRegisterTracker()
{
- qDebug()<<"tracker un-registerd";
+ qDebug()<<"TrackerDialog:: Tracker un-registerd";
tracker = NULL;
ui.tcalib_button->setEnabled(false);
+ ui.center_button->setEnabled(false);
+ ui.reset_button->setEnabled(false);
}
//-----------------------------------------------------------------------------
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
index 4b92fa72..e5a27dc5 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
@@ -12,6 +12,9 @@
#include "ftnoir_tracker_pt_settings.h"
#include "ftnoir_tracker_pt.h"
#include "ui_FTNoIR_PT_Controls.h"
+#include "trans_calib.h"
+
+#include <QTimer>
//-----------------------------------------------------------------------------
class TrackerDialog : public QWidget, Ui::UICPTClientControls, public ITrackerDialog
@@ -25,17 +28,19 @@ public:
void Initialize(QWidget *parent);
void registerTracker(ITracker *tracker);
void unRegisterTracker();
+
+ void trans_calib_step();
protected slots:
- void doOK();
- void doCancel();
- void doCenter();
-
// ugly qt stuff
void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); }
void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); }
- void set_cam_index(int val);
+ void set_reset_time(int val) { settings.reset_time = val; settings_changed(); }
+ void set_cam_index(int val) { settings.cam_index = val; settings_changed(); }
void set_cam_f(double val) { settings.cam_f = val; settings_changed(); }
+ void set_cam_res_x(int val) { settings.cam_res_x = val; settings_changed(); }
+ void set_cam_res_y(int val) { settings.cam_res_y = val; settings_changed(); }
+ void set_cam_fps(int val) { settings.cam_fps = val; settings_changed(); }
void set_min_point_size(int val) { settings.min_point_size = val; settings_changed(); }
void set_max_point_size(int val) { settings.max_point_size = val; settings_changed(); }
void set_threshold(int val) { settings.threshold = val; settings_changed(); }
@@ -45,6 +50,19 @@ protected slots:
void set_m2x(int val) { settings.M02[0] = val; settings_changed(); }
void set_m2y(int val) { settings.M02[1] = val; settings_changed(); }
void set_m2z(int val) { settings.M02[2] = val; settings_changed(); }
+ void set_tx(int val) { settings.t_MH[0] = val; settings_changed(); }
+ void set_ty(int val) { settings.t_MH[1] = val; settings_changed(); }
+ void set_tz(int val) { settings.t_MH[2] = val; settings_changed(); }
+
+ void doCenter();
+ void doReset();
+
+ void doOK();
+ void doCancel();
+
+ void startstop_trans_calib(bool start);
+
+ void poll_tracker_info();
protected:
void settings_changed();
@@ -53,6 +71,9 @@ protected:
bool settings_dirty;
Tracker* tracker;
+ TranslationCalibrator trans_calib;
+ bool trans_calib_running;
+ QTimer timer;
Ui::UICPTClientControls ui;
};
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp
index 3210a027..d41e5db2 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp
@@ -5,14 +5,14 @@
* copyright notice and this permission notice appear in all copies.
*/
-#include "ftnoir_tracker_pt.h"
+#include "ftnoir_tracker_pt_dll.h"
#include <QIcon>
//-----------------------------------------------------------------------------
void TrackerDll::getFullName(QString *strToBeFilled)
{
- *strToBeFilled = "PointTracker 0.1";
+ *strToBeFilled = "PointTracker 0.2";
}
void TrackerDll::getShortName(QString *strToBeFilled)
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h
index 34f6801e..15ad63aa 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h
@@ -5,4 +5,15 @@
* copyright notice and this permission notice appear in all copies.
*/
-#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" \ No newline at end of file
+#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h"
+
+//-----------------------------------------------------------------------------
+class TrackerDll : public ITrackerDll
+{
+ // ITrackerDll interface
+ void Initialize() {}
+ void getFullName(QString *strToBeFilled);
+ void getShortName(QString *strToBeFilled);
+ void getDescription(QString *strToBeFilled);
+ void getIcon(QIcon *icon);
+}; \ No newline at end of file
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
index 408ac9d2..d67ced5e 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
@@ -22,18 +22,24 @@ void TrackerSettings::load_ini()
cam_index = iniFile.value("CameraId", 0).toInt();
cam_f = iniFile.value("CameraF", 1).toFloat();
+ cam_res_x = iniFile.value("CameraResX", 640).toInt();
+ cam_res_y = iniFile.value("CameraResY", 480).toInt();
+ cam_fps = iniFile.value("CameraFPS", 30).toInt();
threshold = iniFile.value("PointExtractThreshold", 128).toInt();
min_point_size = iniFile.value("PointExtractMinSize", 2).toInt();
max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt();
- M01[0] = iniFile.value("PointModelM01x", 0).toFloat();
- M01[1] = iniFile.value("PointModelM01y", 40).toFloat();
- M01[2] = iniFile.value("PointModelM01z", -30).toFloat();
- M02[0] = iniFile.value("PointModelM02x", 0).toFloat();
- M02[1] = iniFile.value("PointModelM02y", -70).toFloat();
- M02[2] = iniFile.value("PointModelM02z", -80).toFloat();
- //TODO: headpos
+ M01[0] = iniFile.value("PointModelM01x", 0).toFloat();
+ M01[1] = iniFile.value("PointModelM01y", 40).toFloat();
+ M01[2] = iniFile.value("PointModelM01z", -30).toFloat();
+ M02[0] = iniFile.value("PointModelM02x", 0).toFloat();
+ M02[1] = iniFile.value("PointModelM02y", -70).toFloat();
+ M02[2] = iniFile.value("PointModelM02z", -80).toFloat();
+ t_MH[0] = iniFile.value("tMHx", 0).toFloat();
+ t_MH[1] = iniFile.value("tMHy", 0).toFloat();
+ t_MH[2] = iniFile.value("tMHz", 0).toFloat();
video_widget = iniFile.value("VideoWidget", true).toBool();
sleep_time = iniFile.value("SleepTime", 10).toInt();
+ reset_time = iniFile.value("ResetTime", 3).toInt();
iniFile.endGroup();
}
@@ -50,6 +56,9 @@ void TrackerSettings::save_ini() const
iniFile.setValue("CameraId", cam_index);
iniFile.setValue("CameraF", cam_f);
+ iniFile.setValue("CameraResX", cam_res_x);
+ iniFile.setValue("CameraResY", cam_res_y);
+ iniFile.setValue("CameraFPS", cam_fps);
iniFile.setValue("PointExtractThreshold", threshold);
iniFile.setValue("PointExtractMinSize", min_point_size);
iniFile.setValue("PointExtractMaxSize", max_point_size);
@@ -59,9 +68,12 @@ void TrackerSettings::save_ini() const
iniFile.setValue("PointModelM02x", M02[0]);
iniFile.setValue("PointModelM02y", M02[1]);
iniFile.setValue("PointModelM02z", M02[2]);
- //TODO: headpos
+ iniFile.setValue("tMHx", t_MH[0]);
+ iniFile.setValue("tMHy", t_MH[1]);
+ iniFile.setValue("tMHz", t_MH[2]);
iniFile.setValue("VideoWidget", video_widget);
iniFile.setValue("SleepTime", sleep_time);
+ iniFile.setValue("ResetTime", reset_time);
iniFile.endGroup();
} \ No newline at end of file
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
index 18ff6e37..8868f418 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
@@ -17,6 +17,9 @@ struct TrackerSettings
// camera
int cam_index;
float cam_f;
+ int cam_res_x;
+ int cam_res_y;
+ int cam_fps;
// point extraction
int threshold;
@@ -27,10 +30,11 @@ struct TrackerSettings
cv::Vec3f M01;
cv::Vec3f M02;
- // head pos
- FrameTrafo X_MH;
+ // head to model translation
+ cv::Vec3f t_MH;
- int sleep_time;
+ int sleep_time; // in ms
+ int reset_time; // in s
bool video_widget;
void load_ini();
diff --git a/FTNoIR_Tracker_PT/point_extractor.cpp b/FTNoIR_Tracker_PT/point_extractor.cpp
index cdb9d3f1..b26f7068 100644
--- a/FTNoIR_Tracker_PT/point_extractor.cpp
+++ b/FTNoIR_Tracker_PT/point_extractor.cpp
@@ -40,7 +40,7 @@ const vector<Vec2f>& PointExtractor::extract_points(Mat frame, float dt, bool dr
// find connected components...
// Method 1: contours
- /*
+ //*
// find contours
vector< vector<Point> > contours;
findContours(frame_bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
@@ -64,10 +64,10 @@ const vector<Vec2f>& PointExtractor::extract_points(Mat frame, float dt, bool dr
c[1] = -(m.m01/m.m00 - frame.rows/2)/frame.cols;
points.push_back(c);
}
- */
+ //*/
// Method 2: floodfill
- //*
+ /*
// extract blobs
struct BlobInfo
{
@@ -115,7 +115,7 @@ const vector<Vec2f>& PointExtractor::extract_points(Mat frame, float dt, bool dr
c[1] = -(m.m01/float(m.m00) - frame.rows/2)/frame.cols;
points.push_back(c);
}
- //*/
+ */
// draw output image
if (draw_output)
diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp
index cbe3e9da..90093032 100644
--- a/FTNoIR_Tracker_PT/point_tracker.cpp
+++ b/FTNoIR_Tracker_PT/point_tracker.cpp
@@ -223,8 +223,8 @@ void PointTracker::POSIT(float f)
X_CM.t[1] = p[0][1] * Z0/f;
X_CM.t[2] = Z0;
- qDebug()<<"iter: "<<i;
- qDebug()<<"t: "<<X_CM.t[0]<<' '<<X_CM.t[1]<<' '<<X_CM.t[2];
+ //qDebug()<<"iter: "<<i;
+ //qDebug()<<"t: "<<X_CM.t[0]<<' '<<X_CM.t[1]<<' '<<X_CM.t[2];
//Vec3f r;
//Rodrigues(X_CM.R, r);
//qDebug()<<"r: "<<r[0]<<' '<<r[1]<<' '<<r[2]<<'\n';