summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/camera.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-12-08 05:34:59 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-12-08 05:35:04 +0100
commitbe051e0b0d1207c2cc1932e647ddfeeb16b0b3fe (patch)
tree02a5e7c8fcb7b3c7a2cac88ab6057e8fe32e90d0 /tracker-pt/camera.h
parent57d8fa7661c97fb9f02279060694a0073e7cc8b5 (diff)
tracker/pt: fix camera Hz always the default value
Diffstat (limited to 'tracker-pt/camera.h')
-rw-r--r--tracker-pt/camera.h33
1 files changed, 10 insertions, 23 deletions
diff --git a/tracker-pt/camera.h b/tracker-pt/camera.h
index 75c5faa4..3f5a8f43 100644
--- a/tracker-pt/camera.h
+++ b/tracker-pt/camera.h
@@ -7,6 +7,9 @@
#pragma once
+#undef NDEBUG
+#include <cassert>
+
#include "compat/util.hpp"
#include <opencv2/core/core.hpp>
@@ -17,7 +20,7 @@
struct CamInfo
{
- CamInfo() : res_x(0), res_y(0), fps(0), idx(-1) {}
+ CamInfo() : res_x(0), res_y(0), fps(-1), idx(-1) {}
int res_x;
int res_y;
@@ -29,16 +32,9 @@ class Camera final
{
public:
Camera() : dt_valid(0), dt_mean(0) {}
- ~Camera();
- void start();
+ DEFUN_WARN_UNUSED bool start(int idx, int fps, int res_x, int res_y);
void stop();
- void restart() { stop(); start(); }
-
- // calls corresponding template methods and reinitializes frame rate calculation
- void set_device(const QString& name);
- void set_fps(int fps);
- void set_res(int x_res, int y_res);
DEFUN_WARN_UNUSED bool get_frame(double dt, cv::Mat* frame);
DEFUN_WARN_UNUSED bool get_info(CamInfo &ret);
@@ -47,9 +43,9 @@ public:
QString get_desired_name() const;
QString get_active_name() const;
- cv::VideoCapture& operator*() { return *cap; }
- const cv::VideoCapture& operator*() const { return *cap; }
- cv::VideoCapture* operator->() { return cap.get(); }
+ 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(); }
@@ -65,19 +61,10 @@ private:
struct camera_deleter final
{
- void operator()(cv::VideoCapture* cap)
- {
- if (cap)
- {
- if (cap->isOpened())
- cap->release();
- static const std::default_delete<cv::VideoCapture> deleter;
- deleter(cap);
- }
- }
+ void operator()(cv::VideoCapture* cap);
};
using camera_ptr = std::unique_ptr<cv::VideoCapture, camera_deleter>;
- std::unique_ptr<cv::VideoCapture, camera_deleter> cap;
+ camera_ptr cap;
};