From 21a3c7028b51378577410028a0394753ba45c2e7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 May 2022 21:43:30 +0200 Subject: tracker/trackhat: add back gain slider --- tracker-trackhat/camera.cpp | 2 +- tracker-trackhat/dialog.cpp | 20 +++++++++++--- tracker-trackhat/dialog.ui | 59 +++++++++++++++++++++++++++++++++++++----- tracker-trackhat/lang/nl_NL.ts | 4 +++ tracker-trackhat/lang/ru_RU.ts | 4 +++ tracker-trackhat/lang/stub.ts | 4 +++ tracker-trackhat/lang/zh_CN.ts | 4 +++ tracker-trackhat/settings.cpp | 12 ++------- tracker-trackhat/trackhat.hpp | 7 +++-- 9 files changed, 90 insertions(+), 26 deletions(-) diff --git a/tracker-trackhat/camera.cpp b/tracker-trackhat/camera.cpp index dd1f3d3a..d518621f 100644 --- a/tracker-trackhat/camera.cpp +++ b/tracker-trackhat/camera.cpp @@ -54,7 +54,7 @@ trackhat_camera::trackhat_camera() s.set_raii_dtor_state(false); t.set_raii_dtor_state(false); - for (auto* slider : { &t.exposure, /*&t.threshold,*/ }) + for (auto* slider : { &t.exposure, &t.gain, /*&t.threshold,*/ }) { QObject::connect(slider, options::value_::value_changed(), &sig, &trackhat_impl::setting_receiver::settings_changed, diff --git a/tracker-trackhat/dialog.cpp b/tracker-trackhat/dialog.cpp index cfff03ba..02ecc637 100644 --- a/tracker-trackhat/dialog.cpp +++ b/tracker-trackhat/dialog.cpp @@ -36,16 +36,24 @@ trackhat_dialog::trackhat_dialog() tie_setting(t.exposure, ui.exposure_slider); ui.exposure_label->setValue((int)*t.exposure); - ui.point_filter_limit_label->setValue(*t.point_filter_limit); connect(&t.exposure, value_::value_changed(), ui.exposure_label, [this] { ui.exposure_label->setValue((int)*t.exposure); }, Qt::QueuedConnection); - connect(&t.point_filter_limit, value_::value_changed(), ui.point_filter_limit_label, - [this] { ui.point_filter_limit_label->setValue(*t.point_filter_limit); }, Qt::QueuedConnection); - // threshold + // gain + + ui.gain_slider->setMinimum((int)t.gain->min()); + ui.gain_slider->setMaximum((int)t.gain->max()); + + tie_setting(t.gain, ui.gain_slider); + ui.gain_label->setValue((int)*t.gain); + + connect(&t.gain, value_::value_changed(), ui.gain_label, + [this] { ui.gain_label->setValue((int)*t.gain); }, Qt::QueuedConnection); #if 0 + // threshold + tie_setting(t.threshold, ui.threshold_slider); ui.threshold_label->setValue((int)*t.threshold); @@ -57,6 +65,10 @@ trackhat_dialog::trackhat_dialog() // point filter + ui.point_filter_limit_label->setValue(*t.point_filter_limit); + connect(&t.point_filter_limit, value_::value_changed(), ui.point_filter_limit_label, + [this] { ui.point_filter_limit_label->setValue(*t.point_filter_limit); }, Qt::QueuedConnection); + tie_setting(t.enable_point_filter, ui.enable_point_filter); tie_setting(t.point_filter_coefficient, ui.point_filter_slider); ui.point_filter_label->setValue(*t.point_filter_coefficient); diff --git a/tracker-trackhat/dialog.ui b/tracker-trackhat/dialog.ui index 30cf78db..927cb945 100644 --- a/tracker-trackhat/dialog.ui +++ b/tracker-trackhat/dialog.ui @@ -7,7 +7,7 @@ 0 0 365 - 429 + 460 @@ -30,6 +30,25 @@ Camera + + + + + 0 + 0 + + + + 239 + + + 10 + + + Qt::Horizontal + + + @@ -49,8 +68,22 @@ - - + + + + Exposure + + + + + + + Gain + + + + + 0 @@ -68,10 +101,22 @@ - - - - Exposure + + + + Qt::NoFocus + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + 999 diff --git a/tracker-trackhat/lang/nl_NL.ts b/tracker-trackhat/lang/nl_NL.ts index 73e375fc..8d29d6c4 100644 --- a/tracker-trackhat/lang/nl_NL.ts +++ b/tracker-trackhat/lang/nl_NL.ts @@ -123,6 +123,10 @@ Deadzone + + Gain + + trackhat_module diff --git a/tracker-trackhat/lang/ru_RU.ts b/tracker-trackhat/lang/ru_RU.ts index 091c2101..f2920f58 100644 --- a/tracker-trackhat/lang/ru_RU.ts +++ b/tracker-trackhat/lang/ru_RU.ts @@ -123,6 +123,10 @@ Deadzone + + Gain + + trackhat_module diff --git a/tracker-trackhat/lang/stub.ts b/tracker-trackhat/lang/stub.ts index 548138a3..0d8616c8 100644 --- a/tracker-trackhat/lang/stub.ts +++ b/tracker-trackhat/lang/stub.ts @@ -123,6 +123,10 @@ Status: %1 points detected. BAD! + + Gain + + trackhat_module diff --git a/tracker-trackhat/lang/zh_CN.ts b/tracker-trackhat/lang/zh_CN.ts index cb881fa8..c8c9ed4f 100644 --- a/tracker-trackhat/lang/zh_CN.ts +++ b/tracker-trackhat/lang/zh_CN.ts @@ -123,6 +123,10 @@ Deadzone + + Gain + + trackhat_module diff --git a/tracker-trackhat/settings.cpp b/tracker-trackhat/settings.cpp index 71ab17d2..955d6511 100644 --- a/tracker-trackhat/settings.cpp +++ b/tracker-trackhat/settings.cpp @@ -7,14 +7,6 @@ namespace trackhat_impl { trackhat_settings::trackhat_settings() : opts{"tracker-trackhat"} { } -int trackhat_settings::effective_exposure() const -{ - return std::clamp((int)*exposure, min_exposure, max_exposure); -} -int trackhat_settings::effective_gain() const -{ - return min_gain + std::clamp((int)*exposure - max_exposure, 0, max_gain - min_gain); -} void setting_receiver::settings_changed() { @@ -92,12 +84,12 @@ void trackhat_camera::set_pt_options() bool trackhat_camera::init_regs() { - auto exp = (uint8_t)t.effective_exposure(); + auto exp = (uint8_t)t.exposure; auto exp2 = (uint8_t)(exp == 0xff ? 0xf0 : 0xff); auto thres = (uint8_t)0xfe; auto thres2 = (uint8_t)3; - auto gain = (uint8_t)t.effective_gain(); + auto gain = (uint8_t)t.gain; auto gain_c = (uint8_t)(gain/0x10); gain %= 0x10; gain_c %= 4; diff --git a/tracker-trackhat/trackhat.hpp b/tracker-trackhat/trackhat.hpp index d94841d2..b80e4c2f 100644 --- a/tracker-trackhat/trackhat.hpp +++ b/tracker-trackhat/trackhat.hpp @@ -30,13 +30,12 @@ TH_ErrorCode log_error(TH_ErrorCode error, const char* source, const char* file, struct trackhat_settings : opts { - static constexpr int min_gain = 16, max_gain = 47, + static constexpr int min_gain = 1, max_gain = 47, min_exposure = 0x10, max_exposure = 0xff; static constexpr int num_exposure_steps = max_gain + max_exposure - min_gain - min_exposure; - int effective_exposure() const; - int effective_gain() const; trackhat_settings(); - value exposure{b, "exposure", {min_exposure, min_exposure, max_exposure + max_gain - min_gain}}; + value exposure{b, "exposure", {min_exposure + max_exposure*2/3, min_exposure, max_exposure}}; + value gain{b, "gain", {min_gain + max_gain*2/3, min_gain, max_gain}}; //value threshold{b, "threshold", {0x97, 64, 0xfe}}; value model{b, "model", model_mini_clip_left}; value min_pt_size{b, "min-point-size", 10}; -- cgit v1.2.3