diff options
Diffstat (limited to 'ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp')
-rw-r--r-- | ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ca8cea9e..70af379d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -101,26 +101,31 @@ void Tracker::run() fps = 200; break; } - camera = cv::VideoCapture(camera_name_to_index(s.camera_name)); - if (res.width) + { - camera.set(cv::CAP_PROP_FRAME_WIDTH, res.width); - camera.set(cv::CAP_PROP_FRAME_HEIGHT, res.height); + QMutexLocker l(&camera_mtx); + + camera = cv::VideoCapture(camera_name_to_index(s.camera_name)); + if (res.width) + { + camera.set(cv::CAP_PROP_FRAME_WIDTH, res.width); + camera.set(cv::CAP_PROP_FRAME_HEIGHT, res.height); + } + if (fps) + camera.set(cv::CAP_PROP_FPS, fps); + + if (!camera.isOpened()) + { + qDebug() << "aruco tracker: can't open camera"; + return; + } } - if (fps) - camera.set(cv::CAP_PROP_FPS, fps); aruco::MarkerDetector detector; detector.setDesiredSpeed(3); cv::Rect last_roi(65535, 65535, 0, 0); - if (!camera.isOpened()) - { - fprintf(stderr, "aruco tracker: can't open camera\n"); - return; - } - auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); double cur_fps = 0; @@ -133,8 +138,12 @@ void Tracker::run() while (!stop) { cv::Mat color; - if (!camera.read(color)) - continue; + { + QMutexLocker l(&camera_mtx); + + if (!camera.read(color)) + continue; + } cv::Mat grayscale; cv::cvtColor(color, grayscale, cv::COLOR_RGB2GRAY); @@ -391,6 +400,7 @@ TrackerControls::TrackerControls() 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.camera_settings, SIGNAL(pressed()), this, SLOT(camera_settings())); } void TrackerControls::toggleCalibrate() @@ -440,3 +450,8 @@ void TrackerControls::doCancel() s.b->reload(); this->close(); } + +void TrackerControls::camera_settings() +{ + open_camera_settings(tracker ? &tracker->camera : nullptr, s.camera_name, tracker ? &tracker->camera_mtx : nullptr); +} |