From 2836141124cf065387bbc7e59ddcfa238ea0a26f Mon Sep 17 00:00:00 2001 From: Patrick Ruoff Date: Sat, 29 Sep 2012 13:18:52 +0000 Subject: 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 --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 261 +++++++++++++++++------ FTNoIR_Tracker_PT/camera.cpp | 28 ++- FTNoIR_Tracker_PT/camera.h | 3 + FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 62 ++---- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 23 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 64 +++--- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 31 ++- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp | 4 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h | 13 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 28 ++- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 10 +- FTNoIR_Tracker_PT/point_extractor.cpp | 8 +- FTNoIR_Tracker_PT/point_tracker.cpp | 4 +- 13 files changed, 364 insertions(+), 175 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 77e3ada7..6ba6a1db 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -10,7 +10,7 @@ 0 0 395 - 450 + 511 @@ -51,7 +51,7 @@ - 2 + 0 @@ -67,11 +67,15 @@ - - - Show VideoWidget - - + + + + + Show VideoWidget + + + + @@ -87,28 +91,70 @@ - - - Sleep time - - - sleep_spin - - - - - - - 999 - - - - - - - ms + + + QFormLayout::AllNonFixedFieldsGrow - + + + + Sleep time + + + sleep_spin + + + + + + + + + + + + 9999 + + + + + + + ms + + + + + + + + + Auto-reset time + + + reset_spin + + + + + + + + + 9999 + + + + + + + s + + + + + + @@ -168,6 +214,70 @@ + + + + + + Resolution + + + + + + + 2000 + + + 10 + + + + + + + x + + + + + + + 2000 + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + FPS + + + fps_spin + + + + + + + + @@ -285,18 +395,27 @@ - - + + QFormLayout::AllNonFixedFieldsGrow + + + - Extracted Points: + Camera Info: - - + + + + + 0 + 0 + + - 50 + 120 0 @@ -305,24 +424,18 @@ - - + + - Camera Info: + Extracted Points: - - - - - 0 - 0 - - + + - 120 + 50 0 @@ -335,10 +448,32 @@ - caminfo_label - formLayoutWidget + + + + + + false + + + Reset + + + + + + + false + + + Center + + + + + @@ -663,10 +798,16 @@ - + + + false + Calibrate + + true + @@ -719,11 +860,6 @@ - groupBox_3 - groupBox_4 - label_32 - horizontalLayoutWidget_3 - label_33 @@ -739,7 +875,7 @@ - <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 0.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> + <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 0.2</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 @@ -766,13 +902,6 @@ - - - - Center - - - @@ -810,11 +939,17 @@ cancel_button videowidget_check sleep_spin + reset_spin camindex_spin f_dspin + res_x_spin + res_y_spin + fps_spin threshold_slider mindiam_spin maxdiam_spin + reset_button + center_button m1x_spin m1y_spin m1z_spin @@ -824,7 +959,7 @@ tx_spin ty_spin tz_spin - pushButton + tcalib_button 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& 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 "<(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 > 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: "<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(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 //----------------------------------------------------------------------------- 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 //----------------------------------------------------------------------------- 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& PointExtractor::extract_points(Mat frame, float dt, bool dr // find connected components... // Method 1: contours - /* + //* // find contours vector< vector > contours; findContours(frame_bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); @@ -64,10 +64,10 @@ const vector& 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& 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: "<