summaryrefslogtreecommitdiffhomepage
path: root/tracker-trackhat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-05-26 21:43:30 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-06-05 14:44:25 +0200
commit21a3c7028b51378577410028a0394753ba45c2e7 (patch)
tree15542f096b002c0ee046d52e399033c09bc37e2d /tracker-trackhat
parentf045b65d7e3f2d65195e02c4b6097f2c9886222c (diff)
tracker/trackhat: add back gain slider
Diffstat (limited to 'tracker-trackhat')
-rw-r--r--tracker-trackhat/camera.cpp2
-rw-r--r--tracker-trackhat/dialog.cpp20
-rw-r--r--tracker-trackhat/dialog.ui59
-rw-r--r--tracker-trackhat/lang/nl_NL.ts4
-rw-r--r--tracker-trackhat/lang/ru_RU.ts4
-rw-r--r--tracker-trackhat/lang/stub.ts4
-rw-r--r--tracker-trackhat/lang/zh_CN.ts4
-rw-r--r--tracker-trackhat/settings.cpp12
-rw-r--r--tracker-trackhat/trackhat.hpp7
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<options::slider_value>(),
&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<slider_value>(), ui.exposure_label,
[this] { ui.exposure_label->setValue((int)*t.exposure); }, Qt::QueuedConnection);
- connect(&t.point_filter_limit, value_::value_changed<slider_value>(), 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<slider_value>(), 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<slider_value>(), 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 @@
<x>0</x>
<y>0</y>
<width>365</width>
- <height>429</height>
+ <height>460</height>
</rect>
</property>
<property name="minimumSize">
@@ -30,6 +30,25 @@
<string>Camera</string>
</property>
<layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="1">
+ <widget class="QSlider" name="exposure_slider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximum">
+ <number>239</number>
+ </property>
+ <property name="pageStep">
+ <number>10</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
<item row="0" column="2">
<widget class="QSpinBox" name="exposure_label">
<property name="focusPolicy">
@@ -49,8 +68,22 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QSlider" name="exposure_slider">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Exposure</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Gain</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSlider" name="gain_slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -68,10 +101,22 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Exposure</string>
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="gain_label">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::NoButtons</enum>
+ </property>
+ <property name="maximum">
+ <number>999</number>
</property>
</widget>
</item>
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 @@
<source>Deadzone</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>trackhat_module</name>
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 @@
<source>Deadzone</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>trackhat_module</name>
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 @@
<source>Status: %1 points detected. BAD!</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>trackhat_module</name>
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 @@
<source>Deadzone</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>trackhat_module</name>
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<slider_value> exposure{b, "exposure", {min_exposure, min_exposure, max_exposure + max_gain - min_gain}};
+ value<slider_value> exposure{b, "exposure", {min_exposure + max_exposure*2/3, min_exposure, max_exposure}};
+ value<slider_value> gain{b, "gain", {min_gain + max_gain*2/3, min_gain, max_gain}};
//value<slider_value> threshold{b, "threshold", {0x97, 64, 0xfe}};
value<model_type> model{b, "model", model_mini_clip_left};
value<double> min_pt_size{b, "min-point-size", 10};