summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/module
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
parent5a8c8f1d45997165396502e9404ed371e5ae59fe (diff)
tracker/{pt,wii}: simplify api
Remove useless abstract member functions, simplify some. Issue: #718
Diffstat (limited to 'tracker-pt/module')
-rw-r--r--tracker-pt/module/camera.cpp33
-rw-r--r--tracker-pt/module/camera.h6
2 files changed, 18 insertions, 21 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()
diff --git a/tracker-pt/module/camera.h b/tracker-pt/module/camera.h
index 96234840..79e3dca0 100644
--- a/tracker-pt/module/camera.h
+++ b/tracker-pt/module/camera.h
@@ -26,7 +26,7 @@ struct Camera final : pt_camera
{
Camera(const QString& module_name);
- pt_camera_open_status start(int idx, int fps, int res_x, int res_y) override;
+ bool start(int idx, int fps, int res_x, int res_y) override;
void stop() override;
result get_frame(pt_frame& Frame) override;
@@ -36,8 +36,6 @@ struct Camera final : pt_camera
QString get_desired_name() const override;
QString get_active_name() const override;
- operator bool() const override { return cap && cap->isOpened(); }
-
void set_fov(double value) override { fov = value; }
void show_camera_settings() override;
@@ -45,9 +43,7 @@ private:
warn_result_unused bool _get_frame(cv::Mat& Frame);
double dt_mean = 0, fov = 30;
-
Timer t;
-
pt_camera_info cam_info;
pt_camera_info cam_desired;
QString desired_name, active_name;