From 159ccb4bca654acdb101cfa1fd3491d1f7964743 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 17 Sep 2016 16:11:44 +0200 Subject: tracker/{pt,aruco}: enable camera dialog Suggested-by: MathijsG Issue: #454 --- tracker-aruco/aruco-trackercontrols.ui | 79 +++++++++------ tracker-aruco/ftnoir_tracker_aruco.cpp | 39 ++++++- tracker-aruco/ftnoir_tracker_aruco.h | 2 + tracker-pt/FTNoIR_PT_Controls.ui | 174 ++++++++++++++++++++------------ tracker-pt/ftnoir_tracker_pt_dialog.cpp | 39 ++++++- tracker-pt/ftnoir_tracker_pt_dialog.h | 3 + 6 files changed, 231 insertions(+), 105 deletions(-) diff --git a/tracker-aruco/aruco-trackercontrols.ui b/tracker-aruco/aruco-trackercontrols.ui index ed1c1edf..71bd1c1c 100644 --- a/tracker-aruco/aruco-trackercontrols.ui +++ b/tracker-aruco/aruco-trackercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 485 - 180 + 474 + 208 @@ -23,13 +23,6 @@ Tracker settings - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -47,13 +40,6 @@ - - - - Resolution - - - @@ -84,6 +70,13 @@ + + + + Resolution + + + @@ -131,15 +124,18 @@ - - - - - 0 - 0 - + + + + Qt::Vertical - + + + 20 + 0 + + + @@ -160,18 +156,28 @@ + + + + + 0 + 0 + + + + - - - Qt::Vertical + + + + 0 + 0 + - - - 20 - 0 - + + Camera settings - + @@ -261,6 +267,13 @@ + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index d59ac9be..81a2e176 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -7,13 +7,15 @@ #include "ftnoir_tracker_aruco.h" #include "api/plugin-api.hpp" +#include "compat/camera-names.hpp" +#include "compat/sleep.hpp" +#include "compat/pi-constant.hpp" +#include "cv/video-property-page.hpp" + #include #include #include #include -#include "compat/camera-names.hpp" -#include "compat/sleep.hpp" -#include "compat/pi-constant.hpp" #include #include @@ -425,7 +427,38 @@ TrackerControls::TrackerControls() connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.btn_calibrate, SIGNAL(clicked()), this, SLOT(toggleCalibrate())); connect(this, SIGNAL(destroyed()), this, SLOT(cleanupCalib())); + connect(&calib_timer, SIGNAL(timeout()), this, SLOT(update_tracker_calibration())); + connect(ui.cameraName, &QComboBox::currentTextChanged, this, &TrackerControls::set_camera_settings_available); + set_camera_settings_available(ui.cameraName->currentText()); + connect(ui.camera_settings, &QPushButton::clicked, this, &TrackerControls::show_camera_settings); +} + + +void TrackerControls::set_camera_settings_available(const QString& camera_name) +{ +#ifdef _WIN32 + const bool avail = camera_name != QStringLiteral("PS3Eye Camera"); + ui.camera_settings->setEnabled(avail); +#elif defined(__linux) + (void)camera_name; +#else + (void)camera_name; + ui.camera_settings->setEnabled(false); +#endif +} + +void TrackerControls::show_camera_settings() +{ + const int idx = ui.cameraName->currentIndex(); + if (tracker) + { + cv::VideoCapture& cap = tracker->camera; + if (cap.isOpened()) + video_property_page::show_from_capture(cap, idx); + } + else + video_property_page::show(idx); } void TrackerControls::toggleCalibrate() diff --git a/tracker-aruco/ftnoir_tracker_aruco.h b/tracker-aruco/ftnoir_tracker_aruco.h index 101060f7..41063ca0 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.h +++ b/tracker-aruco/ftnoir_tracker_aruco.h @@ -125,6 +125,8 @@ private slots: void toggleCalibrate(); void cleanupCalib(); void update_tracker_calibration(); + void set_camera_settings_available(const QString& camera_name); + void show_camera_settings(); }; class TrackerDll : public Metadata diff --git a/tracker-pt/FTNoIR_PT_Controls.ui b/tracker-pt/FTNoIR_PT_Controls.ui index 2675f1a4..02eb05fb 100644 --- a/tracker-pt/FTNoIR_PT_Controls.ui +++ b/tracker-pt/FTNoIR_PT_Controls.ui @@ -10,7 +10,7 @@ 0 0 424 - 568 + 586 @@ -67,24 +67,37 @@ Camera settings - - + + - + 0 0 - - FPS + + 10 - - fps_spin + + + + + + ° + + + + + + 10 + + + 90 - - + + 0 @@ -92,12 +105,12 @@ - Width + Diagonal field of view - - + + 0 @@ -105,23 +118,23 @@ - Diagonal field of view + Width - - - - ° - - - + + + + + 0 + 0 + - - 10 + + FPS - - 90 + + fps_spin @@ -180,29 +193,25 @@ - - + + - + 0 0 - - Dynamic pose resolution + + Desired capture width - - - - - ms - - - 1 + px - 10000 + 2000 + + + 10 @@ -219,25 +228,29 @@ - - + + + + ms + + + 1 + + + 10000 + + + + + - + 0 0 - - Desired capture width - - - px - - - 2000 - - - 10 + + Dynamic pose resolution @@ -257,16 +270,23 @@ - - + + - + 0 0 - - 10 + + Open + + + + + + + Camera settings (when available) @@ -1104,8 +1124,14 @@ - + + + + 0 + 0 + + Status @@ -1117,13 +1143,6 @@ - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -1166,6 +1185,29 @@ + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 0 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 4e1df41b..c722e9a7 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -7,6 +7,7 @@ */ #include "ftnoir_tracker_pt_dialog.h" +#include "cv/video-property-page.hpp" #include "compat/camera-names.hpp" #include @@ -71,6 +72,10 @@ TrackerDialog_PT::TrackerDialog_PT() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + connect(ui.camdevice_combo, &QComboBox::currentTextChanged, this, &TrackerDialog_PT::set_camera_settings_available); + set_camera_settings_available(ui.camdevice_combo->currentText()); + connect(ui.camera_settings, &QPushButton::clicked, this, &TrackerDialog_PT::show_camera_settings); + connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); timer.start(250); @@ -97,9 +102,9 @@ void TrackerDialog_PT::startstop_trans_calib(bool start) 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]; + s.t_MH_x = int(tmp[0]); + s.t_MH_y = int(tmp[1]); + s.t_MH_z = int(tmp[2]); } } ui.tx_spin->setEnabled(!start); @@ -144,6 +149,34 @@ void TrackerDialog_PT::poll_tracker_info() } } +void TrackerDialog_PT::set_camera_settings_available(const QString& camera_name) +{ +#ifdef _WIN32 + const bool avail = camera_name != QStringLiteral("PS3Eye Camera"); + ui.camera_settings->setEnabled(avail); +#elif defined(__linux) + (void)camera_name; +#else + (void)camera_name; + ui.camera_settings->setEnabled(false); +#endif +} + +void TrackerDialog_PT::show_camera_settings() +{ + const int idx = ui.camdevice_combo->currentIndex(); + if (tracker) + { + cv::VideoCapture* cap = tracker->camera; + if (cap && cap->isOpened()) + { + video_property_page::show_from_capture(*cap, idx); + } + } + else + video_property_page::show(idx); +} + void TrackerDialog_PT::trans_calib_step() { if (tracker) diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.h b/tracker-pt/ftnoir_tracker_pt_dialog.h index b57e32c3..b5adea51 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.h +++ b/tracker-pt/ftnoir_tracker_pt_dialog.h @@ -32,6 +32,9 @@ public slots: void startstop_trans_calib(bool start); void trans_calib_step(); void poll_tracker_info(); + void set_camera_settings_available(const QString& camera_name); + void show_camera_settings(); + private: settings_pt s; Tracker_PT* tracker; -- cgit v1.2.3