diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-11 19:03:10 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-11 19:03:10 +0100 |
commit | fbd961775001228f6ffd9cc3bf09aa2de610aeae (patch) | |
tree | b54c35357ea0ec0fbf2d78d14a17bcf4047c9488 /tracker-pt/camera.h | |
parent | 71374d0b5cd456e25252775fdec89fe3cf2aa5e6 (diff) |
tracker/pt: allow for reuse
Issue: #718
This allows for replacing the camera and point extractor code. See
`module.cpp' and `pt-api.hpp`.
Diffstat (limited to 'tracker-pt/camera.h')
-rw-r--r-- | tracker-pt/camera.h | 56 |
1 files changed, 18 insertions, 38 deletions
diff --git a/tracker-pt/camera.h b/tracker-pt/camera.h index 076e6847..7a4f75c4 100644 --- a/tracker-pt/camera.h +++ b/tracker-pt/camera.h @@ -8,9 +8,7 @@ #pragma once #include "compat/ndebug-guard.hpp" - -#undef NDEBUG -#include <cassert> +#include "pt-api.hpp" #include "compat/util.hpp" #include "compat/timer.hpp" @@ -22,55 +20,35 @@ #include <tuple> #include <QString> -struct CamInfo final -{ - CamInfo() : fov(0), fps(0), res_x(0), res_y(0), idx(-1) {} - double get_focal_length() const; - - double fov; - double fps; - - int res_x; - int res_y; - int idx; -}; - -struct Camera final +struct Camera final : pt_camera { - enum open_status : unsigned { open_error, open_ok_no_change, open_ok_change }; + Camera(); - using result = std::tuple<bool, CamInfo>; + pt_camera_open_status start(int idx, int fps, int res_x, int res_y) override; + void stop() override; - Camera() : dt_mean(0), fov(0) {} + result get_frame(cv::Mat& frame) override; + result get_info() const override; - warn_result_unused open_status start(int idx, int fps, int res_x, int res_y); - void stop(); + pt_camera_info get_desired() const override { return cam_desired; } + QString get_desired_name() const override; + QString get_active_name() const override; - warn_result_unused result get_frame(cv::Mat& frame); - warn_result_unused result get_info() const; + operator bool() const override { return cap && cap->isOpened(); } - CamInfo get_desired() const { return cam_desired; } - QString get_desired_name() const; - QString get_active_name() const; + void set_fov(double value) override { fov = value; } - cv::VideoCapture& operator*() { assert(cap); return *cap; } - const cv::VideoCapture& operator*() const { assert(cap); return *cap; } - cv::VideoCapture* operator->() { assert(cap); return cap.get(); } - const cv::VideoCapture* operator->() const { return cap.get(); } - operator bool() const { return cap && cap->isOpened(); } - - void set_fov(double value) { fov = value; } + void show_camera_settings() override; private: warn_result_unused bool _get_frame(cv::Mat& frame); - double dt_mean; - double fov; + double dt_mean, fov; Timer t; - CamInfo cam_info; - CamInfo cam_desired; + pt_camera_info cam_info; + pt_camera_info cam_desired; QString desired_name, active_name; struct camera_deleter final @@ -82,5 +60,7 @@ private: camera_ptr cap; + pt_settings s; + static constexpr double dt_eps = 1./384; }; |