summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui214
-rw-r--r--FTNoIR_Tracker_PT/camera.h12
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp155
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.h36
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp318
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h69
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp156
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h137
8 files changed, 338 insertions, 759 deletions
diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
index 9ad4f83c..6cd17e8d 100644
--- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
+++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>458</width>
+ <width>459</width>
<height>590</height>
</rect>
</property>
@@ -69,12 +69,40 @@
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
+ <item row="1" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item>
+ <widget class="QSpinBox" name="reset_spin">
+ <property name="toolTip">
+ <string>Time until automatic reset of tracker's internal state when no valid tracking result is found</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_42">
+ <property name="text">
+ <string>ms</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="3">
<widget class="QCheckBox" name="dynpose_check">
<property name="toolTip">
<string/>
</property>
<property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="label_17">
+ <property name="text">
<string>Dynamic Pose Resolution</string>
</property>
</widget>
@@ -89,30 +117,6 @@
</property>
</widget>
</item>
- <item row="0" column="3">
- <layout class="QHBoxLayout" name="horizontalLayout_11">
- <item>
- <widget class="QSpinBox" name="sleep_spin">
- <property name="toolTip">
- <string>Time the tracker thread sleeps after each processed frame</string>
- </property>
- <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="2">
<widget class="QLabel" name="label_43">
<property name="text">
@@ -123,12 +127,15 @@
</property>
</widget>
</item>
- <item row="1" column="3">
- <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item row="0" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
- <widget class="QSpinBox" name="reset_spin">
+ <widget class="QSpinBox" name="sleep_spin">
<property name="toolTip">
- <string>Time until automatic reset of tracker's internal state when no valid tracking result is found</string>
+ <string>Time the tracker thread sleeps after each processed frame</string>
+ </property>
+ <property name="suffix">
+ <string/>
</property>
<property name="maximum">
<number>9999</number>
@@ -136,7 +143,7 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="label_42">
+ <widget class="QLabel" name="label_40">
<property name="text">
<string>ms</string>
</property>
@@ -144,43 +151,7 @@
</item>
</layout>
</item>
- <item row="0" column="0">
- <widget class="QCheckBox" name="videowidget_check">
- <property name="toolTip">
- <string>Whether to update the content of the VideoWidget</string>
- </property>
- <property name="text">
- <string>Show VideoWidget</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <spacer name="horizontalSpacer_7">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>30</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="1">
- <spacer name="horizontalSpacer_11">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>30</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0">
+ <item row="3" column="3">
<widget class="QPushButton" name="reset_button">
<property name="enabled">
<bool>false</bool>
@@ -635,40 +606,7 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <widget class="QPushButton" name="videowidget_button">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="minimumSize">
- <size>
- <width>130</width>
- <height>0</height>
- </size>
- </property>
- <property name="locale">
- <locale language="English" country="UnitedStates"/>
- </property>
- <property name="text">
- <string>VideoWidget</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_12">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>0</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <layout class="QHBoxLayout" name="horizontalLayout_7"/>
</item>
</layout>
</widget>
@@ -848,38 +786,36 @@
</item>
</layout>
</item>
-
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_secondary">
- <item>
- <widget class="QLabel" name="label_secondary">
- <property name="text">
- <string>Hysteresis</string>
- </property>
- <property name="buddy">
- <cstring>threshold_secondary_slider</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSlider" name="threshold_secondary_slider">
- <property name="toolTip">
- <string>Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise)</string>
- </property>
- <property name="maximum">
- <number>255</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- </layout>
- </item>
-
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_secondary">
+ <item>
+ <widget class="QLabel" name="label_secondary">
+ <property name="text">
+ <string>Hysteresis</string>
+ </property>
+ <property name="buddy">
+ <cstring>threshold_secondary_slider</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="threshold_secondary_slider">
+ <property name="toolTip">
+ <string>Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise)</string>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -1778,6 +1714,13 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
+ <widget class="QPushButton" name="btnApply">
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -1816,11 +1759,8 @@
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
- <tabstop>videowidget_check</tabstop>
<tabstop>sleep_spin</tabstop>
- <tabstop>dynpose_check</tabstop>
<tabstop>reset_spin</tabstop>
- <tabstop>reset_button</tabstop>
<tabstop>chkEnableRoll</tabstop>
<tabstop>chkEnablePitch</tabstop>
<tabstop>chkEnableYaw</tabstop>
diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h
index 78fe8dfb..ea68c387 100644
--- a/FTNoIR_Tracker_PT/camera.h
+++ b/FTNoIR_Tracker_PT/camera.h
@@ -69,13 +69,13 @@ protected:
virtual void _set_fps() = 0;
virtual void _set_res() = 0;
- bool active;
+ float dt_valid;
+ float dt_mean;
int desired_index;
int active_index;
+ bool active;
CamInfo cam_info;
CamInfo cam_desired;
- float dt_valid;
- float dt_mean;
};
@@ -128,9 +128,9 @@ protected:
enum RotationType
{
- CLOCKWISE = -1,
- ZERO = 0,
- COUNTER_CLOCKWISE = 1
+ CLOCKWISE = 0,
+ ZERO = 1,
+ COUNTER_CLOCKWISE = 2
};
// ----------------------------------------------------------------------------
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index e3af446f..25a19ee7 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -23,8 +23,7 @@ const float deg2rad = 1.0/rad2deg;
//-----------------------------------------------------------------------------
Tracker::Tracker()
- : frame_count(0),
- commands(0),
+ : commands(0),
video_widget(NULL),
video_frame(NULL),
tracking_valid(false)
@@ -38,9 +37,10 @@ Tracker::~Tracker()
// terminate tracker thread
set_command(ABORT);
wait();
- // destroy video widget
- show_video_widget = false;
- update_show_video_widget();
+ s.video_widget = false;
+ delete video_widget;
+ video_widget = NULL;
+ if (video_frame->layout()) delete video_frame->layout();
}
void Tracker::set_command(Command command)
@@ -86,10 +86,7 @@ void Tracker::run()
frame = frame_rotation.rotate_frame(frame);
const std::vector<cv::Vec2f>& points = point_extractor.extract_points(frame, dt, has_observers());
tracking_valid = point_tracker.track(points, camera.get_info().f, dt);
- frame_count++;
-#ifdef OPENTRACK_API
video_widget->update_image(frame.clone());
-#endif
}
#ifdef PT_PERF_LOG
log_stream<<"dt: "<<dt;
@@ -97,45 +94,39 @@ void Tracker::run()
log_stream<<"\n";
#endif
}
- msleep(sleep_time);
+ msleep(s.sleep_time);
}
qDebug()<<"Tracker:: Thread stopping";
}
-void Tracker::apply(const TrackerSettings& settings)
+void Tracker::apply(settings& s)
{
qDebug()<<"Tracker:: Applying settings";
QMutexLocker lock(&mutex);
- camera.set_device_index(settings.cam_index);
- camera.set_res(settings.cam_res_x, settings.cam_res_y);
- camera.set_fps(settings.cam_fps);
- camera.set_f(settings.cam_f);
- frame_rotation.rotation = static_cast<RotationType>(settings.cam_roll);
- point_extractor.threshold_val = settings.threshold;
- point_extractor.threshold_secondary_val = settings.threshold_secondary;
- 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));
- point_tracker.dynamic_pose_resolution = settings.dyn_pose_res;
- sleep_time = settings.sleep_time;
- point_tracker.dt_reset = settings.reset_time / 1000.0;
- show_video_widget = settings.video_widget;
- update_show_video_widget();
- bEnableRoll = settings.bEnableRoll;
- bEnablePitch = settings.bEnablePitch;
- bEnableYaw = settings.bEnableYaw;
- bEnableX = settings.bEnableX;
- bEnableY = settings.bEnableY;
- bEnableZ = settings.bEnableZ;
-
- t_MH = settings.t_MH;
- R_GC = Matx33f( cos(deg2rad*settings.cam_yaw), 0, sin(deg2rad*settings.cam_yaw),
+ camera.set_device_index(s.cam_index);
+ camera.set_res(s.cam_res_x, s.cam_res_y);
+ camera.set_fps(s.cam_fps);
+ camera.set_f(s.cam_f);
+ frame_rotation.rotation = static_cast<RotationType>(static_cast<int>(s.cam_roll));
+ point_extractor.threshold_val = s.threshold;
+ point_extractor.threshold_secondary_val = s.threshold_secondary;
+ point_extractor.min_size = s.min_point_size;
+ point_extractor.max_size = s.max_point_size;
+ {
+ cv::Vec3f M01(s.m01_x, s.m01_y, s.m01_z);
+ cv::Vec3f M02(s.m02_x, s.m02_y, s.m02_z);
+ point_tracker.point_model = boost::shared_ptr<PointModel>(new PointModel(M01, M02));
+ }
+ point_tracker.dynamic_pose_resolution = s.dyn_pose_res;
+ point_tracker.dt_reset = s.reset_time / 1000.0;
+ t_MH = cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z);
+ R_GC = Matx33f( cos(deg2rad*s.cam_yaw), 0, sin(deg2rad*s.cam_yaw),
0, 1, 0,
- -sin(deg2rad*settings.cam_yaw), 0, cos(deg2rad*settings.cam_yaw));
+ -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw));
R_GC = R_GC * Matx33f( 1, 0, 0,
- 0, cos(deg2rad*settings.cam_pitch), sin(deg2rad*settings.cam_pitch),
- 0, -sin(deg2rad*settings.cam_pitch), cos(deg2rad*settings.cam_pitch));
+ 0, cos(deg2rad*s.cam_pitch), sin(deg2rad*s.cam_pitch),
+ 0, -sin(deg2rad*s.cam_pitch), cos(deg2rad*s.cam_pitch));
FrameTrafo X_MH(Matx33f::eye(), t_MH);
X_GH_0 = R_GC * X_MH;
@@ -169,58 +160,27 @@ bool Tracker::get_frame_and_points(cv::Mat& frame_copy, boost::shared_ptr< std::
return true;
}
-void Tracker::update_show_video_widget()
-{
- if (!show_video_widget && video_widget) {
- delete video_widget;
- video_widget = NULL;
- if (video_frame->layout()) delete video_frame->layout();
- }
- else if (video_frame && show_video_widget && !video_widget)
- {
- const int VIDEO_FRAME_WIDTH = 320;
- const int VIDEO_FRAME_HEIGHT = 240;
- video_widget = new PTVideoWidget(video_frame, this);
- QHBoxLayout* video_layout = new QHBoxLayout();
- video_layout->setContentsMargins(0, 0, 0, 0);
- video_layout->addWidget(video_widget);
- video_frame->setLayout(video_layout);
- video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT);
- }
-}
-
-//-----------------------------------------------------------------------------
-// ITracker interface
-void Tracker::Initialize(QFrame *video_frame)
-{
- qDebug("Tracker::Initialize");
- // setup video frame
- this->video_frame = video_frame;
- video_frame->setAttribute(Qt::WA_NativeWindow);
- video_frame->show();
- update_show_video_widget();
- TrackerSettings settings;
- settings.load_ini();
- camera.start();
- apply(settings);
- start();
-}
-
void Tracker::refreshVideo()
{
if (video_widget) video_widget->update_frame_and_points();
}
-#ifdef OPENTRACK_API
void Tracker::StartTracker(QFrame *parent_window)
-#else
-void Tracker::StartTracker(HWND parent_window)
-#endif
{
-#ifdef OPENTRACK_API
- Initialize(parent_window);
-#endif
- reset_command(PAUSE);
+ this->video_frame = parent_window;
+ video_frame->setAttribute(Qt::WA_NativeWindow);
+ video_frame->show();
+ apply(s);
+ video_widget = new PTVideoWidget(video_frame, this);
+ QHBoxLayout* video_layout = new QHBoxLayout(parent_window);
+ video_layout->setContentsMargins(0, 0, 0, 0);
+ video_layout->addWidget(video_widget);
+ video_frame->setLayout(video_layout);
+ video_widget->resize(video_frame->width(), video_frame->height());
+ start();
+ camera.start();
+ start();
+ reset_command(PAUSE);
}
#ifndef OPENTRACK_API
@@ -247,18 +207,12 @@ void Tracker::GetHeadPoseData(THeadPoseData *data)
Matx33f R = X_GH.R * X_GH_0.R.t();
Vec3f t = X_GH.t - X_GH_0.t;
-#ifndef OPENTRACK_API
- // get translation(s)
- if (bEnableX) data->x = t[0] / 10.0; // convert to cm
- if (bEnableY) data->y = t[1] / 10.0;
- if (bEnableZ) data->z = t[2] / 10.0;
-#else
// get translation(s)
- if (bEnableX) data[TX] = t[0] / 10.0; // convert to cm
- if (bEnableY) data[TY] = t[1] / 10.0;
- if (bEnableZ) data[TZ] = t[2] / 10.0;
-#endif
- // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame
+ if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm
+ if (s.bEnableY) data[TY] = t[1] / 10.0;
+ if (s.bEnableZ) data[TZ] = t[2] / 10.0;
+
+ // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame
// -z -> x, y -> z, x -> -y
Matx33f R_EG( 0, 0,-1,
-1, 0, 0,
@@ -271,19 +225,10 @@ void Tracker::GetHeadPoseData(THeadPoseData *data)
alpha = atan2( R(1,0), R(0,0));
gamma = atan2( R(2,1), R(2,2));
-#ifndef OPENTRACK_API
- if (bEnableYaw) data->yaw = rad2deg * alpha;
- if (bEnablePitch) data->pitch = - rad2deg * beta; // FTNoIR expects a minus here
- if (bEnableRoll) data->roll = rad2deg * gamma;
-#else
- if (bEnableYaw) data[Yaw] = rad2deg * alpha;
- if (bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here
- if (bEnableRoll) data[Roll] = rad2deg * gamma;
-#endif
+ if (s.bEnableYaw) data[Yaw] = rad2deg * alpha;
+ if (s.bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here
+ if (s.bEnableRoll) data[Roll] = rad2deg * gamma;
}
-#ifndef OPENTRACK_API
- return true;
-#endif
}
//-----------------------------------------------------------------------------
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
index 54edafb2..c7f1dc02 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
@@ -39,20 +39,11 @@ class Tracker : public ITracker, QThread, public FrameProvider
public:
Tracker();
virtual ~Tracker();
-
- // --- ITracker interface ---
- virtual void Initialize(QFrame *videoframe);
-#ifdef OPENTRACK_API
virtual void StartTracker(QFrame* parent_window);
virtual void GetHeadPoseData(double* data);
-#else
- virtual void StartTracker(HWND parent_window);
- virtual void StopTracker(bool exit);
- virtual bool GetHeadPoseData(THeadPoseData *data);
-#endif
virtual void refreshVideo();
- void apply(const TrackerSettings& settings);
+ void apply(settings& s);
void center();
void reset(); // reset the trackers internal state variables
void run();
@@ -74,20 +65,12 @@ protected:
};
void set_command(Command command);
void reset_command(Command command);
- int commands;
-
- int sleep_time;
+ int commands;
- // --- tracking chain ---
-#ifdef OPENTRACK_API
CVCamera camera;
-#else
- VICamera camera;
-#endif
FrameRotation frame_rotation;
PointExtractor point_extractor;
PointTracker point_tracker;
- bool tracking_valid;
FrameTrafo X_GH_0; // for centering
cv::Vec3f t_MH; // translation from model frame to head frame
@@ -96,22 +79,11 @@ protected:
// --- ui ---
cv::Mat frame; // the output frame for display
- void update_show_video_widget();
- bool show_video_widget;
-#ifdef OPENTRACK_API
PTVideoWidget* video_widget;
-#endif
QFrame* video_frame;
+ bool tracking_valid;
- // --- misc ---
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
-
- long frame_count;
+ settings s;
Timer time;
};
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
index f8afa790..a88e3a07 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
@@ -21,8 +21,7 @@ using namespace std;
//-----------------------------------------------------------------------------
TrackerDialog::TrackerDialog()
- : settings_dirty(false),
- tracker(NULL),
+ : tracker(NULL),
video_widget_dialog(NULL),
timer(this),
trans_calib_running(false)
@@ -32,191 +31,112 @@ TrackerDialog::TrackerDialog()
ui.setupUi( this );
- settings.load_ini();
- dialog_settings.load_ini();
-
- // initialize ui values
- ui.videowidget_check->setChecked(settings.video_widget);
- ui.dynpose_check->setChecked(settings.dyn_pose_res);
- ui.sleep_spin->setValue(settings.sleep_time);
- ui.reset_spin->setValue(settings.reset_time);
-
- vector<string> device_names;
+ vector<string> device_names;
get_camera_device_names(device_names);
for (vector<string>::iterator iter = device_names.begin(); iter != device_names.end(); ++iter)
{
ui.camdevice_combo->addItem(iter->c_str());
}
- ui.camdevice_combo->setCurrentIndex(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.camroll_combo->addItem("-90", -1);
- ui.camroll_combo->addItem("0" , 0);
- ui.camroll_combo->addItem("90" , 1);
- int i = ui.camroll_combo->findData(settings.cam_roll);
- ui.camroll_combo->setCurrentIndex(i>=0 ? i : 0);
-
- ui.campitch_spin->setValue(settings.cam_pitch);
- ui.camyaw_spin->setValue(settings.cam_yaw);
- ui.threshold_slider->setValue(settings.threshold);
- ui.threshold_secondary_slider->setValue(settings.threshold_secondary);
-
- ui.chkEnableRoll->setChecked(settings.bEnableRoll);
- ui.chkEnablePitch->setChecked(settings.bEnablePitch);
- ui.chkEnableYaw->setChecked(settings.bEnableYaw);
- ui.chkEnableX->setChecked(settings.bEnableX);
- ui.chkEnableY->setChecked(settings.bEnableY);
- ui.chkEnableZ->setChecked(settings.bEnableZ);
-
- ui.mindiam_spin->setValue(settings.min_point_size);
- ui.maxdiam_spin->setValue(settings.max_point_size);
- ui.model_tabs->setCurrentIndex(dialog_settings.active_model_panel);
- ui.clip_bheight_spin->setValue(dialog_settings.clip_by);
- ui.clip_blength_spin->setValue(dialog_settings.clip_bz);
- ui.clip_theight_spin->setValue(dialog_settings.clip_ty);
- ui.clip_tlength_spin->setValue(dialog_settings.clip_tz);
- ui.cap_width_spin->setValue(dialog_settings.cap_x);
- ui.cap_height_spin->setValue(dialog_settings.cap_y);
- ui.cap_length_spin->setValue(dialog_settings.cap_z);
- ui.m1x_spin->setValue(dialog_settings.M01x);
- ui.m1y_spin->setValue(dialog_settings.M01y);
- ui.m1z_spin->setValue(dialog_settings.M01z);
- ui.m2x_spin->setValue(dialog_settings.M02x);
- ui.m2y_spin->setValue(dialog_settings.M02y);
- ui.m2z_spin->setValue(dialog_settings.M02z);
- ui.tx_spin->setValue(settings.t_MH[0]);
- ui.ty_spin->setValue(settings.t_MH[1]);
- ui.tz_spin->setValue(settings.t_MH[2]);
-
- // connect Qt signals and slots
- connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) );
- connect( ui.dynpose_check,SIGNAL(toggled(bool)), this,SLOT(set_dyn_pose_res(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.camdevice_combo,SIGNAL(currentIndexChanged(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.camroll_combo,SIGNAL(currentIndexChanged(int)), this,SLOT(set_cam_roll(int)) );
- connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) );
- connect( ui.camyaw_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_yaw(int)) );
- connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) );
- connect( ui.threshold_secondary_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold_secondary(int)) );
-
- connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) );
- connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) );
- connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) );
- connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) );
- connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) );
- connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) );
-
- 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)) );
- connect( ui.model_tabs,SIGNAL(currentChanged(int)), this,SLOT(set_model(int)) );
- connect( ui.clip_theight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_height(int)) );
- connect( ui.clip_tlength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_length(int)) );
- connect( ui.clip_bheight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_height(int)) );
- connect( ui.clip_blength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_length(int)) );
- connect( ui.cap_width_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_width(int)) );
- connect( ui.cap_height_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_height(int)) );
- connect( ui.cap_length_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_length(int)) );
- connect( ui.m1x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1x(int)) );
- connect( ui.m1y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1y(int)) );
- connect( ui.m1z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1z(int)) );
- 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.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) );
-
- connect( ui.videowidget_button,SIGNAL(clicked()), this,SLOT(create_video_widget()) );
-
- 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);
-}
-TrackerDialog::~TrackerDialog()
-{
- qDebug()<<"TrackerDialog::~TrackerDialog";
-}
+ ui.camroll_combo->addItem("-90");
+ ui.camroll_combo->addItem("0");
+ ui.camroll_combo->addItem("90");
-void TrackerDialog::set_cam_roll(int idx)
-{
- settings.cam_roll = ui.camroll_combo->itemData(idx).toInt();
- settings_changed();
+ tie_setting(s.dyn_pose_res, ui.dynpose_check);
+ tie_setting(s.sleep_time, ui.sleep_spin);
+ tie_setting(s.reset_time, ui.reset_spin);
+
+ tie_setting(s.cam_index, ui.camdevice_combo);
+ tie_setting(s.cam_f, ui.f_dspin);
+ tie_setting(s.cam_res_x, ui.res_x_spin);
+ tie_setting(s.cam_res_y, ui.res_y_spin);
+ tie_setting(s.cam_fps, ui.fps_spin);
+ tie_setting(s.cam_roll, ui.camroll_combo);
+ tie_setting(s.cam_pitch, ui.campitch_spin);
+ tie_setting(s.cam_yaw, ui.camyaw_spin);
+
+ tie_setting(s.threshold_secondary, ui.threshold_secondary_slider);
+ tie_setting(s.threshold, ui.threshold_slider);
+
+ tie_setting(s.bEnableYaw, ui.chkEnableYaw);
+ tie_setting(s.bEnablePitch, ui.chkEnablePitch);
+ tie_setting(s.bEnableRoll, ui.chkEnableRoll);
+ tie_setting(s.bEnableX, ui.chkEnableX);
+ tie_setting(s.bEnableY, ui.chkEnableY);
+ tie_setting(s.bEnableZ, ui.chkEnableZ);
+
+ tie_setting(s.min_point_size, ui.mindiam_spin);
+ tie_setting(s.max_point_size, ui.maxdiam_spin);
+
+ tie_setting(s.clip_by, ui.clip_bheight_spin);
+ tie_setting(s.clip_bz, ui.clip_blength_spin);
+ tie_setting(s.clip_ty, ui.clip_theight_spin);
+ tie_setting(s.clip_tz, ui.clip_tlength_spin);
+
+ tie_setting(s.cap_x, ui.cap_width_spin);
+ tie_setting(s.cap_y, ui.cap_height_spin);
+ tie_setting(s.cap_z, ui.cap_length_spin);
+
+ tie_setting(s.m01_x, ui.m1x_spin);
+ tie_setting(s.m01_y, ui.m1y_spin);
+ tie_setting(s.m01_z, ui.m1z_spin);
+
+ tie_setting(s.m02_x, ui.m2x_spin);
+ tie_setting(s.m02_y, ui.m2y_spin);
+ tie_setting(s.m02_z, ui.m2z_spin);
+
+ tie_setting(s.t_MH_x, ui.tx_spin);
+ tie_setting(s.t_MH_y, ui.ty_spin);
+ tie_setting(s.t_MH_z, ui.tz_spin);
+
+ connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) );
+ connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset()));
+
+ connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel()));
+ connect(ui.btnApply, SIGNAL(clicked()), this, SLOT(doApply()));
+
+ ui.model_tabs->setCurrentIndex(s.active_model_panel);
+
+ connect(ui.model_tabs, SIGNAL(currentChanged(int)), this, SLOT(set_model(int)));
+ connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info()));
+ timer.start(100);
+
+ connect(s.b.get(), SIGNAL(bundleChanged()), this, SLOT(do_apply_without_saving()));
}
void TrackerDialog::set_model_clip()
{
- settings.M01[0] = 0;
- settings.M01[1] = dialog_settings.clip_ty;
- settings.M01[2] = -dialog_settings.clip_tz;
- settings.M02[0] = 0;
- settings.M02[1] = -dialog_settings.clip_by;
- settings.M02[2] = -dialog_settings.clip_bz;
+ s.m01_x = 0;
+ s.m01_y = static_cast<double>(s.clip_ty);
+ s.m01_z = -static_cast<double>(s.clip_tz);
+ s.m02_x = 0;
+ s.m02_y = -static_cast<double>(s.clip_by);
+ s.m02_z = -static_cast<double>(s.clip_bz);
settings_changed();
}
void TrackerDialog::set_model_cap()
{
- settings.M01[0] = -dialog_settings.cap_x;
- settings.M01[1] = -dialog_settings.cap_y;
- settings.M01[2] = -dialog_settings.cap_z;
- settings.M02[0] = dialog_settings.cap_x;
- settings.M02[1] = -dialog_settings.cap_y;
- settings.M02[2] = -dialog_settings.cap_z;
+ s.m01_x = -static_cast<double>(s.cap_x);
+ s.m01_y = -static_cast<double>(s.cap_y);
+ s.m01_z = -static_cast<double>(s.cap_z);
+ s.m02_x = static_cast<double>(s.cap_x);
+ s.m02_y = -static_cast<double>(s.cap_y);
+ s.m02_z = -static_cast<double>(s.cap_z);
settings_changed();
}
void TrackerDialog::set_model_custom()
{
- settings.M01[0] = dialog_settings.M01x;
- settings.M01[1] = dialog_settings.M01y;
- settings.M01[2] = dialog_settings.M01z;
- settings.M02[0] = dialog_settings.M02x;
- settings.M02[1] = dialog_settings.M02y;
- settings.M02[2] = dialog_settings.M02z;
-
settings_changed();
}
void TrackerDialog::set_model(int val)
{
- dialog_settings.active_model_panel = val;
-
- switch (val) {
-
- case TrackerDialogSettings::MODEL_CLIP:
- set_model_clip();
- break;
-
- case TrackerDialogSettings::MODEL_CAP:
- set_model_cap();
- break;
-
- case TrackerDialogSettings::MODEL_CUSTOM:
- set_model_custom();
- break;
-
- default:
- break;
- }
+ s.active_model_panel = val;
}
void TrackerDialog::startstop_trans_calib(bool start)
@@ -231,7 +151,12 @@ void TrackerDialog::startstop_trans_calib(bool start)
{
qDebug()<<"TrackerDialog:: Stoppping translation calibration";
trans_calib_running = false;
- settings.t_MH = trans_calib.get_estimate();
+ {
+ auto tmp = trans_calib.get_estimate();
+ s.t_MH_x = tmp[0];
+ s.t_MH_y = tmp[1];
+ s.t_MH_z = tmp[2];
+ }
settings_changed();
}
}
@@ -244,17 +169,15 @@ 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];
- ui.tx_spin->setValue(t_MH[0]);
- ui.ty_spin->setValue(t_MH[1]);
- ui.tz_spin->setValue(t_MH[2]);
+ s.t_MH_x = t_MH[0];
+ s.t_MH_y = t_MH[1];
+ s.t_MH_z = t_MH[2];
}
}
void TrackerDialog::settings_changed()
{
- settings_dirty = true;
- if (tracker) tracker->apply(settings);
+ if (tracker) tracker->apply(s);
}
void TrackerDialog::doCenter()
@@ -267,25 +190,52 @@ void TrackerDialog::doReset()
if (tracker) tracker->reset();
}
+void TrackerDialog::save()
+{
+ do_apply_without_saving();
+ s.b->save();
+}
+
void TrackerDialog::doOK()
{
- settings.save_ini();
- dialog_settings.save_ini();
+ save();
close();
}
+void TrackerDialog::do_apply_without_saving()
+{
+ switch (s.active_model_panel) {
+ default:
+ case 0:
+ set_model_clip();
+ break;
+ case 1:
+ set_model_cap();
+ break;
+ case 2:
+ set_model_custom();
+ break;
+ }
+ if (tracker) tracker->apply(s);
+}
+
+void TrackerDialog::doApply()
+{
+ save();
+}
+
void TrackerDialog::doCancel()
{
- if (settings_dirty) {
+ if (s.b->modifiedp()) {
int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?",
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
switch (ret) {
case QMessageBox::Save:
- settings.save_ini();
- dialog_settings.save_ini();
+ save();
close();
break;
case QMessageBox::Discard:
+ s.b->revert();
close();
break;
case QMessageBox::Cancel:
@@ -319,8 +269,6 @@ void TrackerDialog::create_video_widget()
video_widget_dialog->setAttribute( Qt::WA_DeleteOnClose );
connect( video_widget_dialog, SIGNAL(destroyed(QObject*)), this, SLOT(widget_destroyed(QObject*)) );
video_widget_dialog->show();
-
- ui.videowidget_button->setEnabled(false);
}
void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/)
@@ -329,7 +277,6 @@ void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/)
if (do_delete) delete video_widget_dialog;
video_widget_dialog = NULL;
}
- if (tracker) ui.videowidget_button->setEnabled(true);
}
void TrackerDialog::poll_tracker_info()
@@ -369,24 +316,12 @@ void TrackerDialog::poll_tracker_info()
}
}
-
-//-----------------------------------------------------------------------------
-// ITrackerDialog interface
-void TrackerDialog::Initialize(QWidget *parent)
-{
- QPoint offsetpos(200, 200);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
void TrackerDialog::registerTracker(ITracker *t)
{
qDebug()<<"TrackerDialog:: Tracker registered";
tracker = static_cast<Tracker*>(t);
- if (isVisible() && settings_dirty) tracker->apply(settings);
- ui.videowidget_button->setEnabled(true);
+ if (isVisible() & s.b->modifiedp())
+ tracker->apply(s);
ui.tcalib_button->setEnabled(true);
//ui.center_button->setEnabled(true);
ui.reset_button->setEnabled(true);
@@ -397,19 +332,12 @@ void TrackerDialog::unRegisterTracker()
qDebug()<<"TrackerDialog:: Tracker un-registered";
tracker = NULL;
destroy_video_widget();
- ui.videowidget_button->setEnabled(false);
ui.tcalib_button->setEnabled(false);
//ui.center_button->setEnabled(false);
ui.reset_button->setEnabled(false);
}
-//-----------------------------------------------------------------------------
-#ifdef OPENTRACK_API
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
-#else
-#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( )
-#endif
{
return new TrackerDialog;
}
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
index de743ad8..0325160d 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
@@ -28,71 +28,24 @@ class TrackerDialog : public QWidget, Ui::UICPTClientControls, public ITrackerDi
Q_OBJECT
public:
TrackerDialog();
- ~TrackerDialog();
-
- // ITrackerDialog interface
- void Initialize(QWidget *parent);
void registerTracker(ITracker *tracker);
void unRegisterTracker();
-
+ void save();
void trans_calib_step();
-protected slots:
- // ugly qt stuff
- void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); }
- void set_dyn_pose_res(bool val) { settings.dyn_pose_res = val; settings_changed(); }
- void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); }
- void set_reset_time(int val) { settings.reset_time = val; settings_changed(); }
- void set_cam_index(int idx) { settings.cam_index = idx; 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_cam_roll(int idx);
- void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); }
- void set_cam_yaw(int val) { settings.cam_yaw = 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(); }
- void set_threshold_secondary(int val) { settings.threshold_secondary = val; settings_changed(); }
- void set_ena_roll(bool val) { settings.bEnableRoll = val; settings_changed(); }
- void set_ena_pitch(bool val) { settings.bEnablePitch = val; settings_changed(); }
- void set_ena_yaw(bool val) { settings.bEnableYaw = val; settings_changed(); }
- void set_ena_x(bool val) { settings.bEnableX = val; settings_changed(); }
- void set_ena_y(bool val) { settings.bEnableY = val; settings_changed(); }
- void set_ena_z(bool val) { settings.bEnableZ = val; settings_changed(); }
-
- void set_clip_t_height(int val) { dialog_settings.clip_ty = val; set_model_clip(); }
- void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_model_clip(); }
- void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_model_clip(); }
- void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_model_clip(); }
- void set_cap_width(int val) { dialog_settings.cap_x = val; set_model_cap(); }
- void set_cap_height(int val) { dialog_settings.cap_y = val; set_model_cap(); }
- void set_cap_length(int val) { dialog_settings.cap_z = val; set_model_cap(); }
- void set_m1x(int val) { dialog_settings.M01x = val; set_model_custom(); }
- void set_m1y(int val) { dialog_settings.M01y = val; set_model_custom(); }
- void set_m1z(int val) { dialog_settings.M01z = val; set_model_custom(); }
- void set_m2x(int val) { dialog_settings.M02x = val; set_model_custom(); }
- void set_m2y(int val) { dialog_settings.M02y = val; set_model_custom(); }
- void set_m2z(int val) { dialog_settings.M02z = val; set_model_custom(); }
- 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 set_model(int model_id);
-
- void doCenter();
- void doReset();
-
+public slots:
+ void doCenter();
+ void doReset();
void doOK();
+ void doApply();
void doCancel();
+ void do_apply_without_saving();
void startstop_trans_calib(bool start);
-
void widget_destroyed(QObject* obj);
-
void create_video_widget();
-
void poll_tracker_info();
+ void set_model(int idx);
protected:
void destroy_video_widget(bool do_delete = true);
@@ -103,15 +56,11 @@ protected:
void settings_changed();
- TrackerSettings settings;
- TrackerDialogSettings dialog_settings;
- bool settings_dirty;
-
+ settings s;
Tracker* tracker;
+ VideoWidgetDialog* video_widget_dialog;
QTimer timer;
- VideoWidgetDialog* video_widget_dialog;
-
TranslationCalibrator trans_calib;
bool trans_calib_running;
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
deleted file mode 100644
index 50835cb8..00000000
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Copyright (c) 2012 Patrick Ruoff
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
-
-#include "ftnoir_tracker_pt.h"
-#include <QCoreApplication>
-#include <QSettings>
-
-//-----------------------------------------------------------------------------
-void TrackerSettings::load_ini()
-{
- qDebug("TrackerSettings::load_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup( "PointTracker" );
-
- 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();
- cam_roll = iniFile.value("CameraRoll", 0).toInt();
- cam_pitch = iniFile.value("CameraPitch", 0).toInt();
- cam_yaw = iniFile.value("CameraYaw", 0).toInt();
- threshold = iniFile.value("PointExtractThreshold", 128).toInt();
- threshold_secondary = iniFile.value("PointExtractThresholdSecondary", 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();
- t_MH[0] = iniFile.value("tMHx", 0).toFloat();
- t_MH[1] = iniFile.value("tMHy", 0).toFloat();
- t_MH[2] = iniFile.value("tMHz", 0).toFloat();
- dyn_pose_res = iniFile.value("DynamicPoseResolution", true).toBool();
- video_widget = iniFile.value("VideoWidget", true).toBool();
- sleep_time = iniFile.value("SleepTime", 10).toInt();
- reset_time = iniFile.value("ResetTime", 1000).toInt();
-
- bEnableRoll = iniFile.value("EnableRoll", 1).toBool();
- bEnablePitch = iniFile.value("EnablePitch", 1).toBool();
- bEnableYaw = iniFile.value("EnableYaw", 1).toBool();
- bEnableX = iniFile.value("EnableX", 1).toBool();
- bEnableY = iniFile.value("EnableY", 1).toBool();
- bEnableZ = iniFile.value("EnableZ", 1).toBool();
-
- iniFile.endGroup();
-}
-
-void TrackerSettings::save_ini() const
-{
- qDebug("TrackerSettings::save_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "PointTracker" );
-
- 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("CameraRoll", cam_roll);
- iniFile.setValue("CameraPitch", cam_pitch);
- iniFile.setValue("CameraYaw", cam_yaw);
- iniFile.setValue("PointExtractThreshold", threshold);
- iniFile.setValue("PointExtractThresholdSecondary", threshold_secondary);
- iniFile.setValue("PointExtractMinSize", min_point_size);
- iniFile.setValue("PointExtractMaxSize", max_point_size);
- iniFile.setValue("PointModelM01x", M01[0]);
- iniFile.setValue("PointModelM01y", M01[1]);
- iniFile.setValue("PointModelM01z", M01[2]);
- iniFile.setValue("PointModelM02x", M02[0]);
- iniFile.setValue("PointModelM02y", M02[1]);
- iniFile.setValue("PointModelM02z", M02[2]);
- iniFile.setValue("tMHx", t_MH[0]);
- iniFile.setValue("tMHy", t_MH[1]);
- iniFile.setValue("tMHz", t_MH[2]);
- iniFile.setValue("DynamicPoseResolution", dyn_pose_res);
- iniFile.setValue("VideoWidget", video_widget);
- iniFile.setValue("SleepTime", sleep_time);
- iniFile.setValue("ResetTime", reset_time);
-
- iniFile.setValue( "EnableRoll", bEnableRoll );
- iniFile.setValue( "EnablePitch", bEnablePitch );
- iniFile.setValue( "EnableYaw", bEnableYaw );
- iniFile.setValue( "EnableX", bEnableX );
- iniFile.setValue( "EnableY", bEnableY );
- iniFile.setValue( "EnableZ", bEnableZ );
-
- iniFile.endGroup();
-}
-
-//-----------------------------------------------------------------------------
-void TrackerDialogSettings::load_ini()
-{
- qDebug("TrackerDialogSettings::load_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup( "PointTrackerDialog" );
-
- active_model_panel = iniFile.value("ActiveModelPanel", MODEL_CLIP).toInt();
- M01x = iniFile.value("CustomM01x", 0).toInt();
- M01y = iniFile.value("CustomM01y", 40).toInt();
- M01z = iniFile.value("CustomM01z", -30).toInt();
- M02x = iniFile.value("CustomM02x", 0).toInt();
- M02y = iniFile.value("CustomM02y", -70).toInt();
- M02z = iniFile.value("CustomM02z", -80).toInt();
- clip_ty = iniFile.value("ClipTopHeight", 40).toInt();
- clip_tz = iniFile.value("ClipTopLength", 30).toInt();
- clip_by = iniFile.value("ClipBottomHeight", 70).toInt();
- clip_bz = iniFile.value("ClipBottomLength", 80).toInt();
- cap_x = iniFile.value("CapHalfWidth", 40).toInt();
- cap_y = iniFile.value("CapHeight", 60).toInt();
- cap_z = iniFile.value("CapLength", 100).toInt();
-}
-
-void TrackerDialogSettings::save_ini() const
-{
- qDebug("TrackerDialogSettings::save_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "PointTrackerDialog" );
-
- iniFile.setValue("ActiveModelPanel", active_model_panel);
- iniFile.setValue("CustomM01x", M01x);
- iniFile.setValue("CustomM01y", M01y);
- iniFile.setValue("CustomM01z", M01z);
- iniFile.setValue("CustomM02x", M02x);
- iniFile.setValue("CustomM02y", M02y);
- iniFile.setValue("CustomM02z", M02z);
- iniFile.setValue("ClipTopHeight", clip_ty);
- iniFile.setValue("ClipTopLength", clip_tz);
- iniFile.setValue("ClipBottomHeight", clip_by);
- iniFile.setValue("ClipBottomLength", clip_bz);
- iniFile.setValue("CapHalfWidth", cap_x);
- iniFile.setValue("CapHeight", cap_y);
- iniFile.setValue("CapLength", cap_z);
-}
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
index 91a7a8d5..8c590db2 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
@@ -11,80 +11,81 @@
#include <opencv2/opencv.hpp>
#include "point_tracker.h"
+#include "facetracknoir/options.hpp"
+using namespace options;
-//-----------------------------------------------------------------------------
-// Tracker settings and their ini-IO
-struct TrackerSettings
-{
- // camera
- int cam_index;
- float cam_f;
- int cam_res_x;
- int cam_res_y;
- int cam_fps;
- int cam_roll;
- int cam_pitch;
- int cam_yaw;
-
- // point extraction
- int threshold;
- int threshold_secondary;
-
- int min_point_size;
- int max_point_size;
-
- // point tracking
- cv::Vec3f M01;
- cv::Vec3f M02;
- bool dyn_pose_res;
-
- // head to model translation
- cv::Vec3f t_MH;
-
- int sleep_time; // in ms
- int reset_time; // in ms
- bool video_widget;
+struct settings
+{
+ pbundle b;
+ value<int> cam_index,
+ cam_res_x,
+ cam_res_y,
+ cam_fps,
+ cam_roll,
+ cam_pitch,
+ cam_yaw,
+ threshold,
+ threshold_secondary,
+ min_point_size,
+ max_point_size;
+ value<double> cam_f;
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
+ value<int> m01_x, m01_y, m01_z;
+ value<int> m02_x, m02_y, m02_z;
+ value<bool> dyn_pose_res, video_widget;
- void load_ini();
- void save_ini() const;
-};
+ value<int> t_MH_x, t_MH_y, t_MH_z;
+ value<int> sleep_time, reset_time;
-//-----------------------------------------------------------------------------
-// Settings specific to the tracker dialog and their ini-IO
-struct TrackerDialogSettings
-{
- enum
- {
- MODEL_CLIP,
- MODEL_CAP,
- MODEL_CUSTOM
- };
- int active_model_panel;
+ value<bool> bEnableYaw, bEnablePitch, bEnableRoll;
+ value<bool> bEnableX, bEnableY, bEnableZ;
- int M01x;
- int M01y;
- int M01z;
- int M02x;
- int M02y;
- int M02z;
- int clip_ty;
- int clip_tz;
- int clip_by;
- int clip_bz;
- int cap_x;
- int cap_y;
- int cap_z;
+ value<int> clip_ty, clip_tz, clip_by, clip_bz;
+ value<int> active_model_panel, cap_x, cap_y, cap_z;
- void load_ini();
- void save_ini() const;
+ settings() :
+ b(bundle("tracker-pt")),
+ cam_index(b, "camera-index", 0),
+ cam_res_x(b, "camera-res-width", 640),
+ cam_res_y(b, "camera-res-height", 480),
+ cam_fps(b, "camera-fps", 30),
+ cam_roll(b, "camera-roll", 1),
+ cam_pitch(b, "camera-pitch", 0),
+ cam_yaw(b, "camera-yaw", 0),
+ threshold(b, "threshold-primary", 128),
+ threshold_secondary(b, "threshold-secondary", 128),
+ min_point_size(b, "min-point-size", 10),
+ max_point_size(b, "max-point-size", 50),
+ cam_f(b, "camera-focal-length", 1),
+ m01_x(b, "m_01-x", 0),
+ m01_y(b, "m_01-y", 0),
+ m01_z(b, "m_01-z", 0),
+ m02_x(b, "m_02-x", 0),
+ m02_y(b, "m_02-y", 0),
+ m02_z(b, "m_02-z", 0),
+ dyn_pose_res(b, "dynamic-pose-resolution", false),
+ video_widget(b, "video-widget", true),
+ t_MH_x(b, "model-centroid-x", 0),
+ t_MH_y(b, "model-centroid-y", 0),
+ t_MH_z(b, "model-centroid-z", 0),
+ sleep_time(b, "sleep-time", 0),
+ reset_time(b, "reset-time", 0),
+ bEnableYaw(b, "enable-yaw", true),
+ bEnablePitch(b, "enable-pitch", true),
+ bEnableRoll(b, "enable-roll", true),
+ bEnableX(b, "enable-x", true),
+ bEnableY(b, "enable-y", true),
+ bEnableZ(b, "enable-z", true),
+ clip_ty(b, "clip-ty", 0),
+ clip_tz(b, "clip-tz", 0),
+ clip_by(b, "clip-by", 0),
+ clip_bz(b, "clip-bz", 0),
+ active_model_panel(b, "active-model-panel", 0),
+ cap_x(b, "cap-x", 0),
+ cap_y(b, "cap-y", 0),
+ cap_z(b, "cap-z", 0)
+ {}
};
-#endif //FTNOIR_TRACKER_PT_SETTINGS_H \ No newline at end of file
+#endif //FTNOIR_TRACKER_PT_SETTINGS_H