summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-20 08:09:44 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-20 08:09:44 +0200
commite9b42b3d4eabd1d4fbcdfb990c26f286259be8d2 (patch)
treef48d11163626a298285863b217ea79e1d7b84c35
parent8bf58b412d2b9c5cd3f1e1215c5ae9462d494888 (diff)
camera: more robust get_info()
If camera was barely created and there's no info, grab the first frame to get resolution data.
-rw-r--r--ftnoir_tracker_pt/camera.cpp10
-rw-r--r--ftnoir_tracker_pt/camera.h4
2 files changed, 12 insertions, 2 deletions
diff --git a/ftnoir_tracker_pt/camera.cpp b/ftnoir_tracker_pt/camera.cpp
index 9168a3e4..2e745f2a 100644
--- a/ftnoir_tracker_pt/camera.cpp
+++ b/ftnoir_tracker_pt/camera.cpp
@@ -61,6 +61,16 @@ void Camera::set_res(int x_res, int y_res)
}
}
+CamInfo Camera::get_info()
+{
+ if (cam_info.res_x == 0 || cam_info.res_y == 0)
+ {
+ cv::Mat tmp;
+ _get_frame(&tmp);
+ }
+ return cam_info;
+}
+
bool Camera::get_frame(float dt, cv::Mat* frame)
{
bool new_frame = _get_frame(frame);
diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h
index 63614ded..2c42652a 100644
--- a/ftnoir_tracker_pt/camera.h
+++ b/ftnoir_tracker_pt/camera.h
@@ -54,8 +54,8 @@ public:
bool get_frame(float dt, cv::Mat* frame);
// WARNING: returned references are valid as long as object
- const CamInfo& get_info() const { return cam_info; }
- const CamInfo& get_desired() const { return cam_desired; }
+ CamInfo get_info();
+ CamInfo get_desired() const { return cam_desired; }
protected:
// get a frame from the camera