summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt/camera.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-11-23 15:11:26 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-11-23 15:11:49 +0100
commit0c6c39986c14761c08ce24677c3196a09a4b05ca (patch)
tree67869631be1cc52c65007dfa35e548fc8f62edca /ftnoir_tracker_pt/camera.cpp
parent0148f7dee879cd19a1518b483cf0d2ebc5ec1c5c (diff)
pt: get resolution when frame arrives
Diffstat (limited to 'ftnoir_tracker_pt/camera.cpp')
-rw-r--r--ftnoir_tracker_pt/camera.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/ftnoir_tracker_pt/camera.cpp b/ftnoir_tracker_pt/camera.cpp
index e762da82..b0cb32c9 100644
--- a/ftnoir_tracker_pt/camera.cpp
+++ b/ftnoir_tracker_pt/camera.cpp
@@ -119,13 +119,12 @@ void Camera::set_fps(int fps)
void Camera::set_res(int x_res, int y_res)
{
- if (cam_desired.res_x != x_res || cam_desired.res_y != y_res)
- {
- cam_desired.res_x = x_res;
- cam_desired.res_y = y_res;
- _set_res();
- _set_fps();
- }
+ if (cam_desired.res_x != x_res || cam_desired.res_y != y_res)
+ {
+ cam_desired.res_x = x_res;
+ cam_desired.res_y = y_res;
+ _set_res();
+ }
}
bool Camera::get_frame(float dt, cv::Mat* frame)
@@ -174,18 +173,20 @@ void CVCamera::stop()
bool CVCamera::_get_frame(Mat* frame)
{
if (cap && cap->isOpened())
- {
+ {
Mat img;
for (int i = 0; i < 100 && !cap->read(img); i++)
;;
- if (img.empty())
- return false;
+ if (img.empty())
+ return false;
- *frame = img;
- return true;
- }
- return false;
+ *frame = img;
+ cam_info.res_x = img.cols;
+ cam_info.res_y = img.rows;
+ return true;
+ }
+ return false;
}
void CVCamera::_set_fps()
@@ -195,13 +196,11 @@ void CVCamera::_set_fps()
void CVCamera::_set_res()
{
- if (cap)
- {
+ if (cap)
+ {
cap->set(CV_CAP_PROP_FRAME_WIDTH, cam_desired.res_x);
cap->set(CV_CAP_PROP_FRAME_HEIGHT, cam_desired.res_y);
- cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH);
- cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT);
- }
+ }
}
void CVCamera::_set_device_index()
{