diff options
-rw-r--r-- | ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 198 | ||||
-rw-r--r-- | ftnoir_tracker_pt/camera.h | 3 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 8 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt.h | 6 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 6 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h | 4 |
6 files changed, 133 insertions, 92 deletions
diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui index 17e2819b..3e900e8e 100644 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>397</width> - <height>588</height> + <width>405</width> + <height>593</height> </rect> </property> <property name="sizePolicy"> @@ -67,21 +67,8 @@ <string>Camera settings</string> </property> <layout class="QGridLayout" name="gridLayout_2"> - <item row="2" column="0"> - <widget class="QLabel" name="label_41"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Height</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> + <item row="3" column="0"> + <widget class="QLabel" name="label_37"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -89,15 +76,15 @@ </sizepolicy> </property> <property name="text"> - <string>Device</string> + <string>FPS</string> </property> <property name="buddy"> - <cstring>camdevice_combo</cstring> + <cstring>fps_spin</cstring> </property> </widget> </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="res_x_spin"> + <item row="2" column="1"> + <widget class="QSpinBox" name="res_y_spin"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -105,7 +92,7 @@ </sizepolicy> </property> <property name="toolTip"> - <string>Desired capture width</string> + <string>Desired capture height</string> </property> <property name="suffix"> <string> px</string> @@ -118,16 +105,16 @@ </property> </widget> </item> - <item row="0" column="1"> - <widget class="QComboBox" name="camdevice_combo"> + <item row="4" column="0"> + <widget class="QLabel" name="label_4"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumContentsLength"> - <number>10</number> + <property name="text"> + <string>Field of view</string> </property> </widget> </item> @@ -144,30 +131,31 @@ </property> </widget> </item> - <item row="2" column="1"> - <widget class="QSpinBox" name="res_y_spin"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="4" column="1"> + <widget class="QSpinBox" name="fov"> + <property name="suffix"> + <string>°</string> </property> - <property name="toolTip"> - <string>Desired capture height</string> + <property name="prefix"> + <string/> </property> - <property name="suffix"> - <string> px</string> + <property name="minimum"> + <number>10</number> </property> <property name="maximum"> - <number>2000</number> + <number>90</number> </property> - <property name="singleStep"> - <number>10</number> + </widget> + </item> + <item row="5" column="1"> + <widget class="QCheckBox" name="dynamic_pose"> + <property name="text"> + <string/> </property> </widget> </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_37"> + <item row="5" column="0"> + <widget class="QLabel" name="label_5"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -175,28 +163,51 @@ </sizepolicy> </property> <property name="text"> - <string>FPS</string> + <string>Dynamic pose resolution</string> </property> - <property name="buddy"> - <cstring>fps_spin</cstring> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Dynamic pose timeout</string> </property> </widget> </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_4"> + <item row="3" column="1"> + <widget class="QSpinBox" name="fps_spin"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="text"> - <string>Field of view</string> + <property name="toolTip"> + <string>Desired capture framerate</string> + </property> + <property name="suffix"> + <string> Hz</string> + </property> + <property name="maximum"> + <number>2000</number> </property> </widget> </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_5"> + <item row="6" column="1"> + <widget class="QSpinBox" name="init_phase_timeout"> + <property name="suffix"> + <string> ms</string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>10000</number> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_41"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -204,69 +215,78 @@ </sizepolicy> </property> <property name="text"> - <string>Dynamic pose resolution</string> + <string>Height</string> </property> </widget> </item> - <item row="5" column="1"> - <widget class="QCheckBox" name="dynamic_pose"> - <property name="text"> - <string/> + <item row="1" column="1"> + <widget class="QSpinBox" name="res_x_spin"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Desired capture width</string> </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QSpinBox" name="fov"> <property name="suffix"> - <string>°</string> + <string> px</string> </property> - <property name="prefix"> - <string/> + <property name="maximum"> + <number>2000</number> </property> - <property name="minimum"> + <property name="singleStep"> <number>10</number> </property> - <property name="maximum"> - <number>90</number> - </property> </widget> </item> - <item row="3" column="1"> - <widget class="QSpinBox" name="fps_spin"> + <item row="0" column="1"> + <widget class="QComboBox" name="camdevice_combo"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="toolTip"> - <string>Desired capture framerate</string> + <property name="minimumContentsLength"> + <number>10</number> </property> - <property name="suffix"> - <string> Hz</string> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="maximum"> - <number>2000</number> + <property name="text"> + <string>Device</string> + </property> + <property name="buddy"> + <cstring>camdevice_combo</cstring> </property> </widget> </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_6"> + <item row="7" column="0"> + <widget class="QLabel" name="label_9"> <property name="text"> - <string>Dynamic pose timeout</string> + <string>Camera settings dialog</string> </property> </widget> </item> - <item row="6" column="1"> - <widget class="QSpinBox" name="init_phase_timeout"> - <property name="suffix"> - <string> ms</string> - </property> - <property name="minimum"> - <number>1</number> + <item row="7" column="1"> + <widget class="QPushButton" name="camera_settings"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="maximum"> - <number>10000</number> + <property name="text"> + <string>Open</string> </property> </widget> </item> diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h index bffd19ee..63614ded 100644 --- a/ftnoir_tracker_pt/camera.h +++ b/ftnoir_tracker_pt/camera.h @@ -89,12 +89,13 @@ public: void start() override; void stop() override; + operator cv::VideoCapture&() { return *cap; } + protected: bool _get_frame(cv::Mat* frame) override; void _set_fps() override; void _set_res() override; void _set_device_index() override; - private: cv::VideoCapture* cap; }; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 4d55a422..dc0659e5 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -74,7 +74,12 @@ void Tracker_PT::run() const double dt = time.elapsed() * 1e-9; time.start(); cv::Mat frame; - const bool new_frame = camera.get_frame(dt, &frame); + bool new_frame; + + { + QMutexLocker l(&camera_mtx); + new_frame = camera.get_frame(dt, &frame); + } if (new_frame && !frame.empty()) { @@ -133,6 +138,7 @@ void Tracker_PT::run() void Tracker_PT::apply_settings() { qDebug()<<"Tracker:: Applying settings"; + QMutexLocker l(&camera_mtx); 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); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h index 3b9f1648..d0764933 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h @@ -17,6 +17,7 @@ #include "point_tracker.h" #include "pt_video_widget.h" #include "opentrack/timer.hpp" +#include "opentrack/opencv-camera-dialog.hpp" #include <QThread> #include <QMutex> @@ -30,11 +31,15 @@ #endif #include <vector> +class TrackerDialog_PT; + //----------------------------------------------------------------------------- // Constantly processes the tracking chain in a separate thread class Tracker_PT : public QThread, public ITracker { Q_OBJECT + friend class camera_dialog<Tracker_PT>; + friend class TrackerDialog_PT; public: Tracker_PT(); ~Tracker_PT() override; @@ -61,6 +66,7 @@ private: volatile int commands; + QMutex camera_mtx; CVCamera camera; PointExtractor point_extractor; PointTracker point_tracker; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 696f0b1b..5b17df5b 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -83,9 +83,15 @@ TrackerDialog_PT::TrackerDialog_PT() connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); + connect(ui.camera_settings, SIGNAL(pressed()), this, SLOT(camera_settings())); timer.start(100); } +void TrackerDialog_PT::camera_settings() +{ + open_camera_settings(tracker ? &static_cast<cv::VideoCapture&>(tracker->camera) : nullptr, s.camera_name, tracker ? &tracker->camera_mtx : nullptr); +} + void TrackerDialog_PT::startstop_trans_calib(bool start) { if (start) diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h index c1cd2e3b..b9aba4a6 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h @@ -18,12 +18,13 @@ #include "trans_calib.h" #include "pt_video_widget.h" #include "ui_FTNoIR_PT_Controls.h" +#include "opentrack/opencv-camera-dialog.hpp" #include <QTimer> //----------------------------------------------------------------------------- // The dialog that shows up when the user presses "Settings" -class TrackerDialog_PT : public ITrackerDialog +class TrackerDialog_PT : public ITrackerDialog, protected camera_dialog<Tracker_PT> { Q_OBJECT public: @@ -39,6 +40,7 @@ public slots: void startstop_trans_calib(bool start); void poll_tracker_info(); + void camera_settings(); private: settings_pt s; Tracker_PT* tracker; |