diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-06-18 08:45:52 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-06-18 08:45:52 +0200 |
commit | 47a512da1e98b88cd96fc761c567cef4eadd376c (patch) | |
tree | 5e1562b547dcf0f7ee3aa8fb9a6f387ce665b204 /facetracknoir/options-dialog.cpp | |
parent | 33287155bdc7e4beefb45ceef0aaaeb4ecb742a7 (diff) |
flush
It crashes after drawing a frame for now.
Diffstat (limited to 'facetracknoir/options-dialog.cpp')
-rw-r--r-- | facetracknoir/options-dialog.cpp | 123 |
1 files changed, 122 insertions, 1 deletions
diff --git a/facetracknoir/options-dialog.cpp b/facetracknoir/options-dialog.cpp index 9afeba7c..08c92ee8 100644 --- a/facetracknoir/options-dialog.cpp +++ b/facetracknoir/options-dialog.cpp @@ -1,6 +1,7 @@ #include "options-dialog.hpp" +#include "ftnoir_tracker_pt/camera.h" -OptionsDialog::OptionsDialog() +OptionsDialog::OptionsDialog(State& state) : state(state), trans_calib_running(false) { ui.setupUi( this ); @@ -67,6 +68,16 @@ OptionsDialog::OptionsDialog() tie_setting(pt.fov, ui.camera_fov); tie_setting(pt.is_cap, ui.model_cap); + + tie_setting(acc.rot_threshold, ui.rotation_slider); + tie_setting(acc.trans_threshold, ui.translation_slider); + tie_setting(acc.ewma, ui.ewma_slider); + tie_setting(acc.rot_deadzone, ui.rot_dz_slider); + tie_setting(acc.trans_deadzone, ui.trans_dz_slider); + + connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); + connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); + timer.start(100); } void OptionsDialog::doOK() { @@ -85,3 +96,113 @@ void OptionsDialog::doCancel() { ui.game_detector->revert(); close(); } + +void OptionsDialog::startstop_trans_calib(bool start) +{ + auto tracker = get_pt(); + if (!tracker) + { + ui.tcalib_button->setChecked(false); + return; + } + + if (start) + { + qDebug()<<"TrackerDialog:: Starting translation calibration"; + trans_calib.reset(); + trans_calib_running = true; + pt.t_MH_x = 0; + pt.t_MH_y = 0; + pt.t_MH_z = 0; + } + else + { + qDebug()<<"TrackerDialog:: Stopping translation calibration"; + trans_calib_running = false; + { + auto tmp = trans_calib.get_estimate(); + pt.t_MH_x = tmp[0]; + pt.t_MH_y = tmp[1]; + pt.t_MH_z = tmp[2]; + } + } +} + +void OptionsDialog::poll_tracker_info() +{ + auto tracker = get_pt(); + if (tracker) + { + QString to_print; + + // display caminfo + CamInfo info; + tracker->get_cam_info(&info); + to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; + ui.caminfo_label->setText(to_print); + + // display pointinfo + int n_points = tracker->get_n_points(); + to_print = QString::number(n_points); + if (n_points == 3) + to_print += " OK!"; + else + to_print += " BAD!"; + ui.pointinfo_label->setText(to_print); + + // update calibration + if (trans_calib_running) trans_calib_step(); + } + else + { + QString to_print = "Tracker offline"; + ui.caminfo_label->setText(to_print); + ui.pointinfo_label->setText(to_print); + } +} + +void OptionsDialog::trans_calib_step() +{ + auto tracker = get_pt(); + if (tracker) + { + Affine X_CM = tracker->pose(); + trans_calib.update(X_CM.R, X_CM.t); + } +} + +Tracker_PT* OptionsDialog::get_pt() +{ + auto work = state.work.get(); + if (!work) + return nullptr; + auto ptr = work->libs.pTracker; + if (ptr) + return static_cast<Tracker_PT*>(ptr.get()); + return nullptr; +} + +void OptionsDialog::update_rot_display(int value) +{ + ui.rot_gain->setText(QString::number((value + 1) * 10 / 100.) + "°"); +} + +void OptionsDialog::update_trans_display(int value) +{ + ui.trans_gain->setText(QString::number((value + 1) * 5 / 100.) + "mm"); +} + +void OptionsDialog::update_ewma_display(int value) +{ + ui.ewma_label->setText(QString::number(value * 2) + "ms"); +} + +void OptionsDialog::update_rot_dz_display(int value) +{ + ui.rot_dz->setText(QString::number(value * 2 / 100.) + "°"); +} + +void OptionsDialog::update_trans_dz_display(int value) +{ + ui.trans_dz->setText(QString::number(value * 1 / 100.) + "mm"); +} |