From 33de6458080fa9dc9bf6a9d355e89f23f9ee1f02 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 22:37:07 +0200 Subject: PT tracker feature removal Some PT features got under the knife: - dynamic pose resolution velocity prediction model - tracker dialog's tracker tab - focal length coefficient --- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 2206 ++++++++++-------------- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 21 +- ftnoir_tracker_pt/ftnoir_tracker_pt.h | 4 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 28 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h | 6 +- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 10 +- ftnoir_tracker_pt/point_tracker.cpp | 179 +- ftnoir_tracker_pt/point_tracker.h | 26 +- 8 files changed, 998 insertions(+), 1482 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui index a2d5c47c..73b1f767 100644 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -9,7 +9,7 @@ 0 0 - 459 + 453 621 @@ -32,11 +32,83 @@ false - + QLayout::SetFixedSize - + + + + Status + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Extracted Points: + + + + + + + Camera Info: + + + + + + + QDialogButtonBox::Apply + + + true + + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + + + + + + + + 50 + 0 + + + + + + + + + + + @@ -56,73 +128,261 @@ 0 - + - General + Camera - + - + - Tracker Thread + Camera settings - + - + + + + 0 + 0 + + - Auto-reset time + Device - reset_spin + camdevice_combo - + + + + 0 + 0 + + + + 10 + + + + + + + + 0 + 0 + + + + Width + + + + + + + + 0 + 0 + + + + Desired capture width + + + px + + + 2000 + + + 10 + + + + + - + + 0 + 0 + + + + Height + + + + + + + + 0 + 0 + + + + Desired capture height + + + px + + + 2000 + + + 10 + + + + + + + + 0 + 0 + + + + FPS + + + fps_spin + + + + + + + 0 0 - Time until automatic reset of tracker's internal state when no valid tracking result is found + Desired capture framerate - ms + Hz - 9999 + 2000 + + + + + + + + + + Camera orientation + + + + + + Roll + + + camroll_combo + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Rotation of the camera image - + - Dynamic Pose Resolution + Pitch + + + campitch_spin - + + + Qt::DefaultContextMenu + - + The angle the camera is facing upwards + + deg + + + -180 + + + 180 + + + + + - + positive = upwards + + + + + + + Yaw + + + camyaw_spin - - - false + + + Qt::DefaultContextMenu - Reset the tracker's internal state + The angle the camera is facing leftwards + + deg + + + + + + -180 + + + 180 + + + + + - Reset + positve = left @@ -130,1071 +390,657 @@ - - - Qt::Vertical - - - - 20 - 20 - + + + Point extraction - + + + + + Minimum point diameter + + + px + + + 1024 + + + + + + + Intensity threshold for point extraction + + + 255 + + + 1 + + + 127 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 25 + + + + + + + Maximum point diameter + + + px + + + 1024 + + + + + + + Max size + + + maxdiam_spin + + + + + + + Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) + + + 255 + + + 1 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 25 + + + + + + + Threshold + + + threshold_slider + + + + + + + Hysteresis + + + threshold_secondary_slider + + + + + + + Min size + + + mindiam_spin + + + + + - + - Camera + Model - + - - - The camera device used as input + + + QTabWidget::Rounded - - Camera Settings + + 1 + + + false + + + false + + + false - - - - - - - - 55 - 0 - + + + Clip + + + + + + Model Dimensions + + + + + 70 + 35 + 100 + 22 + - - Device + + units - - camdevice_combo + + -65535 + + + 65535 - - - - - - 0 - 0 - + + + + 110 + 115 + 100 + 22 + - - Camera device used as input + + units + + + -65535 + + + 65535 - - - - - - - - - - - - 55 - 0 - + + + + 40 + 55 + 71 + 111 + + + + + + + :/Resources/clip_side.png + + + + + + 10 + 35 + 46 + 13 + + + + Side + + + + + + 50 + 165 + 100 + 22 + + + + units + + + -65535 + + + 65535 + + + + + + 110 + 75 + 100 + 22 + + + + units + + + -65535 + + + 65535 + + + + + + 255 + 40 + 46 + 13 + + + + Front + + + + + + 265 + 60 + 21 + 111 + + + + + + + :/Resources/clip_front.png + + + + + + + + + Cap + + + + + + Model Dimensions + + + + + 30 + 90 + 111 + 81 + + + + + + + :/Resources/cap_side.png + + + + + + 20 + 35 + 46 + 13 + + + + Side + + + + + + 20 + 70 + 101 + 22 + + + + units + + + -65535 + + + 65535 + + + + + + 140 + 90 + 16 + 16 + + + + R + + + + + + 290 + 85 + 16 + 16 + + + + R + + + + + + 270 + 85 + 81 + 81 + + + + + + + :/Resources/cap_front.png + + + + + + 255 + 55 + 100 + 22 + + + + units + + + -65535 + + + 65535 + + + + + + 290 + 35 + 46 + 13 + + + + Front + + + + + + 60 + 120 + 116 + 22 + + + + units + + + -65535 + + + 65535 + + + + + + + + + Custom + + + + + + Model Dimensions + + + + + + + 0 + 0 + - Resolution + z: - - - - FPS + + + + units - - fps_spin + + -65535 + + + 65535 - - + + - + 0 0 - - Desired capture framerate - - - 999 - - - - - - x + x: - - - - - 0 - 0 - + + + + units - - Desired capture width + + -65535 - 2000 - - - 10 + 65535 - - - - Desired capture height - - - 2000 - - - 10 + + + + units - - - - - - F/W + + -65535 - - f_dspin + + 65535 - - - - The camera's focal length devided by its sensor width + + + + units - - 2 + + -65535 - - 0.100000000000000 + + 65535 - - - - Qt::Horizontal - - - - 40 - 20 - + + + + units - - - - - - Qt::Horizontal + + -65535 - - - 0 - 20 - + + 65535 - + - - - - - - - - - - - - - - Camera Orientation - - - - - - - - + + - Pitch - - - campitch_spin + <html><head/><body><p>Location of the two remaining model points<br/>with respect to the reference point in default pose</p><p>Use any units you want, e.g. millimeters, inches, parsecs...</p></body></html> - - - - Qt::DefaultContextMenu - - - The angle the camera is facing upwards + + + + units - -99 - - - - - - - Yaw + -65535 - - camyaw_spin + + 65535 - - - - Qt::DefaultContextMenu - - - The angle the camera is facing leftwards - - - -99 + + + + + 0 + 0 + - - - - - deg (positve = leftwards) + y: - - + + - + 0 0 - - - 0 - 0 - - - - Rotation of the camera image - - - - - - deg (positive = upwards) + x: - - - - deg + + + + + 0 + 0 + - - - - - Roll - - - camroll_combo + <html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">3</span></p></body></html> - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - Point Extraction - - - - - - - - Threshold - - - threshold_slider - - - - - - - Intensity threshold for point extraction - - - 255 - - - 127 - - - Qt::Horizontal - - - - - - - - - - - Hysteresis - - - threshold_secondary_slider - - - - - - - Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) - - - 255 - - - 1 - - - 100 - - - Qt::Horizontal - - - - - - - - - - - Min Diameter - - - mindiam_spin - - - - - - - Minimum point diameter - - - - - - - px - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Max Diameter - - - maxdiam_spin - - - - - - - Maximum point diameter - - - - - - - px - - - - - - - - - - - - - Model - - - - - - QTabWidget::Rounded - - - 2 - - - false - - - false - - - false - - - - Clip - - - - - - Model Dimensions (mm) - - - - + + - + 0 0 - - - 150 - 160 - + + <html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">3</span></p></body></html> - - - - 30 - 30 - 71 - 111 - - - - - - - :/Resources/clip_side.png - - - - - - 100 - 50 - 46 - 22 - - - - 999 - - - - - - 60 - 10 - 46 - 22 - - - - 999 - - - - - - 100 - 90 - 46 - 22 - - - - 999 - - - - - - 10 - 10 - 46 - 13 - - - - Side - - - - - - 40 - 140 - 46 - 22 - - - - 999 - - - - - - 70 - 70 - 16 - 16 - - - - R - - - - + + - + 0 0 - - - 100 - 140 - - - - - - 10 - 10 - 46 - 13 - - - - Front - - - - - - 40 - 30 - 21 - 111 - - - - - - - :/Resources/clip_front.png - - - - - - 60 - 70 - 16 - 16 - - - - R - - - - - - - - - - - - Cap - - - - - - Model Dimensions (mm) - - - - - - - 140 - 130 - + + z: - - - - 20 - 50 - 111 - 81 - - - - - - - :/Resources/cap_side.png - - - - - - 30 - 80 - 46 - 22 - - - - 999 - - - - - - 130 - 50 - 16 - 16 - - - - R - - - - - - 10 - 10 - 46 - 13 - - - - Side - - - - - - 50 - 40 - 46 - 22 - - - - 999 - - - - + + - + 0 0 - - - 100 - 130 - - - - - - 10 - 10 - 46 - 13 - - - - Front - - - - - - 30 - 50 - 16 - 16 - - - - R - - - - - - 10 - 50 - 81 - 81 - - - - - - - :/Resources/cap_front.png - - - - - - 50 - 30 - 46 - 22 - - - - 999 - - - - - - - - - - - - Custom - - - - - - Model Dimensions (mm) - - - - - <html><head/><body><p>Location of the two remaining model points<br/>with respect to the reference point in default pose</p></body></html> + y: - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - - -999 - - - 999 - - - - - - - y: - - - - - - - -999 - - - 999 - - - - - - - z: - - - - - - - M1: - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - z: - - - - - - - -999 - - - 999 - - - - - - - y: - - - - - - - M2: - - - - - - - - - - -999 - - - 999 - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - @@ -1205,129 +1051,88 @@ - Model Position (mm) + Model position - - + + + + + units + + + -65535 + + + 65536 + + + + <html><head/><body><p>Translation from head center to model reference point<br/> in default pose</p></body></html> - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - y: - - - - - - - z: - - - - - - - -999 - - - 999 - - - - - - - -999 - - - 999 - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - false - - - Calibrate - - - true - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - + + + + units + + + -65535 + + + 65536 + + + + + + + y: + + + + + + + z: + + + + + + + x: + + + + + + + units + + + -65535 + + + 65536 + + + + + + + false + + + Calibrate + + + true + + @@ -1338,171 +1143,48 @@ About - - - - 30 - 30 - 161 - 111 - - - - <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> - - - true - - - - - - 200 - 30 - 141 - 141 - - - - - - - :/Resources/Logo_IR.png - - + + + + + <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + :/Resources/Logo_IR.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + - - - - Status - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Camera Info: - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - - - - - - - Extracted Points: - - - - - - - - 50 - 0 - - - - - - - - - - - - - - - - - - Save - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Ok - - - - - - - - - - Cancel - - - - - tabWidget - reset_spin camdevice_combo res_x_spin - res_y_spin - fps_spin - f_dspin camroll_combo campitch_spin camyaw_spin threshold_slider - mindiam_spin - maxdiam_spin model_tabs - clip_tlength_spin - clip_theight_spin - clip_bheight_spin - clip_blength_spin - cap_length_spin - cap_height_spin - cap_width_spin m1x_spin m1y_spin m1z_spin @@ -1512,31 +1194,11 @@ tx_spin ty_spin tz_spin - tcalib_button - ok_button - cancel_button - - - dynpose_check - toggled(bool) - reset_spin - setEnabled(bool) - - - 172 - 110 - - - 351 - 112 - - - - + startEngineClicked() stopEngineClicked() diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 3fa6910d..768a3a71 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -26,7 +26,6 @@ Tracker::Tracker() commands(0), video_widget(NULL), video_frame(NULL), - tracking_valid(false), new_settings(nullptr) { @@ -68,16 +67,13 @@ void Tracker::run() #endif time.start(); - double dt; bool new_frame; forever { if (commands & ABORT) break; - if (commands & PAUSE) continue; commands = 0; - apply_inner(); - dt = time.start() / 1000000000.; - + apply_inner(); + const double dt = time.start() * 1e-9; new_frame = camera.get_frame(dt, &frame); if (new_frame && !frame.empty()) @@ -101,7 +97,7 @@ void Tracker::run() color, 4); } - tracking_valid = point_tracker.track(points, camera.get_info().f, dt); + point_tracker.track(points, camera.get_info().f); video_widget->update_image(frame); } #ifdef PT_PERF_LOG @@ -124,12 +120,13 @@ void Tracker::apply_inner() settings* tmp = new_settings.exchange(nullptr); if (tmp == nullptr) return; + reset(); auto& s = *tmp; qDebug()<<"Tracker:: Applying settings"; 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); + camera.set_f(1); frame_rotation.rotation = static_cast(static_cast(s.cam_roll)); point_extractor.threshold_val = s.threshold; point_extractor.threshold_secondary_val = s.threshold_secondary; @@ -140,8 +137,6 @@ void Tracker::apply_inner() cv::Vec3f M02(s.m02_x, s.m02_y, s.m02_z); point_tracker.point_model = std::shared_ptr(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, @@ -152,7 +147,6 @@ void Tracker::apply_inner() FrameTrafo X_MH(Matx33f::eye(), t_MH); X_GH_0 = R_GC * X_MH; - qDebug()<<"Tracker::apply ends"; } @@ -201,7 +195,6 @@ void Tracker::StartTracker(QFrame *parent_window) camera.start(); apply(s); start(); - reset_command(PAUSE); } #ifndef OPENTRACK_API @@ -220,9 +213,7 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) { QMutexLocker lock(&mutex); - if (!tracking_valid) return; - - FrameTrafo X_CM = point_tracker.get_pose(); + FrameTrafo X_CM = point_tracker.get_pose(); FrameTrafo X_MH(Matx33f::eye(), t_MH); FrameTrafo X_GH = R_GC * X_CM * X_MH; Matx33f R = X_GH.R * X_GH_0.R.t(); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h index 3d9a83fd..238dcd8f 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h @@ -61,8 +61,7 @@ protected: QMutex mutex; // thread commands enum Command { - ABORT = 1<<0, - PAUSE = 1<<1 + ABORT = 1<<0 }; void set_command(Command command); void reset_command(Command command); @@ -82,7 +81,6 @@ protected: PTVideoWidget* video_widget; QFrame* video_frame; - bool tracking_valid; settings s; std::atomic new_settings; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index e037a099..0e58a2e4 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -42,11 +42,7 @@ TrackerDialog::TrackerDialog() ui.camroll_combo->addItem("0"); ui.camroll_combo->addItem("90"); - tie_setting(s.dyn_pose_res, ui.dynpose_check); - 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); @@ -82,11 +78,9 @@ TrackerDialog::TrackerDialog() 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())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); ui.model_tabs->setCurrentIndex(s.active_model_panel); @@ -94,7 +88,7 @@ TrackerDialog::TrackerDialog() connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); timer.start(100); - connect(s.b.get(), SIGNAL(bundleChanged()), this, SLOT(do_apply_without_saving())); + connect(ui.buttonBox_2, SIGNAL(clicked(QAbstractButton*)), this, SLOT(do_apply_without_saving(QAbstractButton*))); } void TrackerDialog::set_model_clip() @@ -172,19 +166,9 @@ void TrackerDialog::settings_changed() if (tracker) tracker->apply(s); } -void TrackerDialog::doCenter() -{ - if (tracker) tracker->center(); -} - -void TrackerDialog::doReset() -{ - if (tracker) tracker->reset(); -} - void TrackerDialog::save() { - do_apply_without_saving(); + do_apply_without_saving(nullptr); s.b->save(); } @@ -194,7 +178,7 @@ void TrackerDialog::doOK() close(); } -void TrackerDialog::do_apply_without_saving() +void TrackerDialog::do_apply_without_saving(QAbstractButton*) { switch (s.active_model_panel) { default: @@ -295,7 +279,6 @@ void TrackerDialog::registerTracker(ITracker *t) tracker->apply(s); ui.tcalib_button->setEnabled(true); //ui.center_button->setEnabled(true); - ui.reset_button->setEnabled(true); } void TrackerDialog::unRegisterTracker() @@ -305,7 +288,6 @@ void TrackerDialog::unRegisterTracker() destroy_video_widget(); ui.tcalib_button->setEnabled(false); //ui.center_button->setEnabled(false); - ui.reset_button->setEnabled(false); } extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h index a4d9c4b5..dbb93f30 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h @@ -34,12 +34,10 @@ public: void trans_calib_step(); public slots: - void doCenter(); - void doReset(); void doOK(); - void doApply(); void doCancel(); - void do_apply_without_saving(); + void doApply(); + void do_apply_without_saving(QAbstractButton *); void startstop_trans_calib(bool start); void widget_destroyed(QObject* obj); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index e4cb9ad3..7faad9ed 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -28,18 +28,17 @@ struct settings threshold_secondary, min_point_size, max_point_size; - value cam_f; value m01_x, m01_y, m01_z; value m02_x, m02_y, m02_z; - value dyn_pose_res, video_widget; + value video_widget; value t_MH_x, t_MH_y, t_MH_z; - value reset_time; - value clip_ty, clip_tz, clip_by, clip_bz; value active_model_panel, cap_x, cap_y, cap_z; + + // XXX todo red channel only, good for crapola CCD sensors -sh 20140922 settings() : b(bundle("tracker-pt")), @@ -54,19 +53,16 @@ struct settings 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), - reset_time(b, "reset-time", 2000), clip_ty(b, "clip-ty", 0), clip_tz(b, "clip-tz", 0), clip_by(b, "clip-by", 0), diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index e9892d67..5f57baf5 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -37,7 +37,7 @@ static void set_row(Matx33f& m, int i, const Vec3f& v) PointModel::PointModel(Vec3f M01, Vec3f M02) : M01(M01), M02(M02) -{ +{ // calculate u u = M01.cross(M02); u /= norm(u); @@ -48,7 +48,6 @@ PointModel::PointModel(Vec3f M01, Vec3f M02) float s22 = M02.dot(M02); P = 1.0/(s11*s22-s12*s12) * Matx22f(s22, -s12, -s12, s11); - // calculate d and d_order for simple freetrack-like point correspondence vector points; points.push_back(Vec2f(0,0)); @@ -97,151 +96,58 @@ void PointModel::get_d_order(const std::vector& points, int d_order[] // ---------------------------------------------------------------------------- -PointTracker::PointTracker() : - dynamic_pose_resolution(true), - dt_reset(1), - init_phase(true), - dt_valid(0), - v_t(0,0,0), - v_r(0,0,0) +PointTracker::PointTracker() { X_CM.t[2] = 1000; // default position: 1 m away from cam; } void PointTracker::reset() { - // enter init phase and reset velocities - init_phase = true; - dt_valid = 0; - reset_velocities(); -} - -void PointTracker::reset_velocities() -{ - v_t = Vec3f(0,0,0); - v_r = Vec3f(0,0,0); + // enter init phase + X_CM = FrameTrafo(); } - -bool PointTracker::track(const vector& points, float f, float dt) +void PointTracker::track(const vector& points, float f) { - if (!dynamic_pose_resolution) init_phase = true; - - dt_valid += dt; - // if there was no valid tracking result for too long, do a reset - if (dt_valid > dt_reset) - { - //qDebug()<<"dt_valid "< dt_reset "<& points, float f) +void PointTracker::find_correspondences(const std::vector& points, float f) { - if (init_phase) { - // We do a simple freetrack-like sorting in the init phase... - // sort points - int point_d_order[PointModel::N_POINTS]; - point_model->get_d_order(points, point_d_order); - - // set correspondences - for (int i=0; id_order[i]] = points[point_d_order[i]]; - } - } - else { - // ... otherwise we look at the distance to the projection of the expected model points - // project model points under current pose - p_exp[0] = project(Vec3f(0,0,0), f); - p_exp[1] = project(point_model->M01, f); - p_exp[2] = project(point_model->M02, f); - - // set correspondences by minimum distance to projected model point - bool point_taken[PointModel::N_POINTS]; - for (int i=0; iM01, f); + p_exp[2] = project(point_model->M02, f); + + // set correspondences by minimum distance to projected model point + bool point_taken[PointModel::N_POINTS]; + for (int i=0; i& points, float f, float dt); + void track(const std::vector& points, float f); std::shared_ptr point_model; - bool dynamic_pose_resolution; - float dt_reset; - FrameTrafo get_pose() const { return X_CM; } void reset(); @@ -106,24 +103,13 @@ protected: return cv::Vec2f(f*v_C[0]/v_C[2], f*v_C[1]/v_C[2]); } - bool find_correspondences(const std::vector& points, float f); + void find_correspondences(const std::vector& points, float f); cv::Vec2f p[PointModel::N_POINTS]; // the points in model order - cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions - - void predict(float dt); - void update_velocities(float dt); - void reset_velocities(); - int POSIT(float f); // The POSIT algorithm, returns the number of iterations - bool init_phase; - float dt_valid; // time since last valid tracking result - cv::Vec3f v_t; // velocities - cv::Vec3f v_r; FrameTrafo X_CM; // trafo from model to camera - FrameTrafo X_CM_old; }; #endif //POINTTRACKER_H -- cgit v1.2.3