summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/module/camera.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-02-16 11:07:57 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-02-16 12:55:48 +0100
commite42a0361c986c39a9456226f1465a7fb721fe111 (patch)
tree67120790e85b977be6c5a5578293a6b3c31888af /tracker-pt/module/camera.cpp
parent5a8c8f1d45997165396502e9404ed371e5ae59fe (diff)
tracker/{pt,wii}: simplify api
Remove useless abstract member functions, simplify some. Issue: #718
Diffstat (limited to 'tracker-pt/module/camera.cpp')
-rw-r--r--tracker-pt/module/camera.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp
index ba4583da..9c62e8a3 100644
--- a/tracker-pt/module/camera.cpp
+++ b/tracker-pt/module/camera.cpp
@@ -36,19 +36,18 @@ void Camera::show_camera_settings()
{
const int idx = camera_name_to_index(s.camera_name);
- if (bool(*this))
+ if (cap && cap->isOpened())
video_property_page::show_from_capture(*cap, idx);
else
- {
video_property_page::show(idx);
- }
}
Camera::result Camera::get_info() const
{
if (cam_info.res_x == 0 || cam_info.res_y == 0)
- return result(false, pt_camera_info());
- return result(true, cam_info);
+ return { false, pt_camera_info() };
+ else
+ return { true, cam_info };
}
Camera::result Camera::get_frame(pt_frame& frame_)
@@ -82,7 +81,7 @@ Camera::result Camera::get_frame(pt_frame& frame_)
return result(false, pt_camera_info());
}
-pt_camera_open_status Camera::start(int idx, int fps, int res_x, int res_y)
+bool Camera::start(int idx, int fps, int res_x, int res_y)
{
if (idx >= 0 && fps >= 0 && res_x >= 0 && res_y >= 0)
{
@@ -110,7 +109,7 @@ pt_camera_open_status Camera::start(int idx, int fps, int res_x, int res_y)
if (cam_desired.fps)
cap->set(cv::CAP_PROP_FPS, cam_desired.fps);
- if (cap->isOpened() && cap->grab())
+ if (cap->isOpened())
{
cam_info = pt_camera_info();
active_name = QString();
@@ -118,22 +117,24 @@ pt_camera_open_status Camera::start(int idx, int fps, int res_x, int res_y)
dt_mean = 0;
active_name = desired_name;
- t.start();
+ cv::Mat tmp;
- return cam_open_ok_change;
- }
- else
- {
- stop();
- return cam_open_error;
+ if (_get_frame(tmp))
+ {
+ t.start();
+ return true;
+ }
}
+
+ cap = nullptr;
+ return false;
}
- return cam_open_ok_no_change;
+ return true;
}
stop();
- return cam_open_error;
+ return false;
}
void Camera::stop()