From 47a512da1e98b88cd96fc761c567cef4eadd376c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Jun 2015 08:45:52 +0200 Subject: flush It crashes after drawing a frame for now. --- CMakeLists.txt | 55 +- facetracknoir/options-dialog.cpp | 123 ++- facetracknoir/options-dialog.hpp | 23 +- facetracknoir/settings.ui | 514 +++++++++--- facetracknoir/trans_calib.cpp | 44 + facetracknoir/trans_calib.h | 39 + facetracknoir/ui.cpp | 59 +- facetracknoir/ui.h | 12 - .../ftnoir_accela_filtercontrols.ui | 299 ------- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 9 - ftnoir_filter_accela/ftnoir_filter_accela.h | 37 +- .../ftnoir_filter_accela_dialog.cpp | 85 -- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 926 --------------------- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 62 +- ftnoir_tracker_pt/ftnoir_tracker_pt.qrc | 9 - ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 154 ---- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h | 53 -- ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp | 20 - ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h | 24 - ftnoir_tracker_pt/point_extractor.cpp | 86 +- ftnoir_tracker_pt/point_extractor.h | 1 - ftnoir_tracker_pt/point_tracker.h | 25 +- ftnoir_tracker_pt/trans_calib.cpp | 44 - ftnoir_tracker_pt/trans_calib.h | 39 - opentrack/selected-libraries.cpp | 6 +- opentrack/selected-libraries.hpp | 2 +- opentrack/tracker.cpp | 2 +- 27 files changed, 741 insertions(+), 2011 deletions(-) create mode 100644 facetracknoir/trans_calib.cpp create mode 100644 facetracknoir/trans_calib.h delete mode 100644 ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui delete mode 100644 ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp delete mode 100644 ftnoir_tracker_pt/FTNoIR_PT_Controls.ui delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.qrc delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h delete mode 100644 ftnoir_tracker_pt/trans_calib.cpp delete mode 100644 ftnoir_tracker_pt/trans_calib.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 65d6e369..149655e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,20 +90,24 @@ macro(opentrack_library n dir) opentrack_module(${n} ${dir}) opentrack_qt(${n}) set(link-mode SHARED) - if (STATIC) + if (foolib_STATIC) set(link-mode STATIC) endif() add_library(${n} ${link-mode} ${${n}-all}) target_link_libraries(${n} ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + set(visibility "-fvisibility=hidden -fvisibility-inlines-hidden") + if (foolib_STATIC) + set(visibility) + endif() SET_TARGET_PROPERTIES(${n} PROPERTIES LINK_FLAGS "${foolib_LINK} ${foolib_GNU-LINK} -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack/${version-script}-version-script.txt\"" - COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" + COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} ${visibility}" ) else() set_target_properties(${n} PROPERTIES LINK_FLAGS ${foolib_LINK} COMPILE_FLAGS ${foolib_COMPILE}) endif() - if (NOT STATIC) + if (NOT foolib_STATIC) install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) endif() endmacro() @@ -244,9 +248,8 @@ set_target_properties(opentrack-version PROPERTIES COMPILE_DEFINITIONS "IN_VERSION_UNIT;OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\"") -opentrack_library(opentrack-filter-accela ftnoir_filter_accela) -opentrack_library(opentrack-filter-kalman ftnoir_filter_kalman) -opentrack_library(opentrack-filter-ewma ftnoir_filter_ewma2) +opentrack_library(opentrack-filter-accela ftnoir_filter_accela STATIC TRUE) +#opentrack_library(opentrack-filter-ewma ftnoir_filter_ewma2) opentrack_library(opentrack-proto-fgfs ftnoir_protocol_fg) @@ -286,16 +289,16 @@ endif() opentrack_library(opentrack-proto-udp ftnoir_protocol_ftn) if(WIN32) - opentrack_library(opentrack-tracker-joystick ftnoir_tracker_joystick) + #opentrack_library(opentrack-tracker-joystick ftnoir_tracker_joystick) endif() -if(Qt5SerialPort_FOUND) +if(Qt5SerialPort_FOUND AND FALSE) opentrack_library(opentrack-tracker-hatire ftnoir_tracker_hatire) target_link_libraries(opentrack-tracker-hatire ${Qt5SerialPort_LIBRARIES}) target_include_directories(opentrack-tracker-hatire SYSTEM PUBLIC ${Qt5SerialPort_INCLUDE_DIRS}) endif() -if(SDK_WINE_PREFIX) +if(SDK_WINE_PREFIX AND FALSE) opentrack_library(opentrack-proto-wine ftnoir_protocol_wine) target_link_libraries(opentrack-proto-wine opentrack-compat opentrack-csv) if(NOT SDK_WINE_NO_WRAPPER) @@ -319,32 +322,33 @@ if(SDK_WINE_PREFIX) endif() endif() -opentrack_library(opentrack-tracker-udp ftnoir_tracker_udp) -opentrack_library(opentrack-tracker-freepie-udp ftnoir_tracker_freepie-udp) +#opentrack_library(opentrack-tracker-udp ftnoir_tracker_udp) +#opentrack_library(opentrack-tracker-freepie-udp ftnoir_tracker_freepie-udp) if(OpenCV_FOUND) - opentrack_library(opentrack-tracker-pt ftnoir_tracker_pt) + opentrack_library(opentrack-tracker-pt ftnoir_tracker_pt STATIC YES) target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS}) target_include_directories(opentrack-tracker-pt SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) link_with_dinput8(opentrack-tracker-pt) if(SDK_ARUCO_LIBPATH) - opentrack_library(opentrack-tracker-aruco ftnoir_tracker_aruco) - target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - target_include_directories(opentrack-tracker-aruco SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) + #opentrack_library(opentrack-tracker-aruco ftnoir_tracker_aruco) + #target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) + #target_include_directories(opentrack-tracker-aruco SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) endif() - target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) - target_include_directories(opentrack-filter-kalman SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) + #opentrack_library(opentrack-filter-kalman ftnoir_filter_kalman) + #target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) + #target_include_directories(opentrack-filter-kalman SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) endif() -opentrack_library(opentrack-tracker-ht ftnoir_tracker_ht) -target_link_libraries(opentrack-tracker-ht opentrack-compat) -link_with_dinput8(opentrack-tracker-ht) +#opentrack_library(opentrack-tracker-ht ftnoir_tracker_ht) +#target_link_libraries(opentrack-tracker-ht opentrack-compat) +#link_with_dinput8(opentrack-tracker-ht) -link_with_dinput8(opentrack-tracker-joystick) +#link_with_dinput8(opentrack-tracker-joystick) -if(SDK_RIFT) +if(SDK_RIFT AND FALSE) set(link-flags) set(c-flags) if(APPLE) @@ -366,7 +370,7 @@ if(SDK_RIFT) endif() endif() -if(SDK_HYDRA) +if(SDK_HYDRA AND FALSE) opentrack_library(opentrack-tracker-hydra ftnoir_tracker_hydra) target_include_directories(opentrack-tracker-hydra SYSTEM PUBLIC ${SDK_HYDRA}/include ${SDK_HYDRA}/include/sixense_utils) if(WIN32) @@ -428,18 +432,21 @@ else() endif() opentrack_module(opentrack facetracknoir) + if(UNIX OR APPLE) list(APPEND opentrack-c qxt-mini/qxtglobalshortcut.h) endif() opentrack_qt(opentrack) add_executable(opentrack ${opentrack-win32-executable} ${opentrack-all}) +target_link_libraries(opentrack opentrack-filter-accela opentrack-tracker-pt) if(NOT WIN32) set_target_properties(opentrack PROPERTIES SUFFIX ".bin") endif() target_link_libraries(opentrack opentrack-api opentrack-version opentrack-pose-widget opentrack-spline-widget) - +target_include_directories(opentrack SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) +target_link_libraries(opentrack ${OpenCV_LIBS}) if(APPLE) SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation") 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(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"); +} diff --git a/facetracknoir/options-dialog.hpp b/facetracknoir/options-dialog.hpp index 33ae1810..6f752a08 100644 --- a/facetracknoir/options-dialog.hpp +++ b/facetracknoir/options-dialog.hpp @@ -2,9 +2,14 @@ #include #include +#include #include "ui_settings.h" +#include "opentrack/state.hpp" #include "opentrack/shortcuts.h" #include "ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h" +#include "facetracknoir/trans_calib.h" +#include "ftnoir_tracker_pt/ftnoir_tracker_pt.h" +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" class OptionsDialog: public QWidget { @@ -12,12 +17,28 @@ class OptionsDialog: public QWidget signals: void reload(); public: - OptionsDialog(); + OptionsDialog(State &state); private: Ui::UI_Settings ui; Shortcuts::settings s; settings_pt pt; + settings_accela acc; + QTimer timer; + State& state; + TranslationCalibrator trans_calib; + bool trans_calib_running; + + Tracker_PT* get_pt(); + + void update_ewma_display(int value); + void update_rot_display(int value); + void update_trans_display(int value); + void update_rot_dz_display(int value); + void update_trans_dz_display(int value); private slots: void doOK(); void doCancel(); + void startstop_trans_calib(bool start); + void poll_tracker_info(); + void trans_calib_step(); }; diff --git a/facetracknoir/settings.ui b/facetracknoir/settings.ui index 240ed522..5c6c7f32 100644 --- a/facetracknoir/settings.ui +++ b/facetracknoir/settings.ui @@ -296,8 +296,135 @@ Camera - - + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Point extraction + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Threshold + + + threshold_slider + + + + + + + Intensity threshold for point extraction + + + 255 + + + 1 + + + 127 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 25 + + + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + Min size + + + mindiam_spin + + + + + + + Minimum point diameter + + + px + + + 1024 + + + + + + + Max size + + + maxdiam_spin + + + + + + + Maximum point diameter + + + px + + + 1024 + + + + + + + + + + Camera offset @@ -403,7 +530,7 @@ - + Device @@ -464,133 +591,29 @@ - - + + - Point extraction + Status - + - - - QFrame::StyledPanel - - - QFrame::Raised + + + Not running - - - - - Threshold - - - threshold_slider - - - - - - - Intensity threshold for point extraction - - - 255 - - - 1 - - - 127 - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - QFrame::NoFrame - - - QFrame::Raised + + + - - - - - Min size - - - mindiam_spin - - - - - - - Minimum point diameter - - - px - - - 1024 - - - - - - - Max size - - - maxdiam_spin - - - - - - - Maximum point diameter - - - px - - - 1024 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -684,7 +707,7 @@ - Model position + Model position calibration @@ -1299,6 +1322,261 @@ + + + Filter + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + 99 + + + 5 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 25 + + + + + + + + 0 + 0 + + + + color:#0; +background:none; + + + Rotation sensitivity + + + + + + + Smoothing + + + + + + + + 48 + 0 + + + + 0 ms + + + + + + + + + + + + + + 100 + + + 10 + + + 25 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 25 + + + + + + + Translation deadzone + + + + + + + Rotation deadzone + + + + + + + 100 + + + Qt::Horizontal + + + + + + + + + + + + + + 100 + + + Qt::Horizontal + + + + + + + 0mm + + + + + + + + 0 + 0 + + + + Translation sensitivity + + + + + + + 0mm + + + + + + + 99 + + + 5 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 25 + + + + + + + + + + GroupBox + + + + + + + 0 + 0 + + + + + 7 + + + + QFrame::NoFrame + + + <html><head/><body><p align="justify"><br/><span style=" font-size:10pt;">Accela by </span><a href="https://github.com/sthalik"><span style=" font-size:10pt; text-decoration: underline; color:#0057ae;">Stanisław Halik</span></a><span style=" font-size:10pt;"><br/>Thanks to </span><a href="https://github.com/dbaarda"><span style=" font-size:10pt; text-decoration: underline; color:#0057ae;">Donovan Baarda</span></a></p><p align="right"><span style=" font-size:10pt;">2012-2015</span></p><p align="right"><br/></p></body></html> + + + Qt::RichText + + + false + + + Qt::AlignCenter + + + true + + + 0 + + + 0 + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + <html><head/><body><p>Visit <a href="https://github.com/opentrack/opentrack/wiki/Accela-in-opentrack-2.3"><span style=" text-decoration: underline; color:#0000ff;">our wiki</span></a> for description of the settings.</p></body></html> + + + true + + + + + + + + Game detection diff --git a/facetracknoir/trans_calib.cpp b/facetracknoir/trans_calib.cpp new file mode 100644 index 00000000..2994eb48 --- /dev/null +++ b/facetracknoir/trans_calib.cpp @@ -0,0 +1,44 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "trans_calib.h" + +using namespace cv; + +//----------------------------------------------------------------------------- +TranslationCalibrator::TranslationCalibrator() +{ + reset(); +} + +void TranslationCalibrator::reset() +{ + P = Matx66f::zeros(); + y = Vec6f(0,0,0, 0,0,0); +} + +void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) +{ + Matx H_k_T = Matx::zeros(); + for (int i=0; i<3; ++i) { + for (int j=0; j<3; ++j) { + H_k_T(i,j) = R_CM_k(j,i); + } + } + for (int i=0; i<3; ++i) + { + H_k_T(3+i,i) = 1.0; + } + P += H_k_T * H_k_T.t(); + y += H_k_T * t_CM_k; +} + +Vec3f TranslationCalibrator::get_estimate() +{ + Vec6f x = P.inv() * y; + return Vec3f(-x[0], -x[1], -x[2]); +} diff --git a/facetracknoir/trans_calib.h b/facetracknoir/trans_calib.h new file mode 100644 index 00000000..c2c02b38 --- /dev/null +++ b/facetracknoir/trans_calib.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef TRANSCALIB_H +#define TRANSCALIB_H + +#include + +//----------------------------------------------------------------------------- +// Calibrates the translation from head to model = t_MH +// by recursive least squares / +// kalman filter in information form with identity noise covariance +// measurement equation when head position = t_CH is fixed: +// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k + +class TranslationCalibrator +{ +public: + TranslationCalibrator(); + + // reset the calibration process + void reset(); + + // update the current estimate + void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); + + // get the current estimate for t_MH + cv::Vec3f get_estimate(); + +private: + cv::Matx66f P; // normalized precision matrix = inverse covariance + cv::Vec6f y; // P*(-t_MH, t_CH) +}; + +#endif //TRANSCALIB_H diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index d1d43a24..7e0a78cc 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -24,6 +24,8 @@ #include "ui.h" #include "opentrack/tracker.h" #include "opentrack/options.hpp" +#include "ftnoir_tracker_pt/ftnoir_tracker_pt.h" +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" #include #include @@ -208,7 +210,8 @@ void MainWindow::startTracker() { // tracker dtor needs run first work = nullptr; - libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter()); + libs = SelectedLibraries(ui.video_frame, std::make_shared(), current_protocol(), std::make_shared()); + work = std::make_shared(s, pose, libs, this, winId()); { @@ -225,12 +228,6 @@ void MainWindow::startTracker() { return; } - if (pTrackerDialog) - pTrackerDialog->register_tracker(libs.pTracker.get()); - - if (pFilterDialog) - pFilterDialog->register_filter(libs.pFilter.get()); - if (pProtocolDialog) pProtocolDialog->register_protocol(libs.pProtocol.get()); @@ -248,24 +245,12 @@ void MainWindow::stopTracker( ) { pose_update_timer.stop(); ui.pose_display->rotateBy(0, 0, 0, 0, 0, 0); - if (pTrackerDialog) - { - pTrackerDialog->unregister_tracker(); - pTrackerDialog = nullptr; - } - if (pProtocolDialog) { pProtocolDialog->unregister_protocol(); pProtocolDialog = nullptr; } - if (pFilterDialog) - { - pFilterDialog->unregister_filter(); - pFilterDialog = nullptr; - } - work = nullptr; libs = SelectedLibraries(); @@ -338,24 +323,6 @@ mem mk_dialog(mem lib) return nullptr; } -void MainWindow::showTrackerSettings() -{ - if (pTrackerDialog && pTrackerDialog->isVisible()) - { - pTrackerDialog->show(); - pTrackerDialog->raise(); - } - else - { - auto dialog = mk_dialog(current_tracker()); - pTrackerDialog = dialog; - if (libs.pTracker != nullptr) - dialog->register_tracker(libs.pTracker.get()); - dialog->show(); - dialog->raise(); - } -} - void MainWindow::showProtocolSettings() { if (pProtocolDialog && pProtocolDialog->isVisible()) { @@ -372,22 +339,6 @@ void MainWindow::showProtocolSettings() { } } -void MainWindow::showFilterSettings() { - if (pFilterDialog && pFilterDialog->isVisible()) - { - pFilterDialog->show(); - pFilterDialog->raise(); - } else - { - auto dialog = mk_dialog(current_filter()); - pFilterDialog = dialog; - if (libs.pFilter != nullptr) - dialog->register_filter(libs.pFilter.get()); - dialog->show(); - dialog->raise(); - } -} - void MainWindow::showKeyboardShortcuts() { if (shortcuts_widget && shortcuts_widget->isVisible()) { @@ -396,7 +347,7 @@ void MainWindow::showKeyboardShortcuts() { } else { - shortcuts_widget = std::make_shared(); + shortcuts_widget = std::make_shared(static_cast(*this)); shortcuts_widget->setWindowFlags(Qt::Dialog); connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts())); shortcuts_widget->show(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 10f5c814..1a4ce5cb 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -71,23 +71,13 @@ class MainWindow : public QMainWindow, private State mem mapping_widget; QShortcut kbd_quit; QPixmap no_feed_pixmap; - mem pFilterDialog; mem pProtocolDialog; - mem pTrackerDialog; process_detector_worker det; - mem current_tracker() - { - return modules.trackers().value(0, nullptr); - } mem current_protocol() { return modules.protocols().value(ui.iconcomboProtocol->currentIndex(), nullptr); } - mem current_filter() - { - return modules.filters().value(0, nullptr); - } void changeEvent(QEvent* e) override; @@ -109,9 +99,7 @@ private slots: void exit(); void profileSelected(int index); - void showTrackerSettings(); void showProtocolSettings(); - void showFilterSettings(); void showKeyboardShortcuts(); void showCurveConfiguration(); void showHeadPose(); diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui deleted file mode 100644 index c16fbe0a..00000000 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ /dev/null @@ -1,299 +0,0 @@ - - - AccelaUICFilterControls - - - Qt::NonModal - - - - 0 - 0 - 501 - 358 - - - - Accela filter settings - - - - :/images/filter-16.png:/images/filter-16.png - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - 99 - - - 5 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 25 - - - - - - - - 0 - 0 - - - - color:#0; -background:none; - - - Rotation sensitivity - - - - - - - Smoothing - - - - - - - - 48 - 0 - - - - 0 ms - - - - - - - - - - - - - - 100 - - - 10 - - - 25 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 25 - - - - - - - Translation deadzone - - - - - - - Rotation deadzone - - - - - - - 100 - - - Qt::Horizontal - - - - - - - - - - - - - - 100 - - - Qt::Horizontal - - - - - - - 0mm - - - - - - - - 0 - 0 - - - - Translation sensitivity - - - - - - - 0mm - - - - - - - 99 - - - 5 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 25 - - - - - - - - - - - 0 - 0 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - GroupBox - - - - - - - 0 - 0 - - - - - 7 - - - - QFrame::NoFrame - - - <html><head/><body><p align="justify"><br/><span style=" font-size:10pt;">Accela by </span><a href="https://github.com/sthalik"><span style=" font-size:10pt; text-decoration: underline; color:#0057ae;">Stanisław Halik</span></a><span style=" font-size:10pt;"><br/>Thanks to </span><a href="https://github.com/dbaarda"><span style=" font-size:10pt; text-decoration: underline; color:#0057ae;">Donovan Baarda</span></a></p><p align="right"><span style=" font-size:10pt;">2012-2015</span></p><p align="right"><br/></p></body></html> - - - Qt::RichText - - - false - - - Qt::AlignCenter - - - true - - - 0 - - - 0 - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - <html><head/><body><p>Visit <a href="https://github.com/opentrack/opentrack/wiki/Accela-in-opentrack-2.3"><span style=" text-decoration: underline; color:#0000ff;">our wiki</span></a> for description of the settings.</p></body></html> - - - true - - - - - - - - - - buttonBox - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 77964d32..f0b0b468 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -97,12 +97,3 @@ void FTNoIR_Filter::filter(const double* input, double *output) } } -extern "C" OPENTRACK_EXPORT IFilter* GetConstructor() -{ - return new FTNoIR_Filter; -} - -extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() -{ - return new FTNoIR_FilterDll; -} diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index aa10e161..17698922 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,5 +1,4 @@ #pragma once -#include "ui_ftnoir_accela_filtercontrols.h" #include "opentrack/plugin-api.hpp" #include #include @@ -9,9 +8,9 @@ using namespace options; #include "opentrack/timer.hpp" -struct settings : opts { +struct settings_accela : opts { value rot_threshold, trans_threshold, ewma, rot_deadzone, trans_deadzone; - settings() : + settings_accela() : opts("Accela"), rot_threshold(b, "rotation-threshold", 30), trans_threshold(b, "translation-threshold", 50), @@ -27,7 +26,7 @@ public: FTNoIR_Filter(); void filter(const double* input, double *output); private: - settings s; + settings_accela s; bool first_run; double last_output[6]; double smoothed_input[6]; @@ -35,33 +34,3 @@ private: double f(double val, const double gains[][2]); }; - -class FilterControls: public IFilterDialog -{ - Q_OBJECT -public: - FilterControls(); - void register_filter(IFilter* filter); - void unregister_filter(); -private: - Ui::AccelaUICFilterControls ui; - void discard(); - void save(); - FTNoIR_Filter* accela_filter; - settings s; -private slots: - void doOK(); - void doCancel(); - void update_ewma_display(int value); - void update_rot_display(int value); - void update_trans_display(int value); - void update_rot_dz_display(int value); - void update_trans_dz_display(int value); -}; - -class FTNoIR_FilterDll : public Metadata -{ -public: - QString name() { return QString("Accela"); } - QIcon icon() { return QIcon(":/images/filter-16.png"); } -}; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp deleted file mode 100644 index 550c9d24..00000000 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "ftnoir_filter_accela/ftnoir_filter_accela.h" -#include -#include -#include -#include -#include "opentrack/plugin-api.hpp" - -FilterControls::FilterControls() : - accela_filter(nullptr) -{ - ui.setupUi( this ); - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - connect(ui.rotation_slider, SIGNAL(valueChanged(int)), this, SLOT(update_rot_display(int))); - connect(ui.translation_slider, SIGNAL(valueChanged(int)), this, SLOT(update_trans_display(int))); - connect(ui.ewma_slider, SIGNAL(valueChanged(int)), this, SLOT(update_ewma_display(int))); - connect(ui.rot_dz_slider, SIGNAL(valueChanged(int)), this, SLOT(update_rot_dz_display(int))); - connect(ui.trans_dz_slider, SIGNAL(valueChanged(int)), this, SLOT(update_trans_dz_display(int))); - - tie_setting(s.rot_threshold, ui.rotation_slider); - tie_setting(s.trans_threshold, ui.translation_slider); - tie_setting(s.ewma, ui.ewma_slider); - tie_setting(s.rot_deadzone, ui.rot_dz_slider); - tie_setting(s.trans_deadzone, ui.trans_dz_slider); -} - -void FilterControls::register_filter(IFilter* filter) -{ - accela_filter = static_cast(filter); -} - -void FilterControls::unregister_filter() -{ - accela_filter = nullptr; -} - -void FilterControls::doOK() { - save(); - this->close(); -} - -void FilterControls::doCancel() { - discard(); - close(); -} - -void FilterControls::discard() -{ - s.b->reload(); -} - -void FilterControls::save() { - s.b->save(); -} - -void FilterControls::update_rot_display(int value) -{ - ui.rot_gain->setText(QString::number((value + 1) * 10 / 100.) + "°"); -} - -void FilterControls::update_trans_display(int value) -{ - ui.trans_gain->setText(QString::number((value + 1) * 5 / 100.) + "mm"); -} - -void FilterControls::update_ewma_display(int value) -{ - ui.ewma_label->setText(QString::number(value * 2) + "ms"); -} - -void FilterControls::update_rot_dz_display(int value) -{ - ui.rot_dz->setText(QString::number(value * 2 / 100.) + "°"); -} - -void FilterControls::update_trans_dz_display(int value) -{ - ui.trans_dz->setText(QString::number(value * 1 / 100.) + "mm"); -} - -extern "C" OPENTRACK_EXPORT IFilterDialog* GetDialog() -{ - return new FilterControls; -} diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui deleted file mode 100644 index 15062a8d..00000000 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ /dev/null @@ -1,926 +0,0 @@ - - - UICPTClientControls - - - Qt::NonModal - - - - 0 - 0 - 397 - 588 - - - - - 0 - 0 - - - - PointTracker Settings - - - - :/Resources/Logo_IR.png:/Resources/Logo_IR.png - - - Qt::LeftToRight - - - false - - - - QLayout::SetFixedSize - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - 1 - - - - Camera - - - - - - Camera settings - - - - - - - 0 - 0 - - - - Device - - - camdevice_combo - - - - - - - - 0 - 0 - - - - Desired capture width - - - px - - - 2000 - - - 10 - - - - - - - - 0 - 0 - - - - Height - - - - - - - - 0 - 0 - - - - 10 - - - - - - - - 0 - 0 - - - - Width - - - - - - - - 0 - 0 - - - - Field of view - - - - - - - - 0 - 0 - - - - Desired capture height - - - px - - - 2000 - - - 10 - - - - - - - - 0 - 0 - - - - FPS - - - fps_spin - - - - - - - - 0 - 0 - - - - Desired capture framerate - - - Hz - - - 2000 - - - - - - - ° - - - - - - 10 - - - 90 - - - - - - - - 0 - 0 - - - - Dynamic pose resolution - - - - - - - - - - - - - - - - - - Model - - - - - - - 0 - 0 - - - - QTabWidget::Rounded - - - 0 - - - false - - - false - - - false - - - - Clip - - - - - - - 0 - 0 - - - - - 331 - 208 - - - - Model Dimensions - - - - - 70 - 35 - 100 - 22 - - - - mm - - - -65535 - - - 65535 - - - - - - 150 - 130 - 100 - 22 - - - - mm - - - -65535 - - - 65535 - - - - - - 65 - 55 - 71 - 111 - - - - - - - :/Resources/clip_side.png - - - - - - 20 - 40 - 46 - 13 - - - - Side - - - - - - 50 - 160 - 100 - 22 - - - - mm - - - -65535 - - - 65535 - - - - - - 150 - 70 - 100 - 22 - - - - mm - - - -65535 - - - 65535 - - - - - - 290 - 40 - 46 - 13 - - - - Front - - - - - - 300 - 70 - 21 - 111 - - - - - - - :/Resources/clip_front.png - - - - - - - - - Cap - - - - - - - 331 - 208 - - - - Model Dimensions - - - - - 100 - 60 - 111 - 81 - - - - - - - :/Resources/cap_side.png - - - - - - 20 - 40 - 46 - 13 - - - - Side - - - - - - 90 - 40 - 101 - 22 - - - - mm - - - -65535 - - - 65535 - - - - - - 220 - 100 - 81 - 81 - - - - - - - :/Resources/cap_front.png - - - - - - 240 - 70 - 81 - 22 - - - - mm - - - -65535 - - - 65535 - - - - - - 240 - 40 - 46 - 13 - - - - Front - - - - - - 20 - 90 - 81 - 22 - - - - mm - - - -65535 - - - 65535 - - - - - - - - - Custom - - - - - - Model Dimensions - - - - - - - 0 - 0 - - - - z: - - - - - - - mm - - - -65535 - - - 65535 - - - - - - - - 0 - 0 - - - - x: - - - - - - - mm - - - -65535 - - - 65535 - - - - - - - mm - - - -65535 - - - 65535 - - - - - - - mm - - - -65535 - - - 65535 - - - - - - - mm - - - -65535 - - - 65535 - - - - - - - - 0 - 0 - - - - <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, not necessarily centimeters.</p></body></html> - - - - - - - mm - - - -65535 - - - 65535 - - - - - - - - 0 - 0 - - - - y: - - - - - - - - 0 - 0 - - - - x: - - - - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">3</span></p></body></html> - - - - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">2</span></p></body></html> - - - - - - - - 0 - 0 - - - - z: - - - - - - - - 0 - 0 - - - - y: - - - - - - - - - - - - - - - About - - - - - - <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 - - - - - - Extracted Points: - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Camera Info: - - - - - - - - 50 - 0 - - - - - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - - - - - - - - - - tabWidget - camdevice_combo - res_x_spin - res_y_spin - fps_spin - fov - model_tabs - clip_tlength_spin - clip_theight_spin - clip_bheight_spin - clip_blength_spin - cap_length_spin - cap_width_spin - cap_height_spin - m1x_spin - m1y_spin - m1z_spin - m2x_spin - m2y_spin - m2z_spin - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 4c0913e7..bad75238 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -12,6 +12,7 @@ #include #include #include "opentrack/thread.hpp" +#include "opentrack/camera-names.hpp" using namespace std; using namespace cv; @@ -53,7 +54,19 @@ void Tracker_PT::reset_command(Command command) float Tracker_PT::get_focal_length() { static constexpr float pi = 3.1415926f; - const float fov = static_cast(s.fov) * pi / 180.f; + float fov_; + switch (s.fov) + { + default: + case 0: + fov_ = 56; + break; + case 1: + fov_ = 75; + break; + } + + const float fov = static_cast(fov_) * pi / 180.f; return 0.5f / tan(0.5f * fov); } @@ -85,7 +98,7 @@ void Tracker_PT::run() ever_success |= success; if (success) - point_tracker.track(points, PointModel(s), get_focal_length(), s.dynamic_pose); + point_tracker.track(points, PointModel(s), get_focal_length(), true); { Affine X_CM = pose(); @@ -128,15 +141,39 @@ void Tracker_PT::run() qDebug()<<"Tracker:: Thread stopping"; } -int camera_name_to_index(const QString &name); - void Tracker_PT::apply_settings() { qDebug()<<"Tracker:: Applying settings"; QMutexLocker lock(&mutex); - camera.set_device_index(camera_name_to_index(s.camera_name)); - camera.set_res(s.cam_res_x, s.cam_res_y); - camera.set_fps(s.cam_fps); + camera.set_device_index(camera_name_to_index("PS3Eye Camera")); + int res_x, res_y, cam_fps; + switch (s.camera_mode) + { + default: + case 0: + res_x = 640; + res_y = 480; + cam_fps = 75; + break; + case 1: + res_x = 640; + res_y = 480; + cam_fps = 60; + break; + case 2: + res_x = 320; + res_y = 240; + cam_fps = 189; + break; + case 3: + res_x = 320; + res_y = 240; + cam_fps = 120; + break; + } + + camera.set_res(res_x, res_y); + camera.set_fps(cam_fps); qDebug()<<"Tracker::apply ends"; } @@ -202,14 +239,3 @@ void Tracker_PT::data(THeadPoseData *data) data[TZ] = t[2] / 10.0; } } - -//----------------------------------------------------------------------------- -#ifdef OPENTRACK_API -extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() -#else -#pragma comment(linker, "/export:GetTracker=_GetTracker@0") -OPENTRACK_EXPORT ITrackerPtr __stdcall GetTracker() -#endif -{ - return new Tracker_PT; -} diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc b/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc deleted file mode 100644 index a8f9a1af..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc +++ /dev/null @@ -1,9 +0,0 @@ - - - Resources/cap_front.png - Resources/cap_side.png - Resources/clip_front.png - Resources/clip_side.png - Resources/Logo_IR.png - - diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp deleted file mode 100644 index 6f78b141..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_pt_dialog.h" - -#include -#include -#include -#ifndef OPENTRACK_API -# include -#else -# include -# include "opentrack/camera-names.hpp" -#endif -#include - -using namespace std; - -//----------------------------------------------------------------------------- -TrackerDialog_PT::TrackerDialog_PT() - : tracker(NULL), - timer(this), - trans_calib_running(false) -{ - ui.setupUi( this ); - -#ifdef OPENTRACK_API - ui.camdevice_combo->addItems(get_camera_names()); -#else - vector device_names; - get_camera_device_names(device_names); - for (vector::iterator iter = device_names.begin(); iter != device_names.end(); ++iter) - { - ui.camdevice_combo->addItem(iter->c_str()); - } -#endif - - - - connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); - timer.start(100); -} - -void TrackerDialog_PT::startstop_trans_calib(bool start) -{ - if (start) - { - qDebug()<<"TrackerDialog:: Starting translation calibration"; - trans_calib.reset(); - trans_calib_running = true; - s.t_MH_x = 0; - s.t_MH_y = 0; - s.t_MH_z = 0; - } - else - { - qDebug()<<"TrackerDialog:: Stopping translation calibration"; - trans_calib_running = false; - { - auto tmp = trans_calib.get_estimate(); - s.t_MH_x = tmp[0]; - s.t_MH_y = tmp[1]; - s.t_MH_z = tmp[2]; - } - } -} - -void TrackerDialog_PT::poll_tracker_info() -{ - 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 TrackerDialog_PT::trans_calib_step() -{ - if (tracker) - { - Affine X_CM = tracker->pose(); - trans_calib.update(X_CM.R, X_CM.t); - } -} - -void TrackerDialog_PT::save() -{ - s.b->save(); -} - -void TrackerDialog_PT::doOK() -{ - save(); - close(); -} - -void TrackerDialog_PT::doCancel() -{ - s.b->reload(); - close(); -} - -void TrackerDialog_PT::register_tracker(ITracker *t) -{ - qDebug()<<"TrackerDialog:: Tracker registered"; - tracker = static_cast(t); - ui.tcalib_button->setEnabled(true); - //ui.center_button->setEnabled(true); -} - -void TrackerDialog_PT::unregister_tracker() -{ - qDebug()<<"TrackerDialog:: Tracker un-registered"; - tracker = NULL; - ui.tcalib_button->setEnabled(false); - //ui.center_button->setEnabled(false); -} - -extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) -{ - return new TrackerDialog_PT; -} diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h deleted file mode 100644 index c1cd2e3b..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef FTNOIR_TRACKER_PT_DIALOG_H -#define FTNOIR_TRACKER_PT_DIALOG_H - -#ifdef OPENTRACK_API -# include "opentrack/plugin-api.hpp" -#else -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#endif -#include "ftnoir_tracker_pt_settings.h" -#include "ftnoir_tracker_pt.h" -#include "trans_calib.h" -#include "pt_video_widget.h" -#include "ui_FTNoIR_PT_Controls.h" - -#include - -//----------------------------------------------------------------------------- -// The dialog that shows up when the user presses "Settings" -class TrackerDialog_PT : public ITrackerDialog -{ - Q_OBJECT -public: - TrackerDialog_PT(); - void register_tracker(ITracker *tracker) override; - void unregister_tracker() override; - void save(); - void trans_calib_step(); - -public slots: - void doOK(); - void doCancel(); - - void startstop_trans_calib(bool start); - void poll_tracker_info(); -private: - settings_pt s; - Tracker_PT* tracker; - QTimer timer; - - TranslationCalibrator trans_calib; - bool trans_calib_running; - - Ui::UICPTClientControls ui; -}; - -#endif //FTNOIR_TRACKER_PT_DIALOG_H diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp deleted file mode 100644 index 1aaa1bf9..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_pt_dll.h" -#include - -#ifdef OPENTRACK_API -# include "opentrack/plugin-api.hpp" -extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() -#else -# pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") -OPENTRACK_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() -#endif -{ - return new TrackerDll; -} diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h deleted file mode 100644 index 9579d46c..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#if defined(OPENTRACK_API) -# include "opentrack/plugin-api.hpp" -#else -# include "../ftnoir_tracker_base/ftnoir_tracker_base.h" -#endif - -//----------------------------------------------------------------------------- -class TrackerDll : -#if defined(OPENTRACK_API) - public Metadata -#else - public ITrackerDll -#endif -{ - QString name() { return QString("PointTracker 1.1"); } - QIcon icon() { return QIcon(":/Resources/Logo_IR.png"); } -}; diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 2c39c2e2..c186f5f2 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -25,58 +25,24 @@ std::vector PointExtractor::extract_points(Mat& frame) const int W = frame.cols; const int H = frame.rows; - if (frame_last.cols != W || frame_last.rows != H) - { - frame_last = cv::Mat(); - } - // clear old points points.clear(); - // convert to grayscale - Mat frame_gray; + // convert to grayscale + Mat frame_gray; cvtColor(frame, frame_gray, cv::COLOR_RGB2GRAY); - - int secondary = s.threshold_secondary; + int primary = s.threshold; - // mask for everything that passes the threshold (or: the upper threshold of the hysteresis) - Mat frame_bin; - // only used if draw_output - Mat frame_bin_copy; - // mask for everything that passes - Mat frame_bin_low; - // mask for lower-threshold && combined result of last, needs to remain in scope until drawing, but is only used if secondary != 0 - Mat frame_last_and_low; - - if(secondary==0){ - threshold(frame_gray, frame_bin, primary, 255, THRESH_BINARY); - }else{ - // we recombine a number of buffers, this might be slower than a single loop of per-pixel logic - // but it might as well be faster if openCV makes good use of SIMD - float t = primary; - //float hyst = float(threshold_secondary_val)/512.; - //threshold(frame_gray, frame_bin, (t + ((255.-t)*hyst)), 255, THRESH_BINARY); - float hyst = float(primary)/(256.*8.); - threshold(frame_gray, frame_bin, t, 255, THRESH_BINARY); - threshold(frame_gray, frame_bin_low,std::max(float(1), t - (t*hyst)), 255, THRESH_BINARY); - - frame_bin.copyTo(frame_bin_copy); - if(frame_last.empty()){ - frame_bin.copyTo(frame_last); - }else{ - // keep pixels from last if they are above lower threshold - bitwise_and(frame_last, frame_bin_low, frame_last_and_low); - // union of pixels >= higher threshold and pixels >= lower threshold - bitwise_or(frame_bin, frame_last_and_low, frame_last); - frame_last.copyTo(frame_bin); - } - } + // mask for everything that passes the threshold (or: the upper threshold of the hysteresis) + Mat frame_bin; + + threshold(frame_gray, frame_bin, primary, 255, THRESH_BINARY); int min_size = s.min_point_size; int max_size = s.max_point_size; - unsigned int region_size_min = 3.14*min_size*min_size/4.0; + unsigned int region_size_min = 3.14*min_size*min_size/4.0; unsigned int region_size_max = 3.14*max_size*max_size/4.0; int blob_index = 1; @@ -121,14 +87,9 @@ std::vector PointExtractor::extract_points(Mat& frame) if (frame_bin.at(i,j) != blob_index-1) continue; float val; - if(secondary==0){ - val = frame_gray.at(i,j); - val = float(val - primary)/(256 - primary); - val = val*val; // makes it more stable (less emphasis on low values, more on the peak) - }else{ - //hysteresis point detection gets stability from ignoring pixel noise so we decidedly leave the actual pixel values out of the picture - val = frame_last.at(i,j) / 256.; - } + val = frame_gray.at(i,j); + val = float(val - primary)/(256 - primary); + val = val*val; // makes it more stable (less emphasis on low values, more on the peak) m += val; mx += j * val; @@ -143,24 +104,15 @@ std::vector PointExtractor::extract_points(Mat& frame) //qDebug()< "< channels; - if(secondary==0){ - frame_bin.setTo(170, frame_bin); - channels.push_back(frame_gray + frame_bin); - channels.push_back(frame_gray - frame_bin); - channels.push_back(frame_gray - frame_bin); - }else{ - frame_bin_copy.setTo(120, frame_bin_copy); - //frame_bin_low.setTo(90, frame_bin_low); - channels.push_back(frame_gray + frame_bin_copy); - channels.push_back(frame_gray - frame_bin_copy); - channels.push_back(frame_gray - frame_bin_copy); - //channels.push_back(frame_gray + frame_bin); } + + // draw output image + vector channels; + frame_bin.setTo(170, frame_bin); + channels.push_back(frame_gray + frame_bin); + channels.push_back(frame_gray - frame_bin); + channels.push_back(frame_gray - frame_bin); merge(channels, frame); - + return points; } diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h index 3f6cfb72..b9368ab6 100644 --- a/ftnoir_tracker_pt/point_extractor.h +++ b/ftnoir_tracker_pt/point_extractor.h @@ -28,7 +28,6 @@ public: settings_pt s; private: std::vector points; - cv::Mat frame_last; }; #endif //POINTEXTRACTOR_H diff --git a/ftnoir_tracker_pt/point_tracker.h b/ftnoir_tracker_pt/point_tracker.h index 3b9573ff..39071351 100644 --- a/ftnoir_tracker_pt/point_tracker.h +++ b/ftnoir_tracker_pt/point_tracker.h @@ -70,7 +70,7 @@ public: cv::Matx22f P; - enum Model { Clip = 0, Cap = 1, Custom = 2 }; + enum Model { Clip = 0, Cap = 1 }; PointModel(settings_pt& s) { @@ -88,20 +88,17 @@ public: void set_model(settings_pt& s) { - switch (s.active_model_panel) + if (s.is_cap) { - case Clip: - M01 = cv::Vec3f(0, static_cast(s.clip_ty), -static_cast(s.clip_tz)); - M02 = cv::Vec3f(0, -static_cast(s.clip_by), -static_cast(s.clip_bz)); - break; - case Cap: - M01 = cv::Vec3f(-static_cast(s.cap_x), -static_cast(s.cap_y), -static_cast(s.cap_z)); - M02 = cv::Vec3f(static_cast(s.cap_x), -static_cast(s.cap_y), -static_cast(s.cap_z)); - break; - case Custom: - M01 = cv::Vec3f(s.m01_x, s.m01_y, s.m01_z); - M02 = cv::Vec3f(s.m02_x, s.m02_y, s.m02_z); - break; + const double z = 100, x = 120, y = 60; + M01 = cv::Vec3f(-x, -y, -z); + M02 = cv::Vec3f(x, -y, -z); + } + else + { + const double a = 27, b = 43, c = 62, d = 74; + M01 = cv::Vec3f(0, b, -a); + M02 = cv::Vec3f(0, -c, -d); } } diff --git a/ftnoir_tracker_pt/trans_calib.cpp b/ftnoir_tracker_pt/trans_calib.cpp deleted file mode 100644 index 2994eb48..00000000 --- a/ftnoir_tracker_pt/trans_calib.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "trans_calib.h" - -using namespace cv; - -//----------------------------------------------------------------------------- -TranslationCalibrator::TranslationCalibrator() -{ - reset(); -} - -void TranslationCalibrator::reset() -{ - P = Matx66f::zeros(); - y = Vec6f(0,0,0, 0,0,0); -} - -void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) -{ - Matx H_k_T = Matx::zeros(); - for (int i=0; i<3; ++i) { - for (int j=0; j<3; ++j) { - H_k_T(i,j) = R_CM_k(j,i); - } - } - for (int i=0; i<3; ++i) - { - H_k_T(3+i,i) = 1.0; - } - P += H_k_T * H_k_T.t(); - y += H_k_T * t_CM_k; -} - -Vec3f TranslationCalibrator::get_estimate() -{ - Vec6f x = P.inv() * y; - return Vec3f(-x[0], -x[1], -x[2]); -} diff --git a/ftnoir_tracker_pt/trans_calib.h b/ftnoir_tracker_pt/trans_calib.h deleted file mode 100644 index c2c02b38..00000000 --- a/ftnoir_tracker_pt/trans_calib.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef TRANSCALIB_H -#define TRANSCALIB_H - -#include - -//----------------------------------------------------------------------------- -// Calibrates the translation from head to model = t_MH -// by recursive least squares / -// kalman filter in information form with identity noise covariance -// measurement equation when head position = t_CH is fixed: -// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k - -class TranslationCalibrator -{ -public: - TranslationCalibrator(); - - // reset the calibration process - void reset(); - - // update the current estimate - void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); - - // get the current estimate for t_MH - cv::Vec3f get_estimate(); - -private: - cv::Matx66f P; // normalized precision matrix = inverse covariance - cv::Vec6f y; // P*(-t_MH, t_CH) -}; - -#endif //TRANSCALIB_H diff --git a/opentrack/selected-libraries.cpp b/opentrack/selected-libraries.cpp index 8cb226c8..d76c0111 100644 --- a/opentrack/selected-libraries.cpp +++ b/opentrack/selected-libraries.cpp @@ -14,15 +14,15 @@ static mem make_instance(mem lib) return ret; } -SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) : +SelectedLibraries::SelectedLibraries(QFrame* frame, mem t, dylibptr p, mem f) : pTracker(nullptr), pFilter(nullptr), pProtocol(nullptr), correct(false) { - pTracker = make_instance(t); + pTracker = t; pProtocol = make_instance(p); - pFilter = make_instance(f); + pFilter = f; if (!pTracker || !pProtocol) { diff --git a/opentrack/selected-libraries.hpp b/opentrack/selected-libraries.hpp index ffaf882c..07ea419b 100644 --- a/opentrack/selected-libraries.hpp +++ b/opentrack/selected-libraries.hpp @@ -8,7 +8,7 @@ struct SelectedLibraries { mem pTracker; mem pFilter; mem pProtocol; - SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f); + SelectedLibraries(QFrame* frame, mem t, dylibptr p, mem f); SelectedLibraries() : pTracker(nullptr), pFilter(nullptr), pProtocol(nullptr), correct(false) {} ~SelectedLibraries(); bool correct; diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index c124111f..e39e54dd 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -47,7 +47,7 @@ double Tracker::map(double pos, Mapping& axis) axis.curve.setTrackingActive( !altp ); axis.curveAlt.setTrackingActive( altp ); auto& fc = altp ? axis.curveAlt : axis.curve; - return fc.getValue(pos) + axis.opts.zero; + return fc.getValue(pos); } void Tracker::t_compensate(const rmat& rmat, const double* xyz, double* output, bool rz) -- cgit v1.2.3