From faab09446c5c26b96e59218abc34b1dc24727418 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jul 2015 10:20:51 +0200 Subject: pt: initial camera dialog --- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 198 ++++++++++++++----------- ftnoir_tracker_pt/camera.h | 3 +- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 8 +- ftnoir_tracker_pt/ftnoir_tracker_pt.h | 6 + ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 6 + 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 @@ 0 0 - 397 - 588 + 405 + 593 @@ -67,21 +67,8 @@ Camera settings - - - - - 0 - 0 - - - - Height - - - - - + + 0 @@ -89,15 +76,15 @@ - Device + FPS - camdevice_combo + fps_spin - - + + 0 @@ -105,7 +92,7 @@ - Desired capture width + Desired capture height px @@ -118,16 +105,16 @@ - - + + - + 0 0 - - 10 + + Field of view @@ -144,30 +131,31 @@ - - - - - 0 - 0 - + + + + ° - - Desired capture height + + - - px + + 10 - 2000 + 90 - - 10 + + + + + + - - + + 0 @@ -175,28 +163,51 @@ - FPS + Dynamic pose resolution - - fps_spin + + + + + + Dynamic pose timeout - - + + - + 0 0 - - Field of view + + Desired capture framerate + + + Hz + + + 2000 - - + + + + ms + + + 1 + + + 10000 + + + + + 0 @@ -204,69 +215,78 @@ - Dynamic pose resolution + Height - - - - + + + + + 0 + 0 + + + + Desired capture width - - - - - ° + px - - + + 2000 - + 10 - - 90 - - - + + 0 0 - - Desired capture framerate + + 10 - - Hz + + + + + + + 0 + 0 + - - 2000 + + Device + + + camdevice_combo - - + + - Dynamic pose timeout + Camera settings dialog - - - - ms - - - 1 + + + + + 0 + 0 + - - 10000 + + Open 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 #include @@ -30,11 +31,15 @@ #endif #include +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; + 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(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 //----------------------------------------------------------------------------- // The dialog that shows up when the user presses "Settings" -class TrackerDialog_PT : public ITrackerDialog +class TrackerDialog_PT : public ITrackerDialog, protected camera_dialog { 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; -- cgit v1.2.3