summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_aruco
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-08-24 22:33:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-08-24 22:33:52 +0200
commitafbec6a10b1e718fed134f61295e92f1e94770d4 (patch)
tree74de2479d5a8932c810a0cc37e48685fcd936fa5 /ftnoir_tracker_aruco
parentd446d36911a87eb18dd0a776b40c63f4bcc631c9 (diff)
Workaround camera frame-retrieval badness
Diffstat (limited to 'ftnoir_tracker_aruco')
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp14
1 files changed, 11 insertions, 3 deletions
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 <opencv2/opencv.hpp>
#include <opencv/highgui.h>
#include <vector>
+#include <cstdio>
#if defined(_WIN32) || defined(__WIN32)
#include <dshow.h>
@@ -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);