summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-06 10:01:24 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-06 10:47:44 +0200
commit2e7407a094c74b629cbe8348e9007c6373e476fe (patch)
tree10049a7d1eb41d442648741b77846119e95096bc /ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
parent81d2ffa8b95f0dce0a89784d08fe3ba9501cca1e (diff)
aruco: use camera settings class
Diffstat (limited to 'ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp')
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp43
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);
+}