diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-10-19 14:44:43 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-10-19 14:46:33 +0200 |
commit | 0a518ad7d0aa94df529af2c39c2b34457b6d1015 (patch) | |
tree | 0f846576925b5677e51ea6a7aa99c8824eb86dfd /tracker-pt/camera.cpp | |
parent | ef5b07efe3517713e0343e01c806149a0a20b873 (diff) |
compat, tracker/pt: add warn_unused_result compat macro
Diffstat (limited to 'tracker-pt/camera.cpp')
-rw-r--r-- | tracker-pt/camera.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tracker-pt/camera.cpp b/tracker-pt/camera.cpp index f2fdb283..82f4a6fe 100644 --- a/tracker-pt/camera.cpp +++ b/tracker-pt/camera.cpp @@ -10,6 +10,8 @@ #include <string> #include <QDebug> +Camera::~Camera() {} + void Camera::set_device(const QString& name) { const int index = camera_name_to_index(name); @@ -52,7 +54,7 @@ void Camera::set_res(int x_res, int y_res) } } -bool Camera::get_info(CamInfo& ret) +DEFUN_WARN_UNUSED bool Camera::get_info(CamInfo& ret) { if (cam_info.res_x == 0 || cam_info.res_y == 0) { @@ -66,12 +68,16 @@ bool Camera::get_frame(double dt, cv::Mat* frame) { bool new_frame = _get_frame(frame); // measure fps of valid frames - static constexpr double dt_smoothing_const = 0.95; + static constexpr double RC = 1; // second + const double alpha = dt/(dt + RC); dt_valid += dt; if (new_frame) { - dt_mean = dt_smoothing_const * dt_mean + (1 - dt_smoothing_const) * dt_valid; - cam_info.fps = int(std::round(dt_mean > 1e-3 ? 1 / dt_mean : 0)); + if (dt_mean < 2e-3) + dt_mean = dt; + else + dt_mean = alpha * dt_mean + (1 - alpha) * dt_valid; + cam_info.fps = int(std::round(dt_mean > 2e-3 ? 1 / dt_mean : 0)); dt_valid = 0; } else |