From c681889ab4c37bfd0f049177459b7fda380fda51 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Wed, 2 Jan 2013 18:54:06 +0000 Subject: Added 'enable axis' parameters to the Trackers. Added 'none' to filter-listbox. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@203 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h | 1 + FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 186 ++++++++- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj | 12 +- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc9.vcproj | 2 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 38 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 7 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 20 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 7 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 16 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 7 + FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui | 434 ++++++++------------- FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h | 8 +- FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp | 25 +- .../ftnoir_tracker_faceapi_dialog.cpp | 20 - FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui | 184 ++++++++- FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h | 7 + FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp | 45 ++- FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp | 31 +- FaceTrackNoIR/FaceTrackNoIR.cpp | 128 +++--- FaceTrackNoIR/FaceTrackNoIR.h | 2 - FaceTrackNoIR/FaceTrackNoIR.ui | 48 +-- FaceTrackNoIR/tracker.cpp | 57 ++- FaceTrackNoIR/tracker.h | 6 - 23 files changed, 785 insertions(+), 506 deletions(-) diff --git a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h index 5b476758..02e95bb4 100644 --- a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h +++ b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h @@ -41,6 +41,7 @@ public: void StartTracker( HWND parent_window ); void StopTracker( bool exit ); bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good + void loadSettings(); // bool setParameterValue(const int index, const float newvalue); bool notifyZeroed(); diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 9c70b397..20e16985 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -9,8 +9,8 @@ 0 0 - 401 - 497 + 393 + 585 @@ -432,6 +432,188 @@ + + + + + 0 + 85 + + + + Enable Axis + + + + + 10 + 20 + 143 + 60 + + + + + + + Roll: + + + + + + + Pitch: + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + X: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Y: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj index 7d698af7..5b70b459 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj +++ b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj @@ -1,7 +1,7 @@ @@ -268,7 +268,7 @@ @@ -314,7 +314,7 @@ @@ -545,7 +545,7 @@ /> x = t[0] / 10.0; // convert to cm - data->y = t[1] / 10.0; - data->z = t[2] / 10.0; + // get translation(s) + if (bEnableX) { + data->x = t[0] / 10.0; // convert to cm + } - // translate rotatation matrix from opengl (G) to roll-pitch-yaw (R) frame + if (bEnableY) { + data->y = t[1] / 10.0; + } + if (bEnableZ) { + data->z = t[2] / 10.0; + } + + // translate rotation matrix from opengl (G) to roll-pitch-yaw (R) frame // -z -> x, y -> z, x -> -y Matx33f R_RG( 0, 0,-1, -1, 0, 0, @@ -208,9 +224,15 @@ 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; // this is what ftnoir expects? - data->roll = rad2deg * gamma; + if (bEnableYaw) { + data->yaw = rad2deg * alpha; + } + if (bEnablePitch) { + data->pitch = -rad2deg * beta; // this is what ftnoir expects? + } + if (bEnableRoll) { + data->roll = rad2deg * gamma; + } } return true; } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index bfc262b3..c381b807 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -33,6 +33,7 @@ public: void StartTracker(HWND parent_window); void StopTracker(bool exit); bool GiveHeadPoseData(THeadPoseData *data); + void refreshVideo(); void apply(const TrackerSettings& settings); @@ -64,6 +65,12 @@ protected: cv::Vec3f t_MH; bool draw_frame; int sleep_time; + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; long frame_count; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index 357cd67f..f3daae0c 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -32,6 +32,14 @@ TrackerDialog::TrackerDialog() ui.res_y_spin->setValue(settings.cam_res_y); ui.fps_spin->setValue(settings.cam_fps); ui.threshold_slider->setValue(settings.threshold); + + 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); @@ -62,6 +70,14 @@ TrackerDialog::TrackerDialog() 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.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)) ); @@ -282,7 +298,7 @@ void TrackerDialog::Initialize(QWidget *parent) void TrackerDialog::registerTracker(ITracker *t) { - qDebug()<<"TrackerDialog:: Tracker registerd"; + qDebug()<<"TrackerDialog:: Tracker registered"; tracker = static_cast(t); if (isVisible() && settings_dirty) tracker->apply(settings); ui.tcalib_button->setEnabled(true); @@ -292,7 +308,7 @@ void TrackerDialog::registerTracker(ITracker *t) void TrackerDialog::unRegisterTracker() { - qDebug()<<"TrackerDialog:: Tracker un-registerd"; + qDebug()<<"TrackerDialog:: Tracker un-registered"; tracker = NULL; ui.tcalib_button->setEnabled(false); ui.center_button->setEnabled(false); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h index 68baf87a..19404444 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -44,6 +44,13 @@ protected slots: 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_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_clip(); } void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_clip(); } void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_clip(); } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp index 036b0558..7c356694 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp @@ -40,7 +40,14 @@ void TrackerSettings::load_ini() 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(); } @@ -75,6 +82,13 @@ void TrackerSettings::save_ini() const 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(); } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index 23496d91..16ee20f3 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -31,6 +31,13 @@ struct TrackerSettings cv::Vec3f M01; cv::Vec3f M02; + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + // head to model translation cv::Vec3f t_MH; diff --git a/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui b/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui index 9fa1b2e4..93befd19 100644 --- a/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui +++ b/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui @@ -6,8 +6,8 @@ 0 0 - 383 - 344 + 388 + 313 @@ -93,272 +93,170 @@ - - - - - Roll: - - - - - - - Pitch: - - - - - - - Yaw: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Enable Axis: - - - - - - - X: - - - - - - - Y: - - - - - - - Z: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Invert Axis: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - + + + + 0 + 140 + + + + Enable Axis + + + + + 10 + 20 + 55 + 110 + + + + + + + Roll: + + + + + + + Pitch: + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + X: + + + + + + + Y: + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h index ce8f5511..b7aed1d0 100644 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h +++ b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h @@ -44,6 +44,7 @@ public: void StartTracker( HWND parent_window ); void StopTracker( bool exit ); bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good + void loadSettings(); bool SMCreateMapping(); @@ -63,13 +64,6 @@ private: bool bEnableX; bool bEnableY; bool bEnableZ; - - double dInvertRoll; - double dInvertPitch; - double dInvertYaw; - double dInvertX; - double dInvertY; - double dInvertZ; }; // Widget that has controls for SMoIR protocol client-settings. diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp index f8320294..624e35a0 100644 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp +++ b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp @@ -44,13 +44,6 @@ FTNoIR_Tracker::~FTNoIR_Tracker() bEnableY = true; bEnableZ = true; - dInvertRoll = 1.0f; - dInvertPitch = 1.0f; - dInvertYaw = 1.0f; - dInvertX = 1.0f; - dInvertY = 1.0f; - dInvertZ = 1.0f; - CloseHandle( hSMMutex ); CloseHandle( hSMMemMap ); hSMMemMap = 0; @@ -132,22 +125,22 @@ bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) // Copy the measurements to FaceTrackNoIR. // if (bEnableX) { - data->x = dInvertX * pMemData->data.new_pose.head_pos.x * 100.0f; // From meters to centimeters + data->x = pMemData->data.new_pose.head_pos.x * 100.0f; // From meters to centimeters } if (bEnableY) { - data->y = dInvertY * pMemData->data.new_pose.head_pos.y * 100.0f; + data->y = pMemData->data.new_pose.head_pos.y * 100.0f; } if (bEnableZ) { - data->z = dInvertZ * pMemData->data.new_pose.head_pos.z * 100.0f; + data->z = pMemData->data.new_pose.head_pos.z * 100.0f; } if (bEnableYaw) { - data->yaw = dInvertYaw * pMemData->data.new_pose.head_rot.y_rads * 57.295781f; // From rads to degrees + data->yaw = pMemData->data.new_pose.head_rot.y_rads * 57.295781f; // From rads to degrees } if (bEnablePitch) { - data->pitch = dInvertPitch * pMemData->data.new_pose.head_rot.x_rads * 57.295781f; + data->pitch = pMemData->data.new_pose.head_rot.x_rads * 57.295781f; } if (bEnableRoll) { - data->roll = dInvertRoll * pMemData->data.new_pose.head_rot.z_rads * 57.295781f; + data->roll = pMemData->data.new_pose.head_rot.z_rads * 57.295781f; } // @@ -178,12 +171,6 @@ void FTNoIR_Tracker::loadSettings() { if (pMemData) { pMemData->initial_filter_level = iniFile.value ( "FilterLevel", 1 ).toInt(); } - dInvertRoll = (iniFile.value ( "InvertRoll", 0 ).toBool()) ? -1.0f : 1.0f; - dInvertPitch = (iniFile.value ( "InvertPitch", 0 ).toBool()) ? -1.0f : 1.0f; - dInvertYaw = (iniFile.value ( "InvertYaw", 0 ).toBool()) ? -1.0f : 1.0f; - dInvertX = (iniFile.value ( "InvertX", 0 ).toBool()) ? -1.0f : 1.0f; - dInvertY = (iniFile.value ( "InvertY", 0 ).toBool()) ? -1.0f : 1.0f; - dInvertZ = (iniFile.value ( "InvertZ", 0 ).toBool()) ? -1.0f : 1.0f; bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp index 7d16b3e3..e334f932 100644 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp +++ b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp @@ -65,13 +65,6 @@ QWidget() timUpdateSettings->start(100); connect(this, SIGNAL(stateChanged( int )), this, SLOT(showSettings( int ))); - connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); @@ -166,13 +159,6 @@ void TrackerControls::loadSettings() { iniFile.beginGroup ( "SMTracker" ); ui.cbxFilterSetting->setCurrentIndex(iniFile.value ( "FilterLevel", 1 ).toInt()); - ui.chkInvertRoll->setChecked(iniFile.value ( "InvertRoll", 0 ).toBool()); - ui.chkInvertPitch->setChecked(iniFile.value ( "InvertPitch", 0 ).toBool()); - ui.chkInvertYaw->setChecked(iniFile.value ( "InvertYaw", 0 ).toBool()); - ui.chkInvertX->setChecked(iniFile.value ( "InvertX", 0 ).toBool()); - ui.chkInvertY->setChecked(iniFile.value ( "InvertY", 0 ).toBool()); - ui.chkInvertZ->setChecked(iniFile.value ( "InvertZ", 0 ).toBool()); - ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); @@ -197,12 +183,6 @@ void TrackerControls::save() { iniFile.beginGroup ( "SMTracker" ); iniFile.setValue ( "FilterLevel", ui.cbxFilterSetting->currentIndex() ); - iniFile.setValue ( "InvertRoll", ui.chkInvertRoll->isChecked() ); - iniFile.setValue ( "InvertPitch", ui.chkInvertPitch->isChecked() ); - iniFile.setValue ( "InvertYaw", ui.chkInvertYaw->isChecked() ); - iniFile.setValue ( "InvertX", ui.chkInvertX->isChecked() ); - iniFile.setValue ( "InvertY", ui.chkInvertY->isChecked() ); - iniFile.setValue ( "InvertZ", ui.chkInvertZ->isChecked() ); iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); diff --git a/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui b/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui index 11e07cf3..7ac6c0f4 100644 --- a/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui +++ b/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui @@ -7,7 +7,7 @@ 0 0 411 - 129 + 210 @@ -58,6 +58,188 @@ + + + + + 0 + 85 + + + + Enable Axis + + + + + 10 + 20 + 143 + 60 + + + + + + + Roll: + + + + + + + Pitch: + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + X: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Y: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h index b1638e7b..94645c84 100644 --- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h +++ b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h @@ -38,6 +38,12 @@ private: THeadPoseData newHeadPose; // Structure with new headpose float portAddress; // Port-number + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -66,6 +72,7 @@ private slots: void doOK(); void doCancel(); void settingChanged() { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; }; //******************************************************************************************************* diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp index ecf0e5dd..102c85bd 100644 --- a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp +++ b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp @@ -33,15 +33,12 @@ FTNoIR_Tracker::FTNoIR_Tracker() m_StopThread = CreateEvent(0, TRUE, FALSE, 0); m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); - ////allocate memory for the parameters - //parameterValueAsFloat.clear(); - //parameterRange.clear(); - - //// Add the parameters to the list - //parameterRange.append(std::pair(1000.0f,9999.0f)); - //parameterValueAsFloat.append(0.0f); - //setParameterValue(kPortAddress,5551.0f); - + bEnableRoll = true; + bEnablePitch = true; + bEnableYaw = true; + bEnableX = true; + bEnableY = true; + bEnableZ = true; portAddress = 5551; newHeadPose.x = 0.0f; @@ -159,12 +156,24 @@ void FTNoIR_Tracker::StopTracker( bool exit ) bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) { - data->x = newHeadPose.x; - data->y = newHeadPose.y; - data->z = newHeadPose.z; - data->yaw = newHeadPose.yaw; - data->pitch = newHeadPose.pitch; - data->roll = newHeadPose.roll; + if (bEnableX) { + data->x = newHeadPose.x; + } + if (bEnableX) { + data->y = newHeadPose.y; + } + if (bEnableX) { + data->z = newHeadPose.z; + } + if (bEnableX) { + data->yaw = newHeadPose.yaw; + } + if (bEnableX) { + data->pitch = newHeadPose.pitch; + } + if (bEnableX) { + data->roll = newHeadPose.roll; + } return true; } @@ -182,6 +191,12 @@ void FTNoIR_Tracker::loadSettings() { qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; iniFile.beginGroup ( "FTNClient" ); + 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(); portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt(); iniFile.endGroup (); } diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp index c5bee64f..2857715a 100644 --- a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp +++ b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp @@ -39,12 +39,15 @@ QWidget() // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - //connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - //connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - //connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - //connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + // Load the settings from the current .INI-file loadSettings(); } @@ -129,10 +132,12 @@ void TrackerControls::loadSettings() { // qDebug() << "loadSettings says: iniFile = " << currentFile; iniFile.beginGroup ( "FTNClient" ); - //ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - //ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - //ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - //ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); + ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); + ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); + ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); + ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); + ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); + ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); iniFile.endGroup (); @@ -151,10 +156,12 @@ void TrackerControls::save() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FTNClient" ); - //iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - //iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - //iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - //iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); + iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); + iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); + iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); + iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); + iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); + iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); iniFile.endGroup (); diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 5494c918..41dee02f 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,8 @@ *********************************************************************************/ /* Modifications (last one on top): + 20130101 - WVR: Added "None" to filter-listbox to remove "use advanced filtering". + 20121209 - WVR: Pre-v170 DLLs will not be added to the Listbox. Initial selection was changed (made case-insensitive). 20121014 - WVR: Added second Tracker Source for Arduino solution. The two will be mutually exclusive. 20120929 - WVR: Disable button Filter-settings when StartTracker. 20120918 - WVR: When AutoStart is TRUE, the program is not directly minimized any more. @@ -137,10 +139,6 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - // button methods connect with methods in this class - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - // Connect checkboxes connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); @@ -149,7 +147,9 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); - connect(ui.chkUseEWMA, SIGNAL(stateChanged(int)), this, SLOT(setUseFilter(int))); + // button methods connect with methods in this class + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); // Connect slider for smoothing connect(ui.slideSmoothing, SIGNAL(valueChanged(int)), this, SLOT(setSmoothing(int))); @@ -260,11 +260,11 @@ QString FaceTrackNoIR::getCurrentProtocolName() QString FaceTrackNoIR::getCurrentFilterName() { qDebug() << "getCurrentFilterName says: " << ui.iconcomboFilter->currentIndex(); - if (ui.iconcomboFilter->currentIndex() < 0) { - return QString(""); + if (ui.iconcomboFilter->currentIndex() <= 0) { + return QString("None"); } else { - return filterFileList.at(ui.iconcomboFilter->currentIndex()); + return filterFileList.at(ui.iconcomboFilter->currentIndex() - 1 ); } } @@ -277,6 +277,7 @@ QString FaceTrackNoIR::getCurrentTrackerName() return QString(""); } else { + qDebug() << "FaceTrackNoIR::getCurrentTrackerName libName = " << trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); return trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); } } @@ -403,7 +404,6 @@ void FaceTrackNoIR::save() { iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() ); iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() ); iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() ); - iniFile.setValue ( "useEWMA", ui.chkUseEWMA->isChecked() ); iniFile.endGroup (); iniFile.beginGroup ( "GameProtocol" ); @@ -495,7 +495,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "FaceTrackNoIR (1.7 alpha 8) - " + pathInfo.fileName() ); + setWindowTitle ( "FaceTrackNoIR (1.7 alpha 10) - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. @@ -530,8 +530,6 @@ void FaceTrackNoIR::loadSettings() { ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool()); ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool()); ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); - ui.chkUseEWMA->setChecked (iniFile.value ( "useEWMA", 1 ).toBool()); - iniFile.endGroup (); // @@ -585,14 +583,15 @@ void FaceTrackNoIR::loadSettings() { } iniFile.endGroup (); - disconnect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); + // + // Find the Index of the DLL and set the selection. + // for ( int i = 0; i < protocolFileList.size(); i++) { - if (protocolFileList.at(i) == selectedProtocolName) { + if (protocolFileList.at(i).compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { ui.iconcomboProtocol->setCurrentIndex( i ); + break; } } - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - protocolSelected( ui.iconcomboProtocol->currentIndex() ); // // Read the currently selected Tracker from the INI-file. @@ -623,10 +622,10 @@ void FaceTrackNoIR::loadSettings() { disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); disconnect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); for ( int i = 0; i < trackerFileList.size(); i++) { - if (trackerFileList.at(i) == selectedTrackerName) { + if (trackerFileList.at(i).compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) { ui.iconcomboTrackerSource->setCurrentIndex( i ); } - if (trackerFileList.at(i) == secondTrackerName) { + if (trackerFileList.at(i).compare( secondTrackerName, Qt::CaseInsensitive ) == 0) { ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); // The first value = "None", so add 1 } } @@ -641,13 +640,15 @@ void FaceTrackNoIR::loadSettings() { qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; iniFile.endGroup (); - disconnect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + // + // Find the Index of the DLL and set the selection. + // for ( int i = 0; i < filterFileList.size(); i++) { - if (filterFileList.at(i) == selectedFilterName) { - ui.iconcomboFilter->setCurrentIndex( i ); + if (filterFileList.at(i).compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { + ui.iconcomboFilter->setCurrentIndex( i + 1 ); // The first value = "None", so add 1 + break; } } - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); settingsDirty = false; } @@ -704,8 +705,6 @@ void FaceTrackNoIR::startTracker( ) { // tracker->setup(); tracker->setSmoothing ( ui.slideSmoothing->value() ); - tracker->setUseFilter (ui.chkUseEWMA->isChecked() ); - tracker->setInvertYaw (ui.chkInvertYaw->isChecked() ); tracker->setInvertPitch (ui.chkInvertPitch->isChecked() ); tracker->setInvertRoll (ui.chkInvertRoll->isChecked() ); @@ -888,12 +887,6 @@ void FaceTrackNoIR::setInvertZ( int invert ) { settingsDirty = true; } -/** set Use Filter from the checkbox **/ -void FaceTrackNoIR::setUseFilter( int set ) { - Tracker::setUseFilter ( (set != 0)?true:false ); - settingsDirty = true; -} - /** Show the headpose in the widget (triggered by timer) **/ void FaceTrackNoIR::showHeadPose() { THeadPoseData newdata; @@ -1244,6 +1237,7 @@ importGetFilterDll getFilter; IFilterDllPtr pFilterDll; // Pointer to Filter info instance (in DLL) importGetTrackerDll getTracker; ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) +QStringList listDLLs; // List of specific DLLs QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) @@ -1258,19 +1252,18 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) filters.clear(); filters << "FTNoIR_Protocol_*.dll"; protocolFileList.clear(); - protocolFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + listDLLs.clear(); + listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); // // Add strings to the Listbox. // disconnect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); ui.iconcomboProtocol->clear(); - for ( int i = 0; i < protocolFileList.size(); i++) { - -// qDebug() << "createIconGroupBox says: ProtocolName = " << protocolFileList.at(i); + for ( int i = 0; i < listDLLs.size(); i++) { - // Show the appropriate Protocol-server Settings - QLibrary *protocolLib = new QLibrary(protocolFileList.at(i)); + // Try to load the DLL and get the Icon and Name + QLibrary *protocolLib = new QLibrary(listDLLs.at(i)); QString *protocolName = new QString(""); QIcon *protocolIcon = new QIcon(); @@ -1282,17 +1275,18 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) pProtocolDll = ptrXyz; pProtocolDll->getFullName( protocolName ); pProtocolDll->getIcon( protocolIcon ); -// qDebug() << "FaceTrackNoIR::showServerControls GetProtocolDialog Function Resolved!"; + + // + // Add the Icon and the Name to the Listbox and update the fileList + // + ui.iconcomboProtocol->addItem(*protocolIcon, *protocolName ); + protocolFileList.append(listDLLs.at(i)); } - else { - qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; - } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-DLL not loaded, please check if the DLL is version 1.7",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); } - ui.iconcomboProtocol->addItem(*protocolIcon, *protocolName ); } connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); @@ -1302,19 +1296,20 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) filters.clear(); filters << "FTNoIR_Filter_*.dll"; filterFileList.clear(); - filterFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + listDLLs.clear(); + listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); // // Add strings to the Listbox. // disconnect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); ui.iconcomboFilter->clear(); - for ( int i = 0; i < filterFileList.size(); i++) { + ui.iconcomboFilter->addItem("None"); -// qDebug() << "createIconGroupBox says: FilterName = " << filterFileList.at(i); + for ( int i = 0; i < listDLLs.size(); i++) { - // Show the appropriate Protocol-server Settings - QLibrary *filterLib = new QLibrary(filterFileList.at(i)); + // Try to load the DLL and get the Icon and Name + QLibrary *filterLib = new QLibrary(listDLLs.at(i)); QString *filterName = new QString(""); QIcon *filterIcon = new QIcon(); @@ -1326,17 +1321,18 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) pFilterDll = ptrXyz; pFilterDll->getFullName( filterName ); pFilterDll->getIcon( filterIcon ); -// qDebug() << "FaceTrackNoIR::showServerControls GetFilterDialog Function Resolved!"; + + // + // Add the Icon and the Name to the Listbox and update the fileList + // + ui.iconcomboFilter->addItem(*filterIcon, *filterName ); + filterFileList.append(listDLLs.at(i)); } - else { - qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; - } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded, please check if the DLL is version 1.7",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); } - ui.iconcomboFilter->addItem(*filterIcon, *filterName ); } connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); @@ -1346,7 +1342,8 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) filters.clear(); filters << "FTNoIR_Tracker_*.dll"; trackerFileList.clear(); - trackerFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + listDLLs.clear(); + listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); // // Add strings to the Listbox(es). @@ -1358,12 +1355,10 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) ui.cbxSecondTrackerSource->clear(); ui.cbxSecondTrackerSource->addItem("None"); - for ( int i = 0; i < trackerFileList.size(); i++) { - -// qDebug() << "createIconGroupBox says: TrackerName = " << trackerFileList.at(i); + for ( int i = 0; i < listDLLs.size(); i++) { - // Show the appropriate Protocol-server Settings - QLibrary *trackerLib = new QLibrary(trackerFileList.at(i)); + // Try to load the DLL and get the Icon and Name + QLibrary *trackerLib = new QLibrary(listDLLs.at(i)); QString *trackerName = new QString(""); QIcon *trackerIcon = new QIcon(); @@ -1375,18 +1370,19 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) pTrackerDll = ptrXyz; pTrackerDll->getFullName( trackerName ); pTrackerDll->getIcon( trackerIcon ); -// qDebug() << "FaceTrackNoIR::showServerControls GetTrackerDll Function Resolved!"; + + // + // Add the Icon and the Name to the Listbox and update the fileList + // + ui.iconcomboTrackerSource->addItem(*trackerIcon, *trackerName ); + ui.cbxSecondTrackerSource->addItem(*trackerIcon, *trackerName ); + trackerFileList.append(listDLLs.at(i)); } - else { - qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; - } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Facetracker-DLL not loaded, please check if the DLL is version 1.7",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Tracker-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); } - ui.iconcomboTrackerSource->addItem(*trackerIcon, *trackerName ); - ui.cbxSecondTrackerSource->addItem(*trackerIcon, *trackerName ); } connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index 52ea8418..756b5867 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -150,7 +150,6 @@ private: void showKeyboardShortcuts(); void showCurveConfiguration(); - // invert checkboxes void setInvertYaw( int invert ); void setInvertPitch( int invert ); void setInvertRoll( int invert ); @@ -158,7 +157,6 @@ private: void setInvertY( int invert ); void setInvertZ( int invert ); - void setUseFilter( int set ); void showHeadPose(); //smoothing slider diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index 2a478809..20c2ee53 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -1221,39 +1221,6 @@ color: rgb(0, 255, 0); - - - - 95 - 0 - - - - - 150 - 16777215 - - - - color:#ccc; -background:none; - - - Use advanced filtering: - - - - - - - background:none; - - - - - - - @@ -1276,7 +1243,7 @@ background:none; - + color:#ccc; @@ -1287,7 +1254,7 @@ background:none; - + @@ -1315,7 +1282,7 @@ background:none; - + @@ -1342,7 +1309,7 @@ background:none; - 200 + 190 20 211 81 @@ -2059,7 +2026,7 @@ background:none; - + @@ -2081,8 +2048,7 @@ background:none; Edit the Keyboard and mouse shortcuts - Short- -keys + Shortkeys @@ -2131,7 +2097,7 @@ keys - 70 + 120 24 diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 251f2274..1266ab01 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -68,12 +68,6 @@ #include "tracker.h" #include "FaceTrackNoIR.h" -// -// Definitions for testing purposes -// -//#define USE_HEADPOSE_CALLBACK -//#define USE_DEBUG_CLIENT - // Flags bool Tracker::confid = false; bool Tracker::do_tracking = true; @@ -82,7 +76,6 @@ bool Tracker::do_inhibit = false; bool Tracker::do_game_zero = false; bool Tracker::do_axis_reverse = false; -bool Tracker::useFilter = false; bool Tracker::setZero = true; bool Tracker::setEngineStop = true; HANDLE Tracker::hTrackMutex = 0; @@ -156,7 +149,7 @@ QFrame *video_frame; // video_frame = 0; video_frame = mainApp->getVideoWidget(); - qDebug() << "Tracker::setup VideoFrame = " << video_frame; + qDebug() << "Tracker::Tracker VideoFrame = " << video_frame; // // Load the Tracker-engine DLL, get the tracker-class from it and do stuff... @@ -166,6 +159,7 @@ QFrame *video_frame; if (!libName.isEmpty()) { trackerLib = new QLibrary(libName); getIT = (importGetTracker) trackerLib->resolve("GetTracker"); + qDebug() << "Tracker::Tracker libName = " << libName; if (getIT) { ITracker *ptrXyz(getIT()); // Get the Class @@ -225,28 +219,28 @@ QFrame *video_frame; } } -# ifdef USE_DEBUG_CLIENT - debug_Client = QSharedPointer(new ExcelServer ( this )); // Create Excel protocol-server -# endif - // // Load the DLL with the filter-logic and retrieve a pointer to the Filter-class. // + pFilter = NULL; libName = mainApp->getCurrentFilterName(); - filterLib = new QLibrary(libName); - - getFilter = (importGetFilter) filterLib->resolve("GetFilter"); - if (getFilter) { - IFilterPtr ptrXyz(getFilter()); - if (ptrXyz) - { - pFilter = ptrXyz; - qDebug() << "Filter::setup Function Resolved!"; + + if ((!libName.isEmpty()) && (libName != "None")) { + filterLib = new QLibrary(libName); + + getFilter = (importGetFilter) filterLib->resolve("GetFilter"); + if (getFilter) { + IFilterPtr ptrXyz(getFilter()); + if (ptrXyz) + { + pFilter = ptrXyz; + qDebug() << "Filter::setup Function Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + return; } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - return; } // Load the settings from the INI-file @@ -701,8 +695,10 @@ bool bTracker2Confid = false; // do the centering target_camera = target_camera - offset_camera; - if (Tracker::useFilter && pFilter) { -// qDebug() << "Tracker::run() says target_camera.yaw = " << target_camera.yaw; + // + // Use advanced filtering, when a filter was selected. + // + if (pFilter) { pFilter->FilterHeadPoseData(¤t_camera, &target_camera, &new_camera, Tracker::Pitch.newSample); } else { @@ -711,7 +707,11 @@ bool bTracker2Confid = false; output_camera.x = X.invert * X.curvePtr->getValue(new_camera.x); output_camera.y = Y.invert * Y.curvePtr->getValue(new_camera.y); output_camera.z = Z.invert * Z.curvePtr->getValue(new_camera.z); - bool altp = new_camera.pitch < 0; + + // + // Determine, which curve (Up or Down) must be used for Pitch + // + bool altp = (new_camera.pitch < 0); if (altp) { output_camera.pitch = Pitch.invert * Pitch.curvePtrAlt->getValue(new_camera.pitch); Pitch.curvePtr->setTrackingActive( false ); @@ -725,7 +725,6 @@ bool bTracker2Confid = false; output_camera.yaw = Yaw.invert * Yaw.curvePtr->getValue(new_camera.yaw); output_camera.roll = Roll.invert * Roll.curvePtr->getValue(new_camera.roll); - X.curvePtr->setTrackingActive( true ); Y.curvePtr->setTrackingActive( true ); Z.curvePtr->setTrackingActive( true ); diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index fa5bf7ca..0ddd5df4 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -110,7 +110,6 @@ public: void initHeadPoseData(){ headPos = 0.0f; -// offset_headPos = 0.0f; invert = 0.0f; red = 0.0f; rawList.clear(); @@ -126,14 +125,12 @@ public: } float headPos; // Current position (from faceTracker, radials or meters) -// float offset_headPos; // Offset for centering float invert; // Invert measured value (= 1.0f or -1.0f) float red; // Reduction factor (used for EWMA-filtering, between 0.0f and 1.0f) QList rawList; // List of 'n' headPos values (used for moving average) int maxItems; // Maximum number of elements in rawList float prevPos; // Previous Position float prevRawPos; // Previous Raw Position -// QPainterPath curve; // Bezier curve to translate input -> output FunctionConfig* curvePtr; // Function to translate input -> output FunctionConfig* curvePtrAlt; @@ -202,7 +199,6 @@ private: static HANDLE hTrackMutex; // Prevent reading/writing the headpose simultaneously - static bool useFilter; // Use EWMA-filtering static bool setZero; // Set to zero's, when OFF (one-shot) static bool setEngineStop; // Stop tracker->engine, when OFF @@ -250,7 +246,6 @@ public: static void setInvertY(bool invert) { Y.invert = invert?-1.0f:+1.0f; } static void setInvertZ(bool invert) { Z.invert = invert?-1.0f:+1.0f; } - static void setUseFilter(bool set) { useFilter = set; } static void getHeadPose(THeadPoseData *data); // Return the current headpose data static void getOutputHeadPose(THeadPoseData *data); // Return the current (processed) headpose data static IFilterPtr getFilterPtr() { return pFilter; } // Return the pointer for the active Filter @@ -270,7 +265,6 @@ public: static float getSmoothFromList ( QList *rawList ); static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } static float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } -// static float getOutputFromCurve ( QPainterPath *curve, float input, float neutralzone, float maxinput ); // For now, use one slider for all void setSmoothing(int x) { -- cgit v1.2.3