From 2cd3d41a6b35ea978ebf797dcc10a800bd78c658 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 25 Sep 2014 01:16:15 +0200 Subject: gain progress --- facetracknoir/gain-control.hpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp index dcaee692..005ef9cc 100644 --- a/facetracknoir/gain-control.hpp +++ b/facetracknoir/gain-control.hpp @@ -8,6 +8,8 @@ #include #include +#include + #include "timer.hpp" #include @@ -43,16 +45,14 @@ namespace detail { class Gain { private: static constexpr bool use_box_filter = true; - static constexpr int box_size = 32 / 640.; + static constexpr int box_size = 16 / 640.; static constexpr double control_upper_bound = 1.0; // XXX FIXME implement for logitech crapola - static constexpr int GAIN_HISTORY_COUNT = 15, GAIN_HISTORY_EVERY_MS = 115; + static constexpr int GAIN_HISTORY_COUNT = 90, GAIN_HISTORY_EVERY_MS = 85; int control; double step, eps; - std::deque means_history; - cv::Mat last_frame; - + std::deque means_history; Timer debug_timer, history_timer; typedef unsigned char px; @@ -156,19 +156,30 @@ public: debug_timer.start(); qDebug() << "---- gain:" << "mean" << mu << "variance" << var; - for (int i = 0; i < means_history.size(); i++) - qDebug() << "cov" << i << means_history[i]; - } - - if (last_frame.cols != frame.cols || last_frame.rows != frame.rows) - { - last_frame = frame; - means_history.clear(); + + const int sz = means_history.size(); + + if (sz) + fprintf(stderr, "covs: "); + + for (int i = 0; i < sz; i++) + { + if (means_history[i].rows != frame.rows || means_history[i].cols != frame.cols) + { + means_history.clear(); + qDebug() << "\n!!! resolution reset"; + break; + } + fprintf(stderr, "%f ", get_covariance(frame, means_history[i])); + } + + if (sz) + fprintf(stderr, "\n"); } if (GAIN_HISTORY_COUNT > means_history.size() && history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) { - means_history.push_front(get_covariance(frame, last_frame)); + means_history.push_front(frame); if (GAIN_HISTORY_COUNT == means_history.size()) means_history.pop_back(); -- cgit v1.2.3