From afbec6a10b1e718fed134f61295e92f1e94770d4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 24 Aug 2013 22:33:52 +0200 Subject: Workaround camera frame-retrieval badness --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ftnoir_tracker_aruco') diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 152c1e32..6fff39d3 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #if defined(_WIN32) || defined(__WIN32) #include @@ -185,12 +186,19 @@ void Tracker::run() aruco::MarkerDetector detector; detector.setDesiredSpeed(3); detector.setThresholdParams(11, 5); - cv::Mat color, grayscale, rvec, tvec; + cv::Mat color, color_, grayscale, rvec, tvec; + + if (!camera.isOpened()) + { + fprintf(stderr, "aruco tracker: can't open camera\n"); + return; + } while (!stop) { - if (!camera.read(color)) - break; + if (!camera.read(color_)) + continue; + color_.copyTo(color); cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); -- cgit v1.2.3