summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-04-26 18:58:49 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-04-26 18:58:49 +0200
commit9ef0dea80ef67d739c11cd3d88f12250ddecf612 (patch)
tree68cd514732fa4ce1142eb57ff55495d9debc0fff
parent248bd81caceb21e3e278e340388425b9f102c34c (diff)
tracker/trackhat: merge gain/exposure sliders
-rw-r--r--tracker-trackhat/camera.cpp2
-rw-r--r--tracker-trackhat/dialog.cpp7
-rw-r--r--tracker-trackhat/dialog.ui83
-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.hpp8
9 files changed, 40 insertions, 88 deletions
diff --git a/tracker-trackhat/camera.cpp b/tracker-trackhat/camera.cpp
index 033fd532..94b81272 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.gain, &t.threshold, })
+ for (auto* slider : { &t.exposure, &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 2a7bf119..19563143 100644
--- a/tracker-trackhat/dialog.cpp
+++ b/tracker-trackhat/dialog.cpp
@@ -31,16 +31,15 @@ trackhat_dialog::trackhat_dialog()
// exposure
+ ui.exposure_slider->setMinimum((int)t.exposure->min());
+ ui.exposure_slider->setMaximum((int)t.exposure->max());
+
tie_setting(t.exposure, ui.exposure_slider);
- tie_setting(t.gain, ui.gain_slider);
ui.exposure_label->setValue((int)*t.exposure);
- ui.gain_label->setValue((int)*t.gain);
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.gain, value_::value_changed<slider_value>(), ui.gain_label,
- [this] { ui.gain_label->setValue((int)*t.gain); }, 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);
diff --git a/tracker-trackhat/dialog.ui b/tracker-trackhat/dialog.ui
index 6bb7f515..3195cf24 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>485</height>
+ <height>460</height>
</rect>
</property>
<property name="minimumSize">
@@ -31,48 +31,6 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
- <widget class="QSlider" name="gain_slider">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximum">
- <number>51</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <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="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Threshold</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
<widget class="QSlider" name="threshold_slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
@@ -92,14 +50,14 @@
</widget>
</item>
<item row="1" column="0">
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="label_3">
<property name="text">
- <string>Gain</string>
+ <string>Threshold</string>
</property>
</widget>
</item>
- <item row="2" column="2">
- <widget class="QSpinBox" name="threshold_label">
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="exposure_label">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@@ -117,27 +75,27 @@
</property>
</widget>
</item>
- <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>
+ <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="readOnly">
- <bool>true</bool>
+ <property name="maximum">
+ <number>239</number>
</property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
+ <property name="pageStep">
+ <number>10</number>
</property>
- <property name="maximum">
- <number>999</number>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="0" column="2">
- <widget class="QSpinBox" name="exposure_label">
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="threshold_label">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@@ -595,7 +553,6 @@
</widget>
<tabstops>
<tabstop>exposure_slider</tabstop>
- <tabstop>gain_slider</tabstop>
<tabstop>threshold_slider</tabstop>
<tabstop>model_type</tabstop>
<tabstop>min_point_size</tabstop>
diff --git a/tracker-trackhat/lang/nl_NL.ts b/tracker-trackhat/lang/nl_NL.ts
index 50fdef30..9166a143 100644
--- a/tracker-trackhat/lang/nl_NL.ts
+++ b/tracker-trackhat/lang/nl_NL.ts
@@ -56,10 +56,6 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Gain</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>Model</source>
<translation type="unfinished"></translation>
</message>
diff --git a/tracker-trackhat/lang/ru_RU.ts b/tracker-trackhat/lang/ru_RU.ts
index 23c14ed4..3d587010 100644
--- a/tracker-trackhat/lang/ru_RU.ts
+++ b/tracker-trackhat/lang/ru_RU.ts
@@ -56,10 +56,6 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Gain</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>Model</source>
<translation type="unfinished"></translation>
</message>
diff --git a/tracker-trackhat/lang/stub.ts b/tracker-trackhat/lang/stub.ts
index 17ca6da6..d1a07ea6 100644
--- a/tracker-trackhat/lang/stub.ts
+++ b/tracker-trackhat/lang/stub.ts
@@ -20,10 +20,6 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Gain</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>Model</source>
<translation type="unfinished"></translation>
</message>
diff --git a/tracker-trackhat/lang/zh_CN.ts b/tracker-trackhat/lang/zh_CN.ts
index 1c7f83ae..ca9ff5c6 100644
--- a/tracker-trackhat/lang/zh_CN.ts
+++ b/tracker-trackhat/lang/zh_CN.ts
@@ -56,10 +56,6 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Gain</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>Model</source>
<translation type="unfinished"></translation>
</message>
diff --git a/tracker-trackhat/settings.cpp b/tracker-trackhat/settings.cpp
index f9a866bf..0ecca16d 100644
--- a/tracker-trackhat/settings.cpp
+++ b/tracker-trackhat/settings.cpp
@@ -7,6 +7,14 @@ 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()
{
@@ -80,12 +88,12 @@ void trackhat_camera::set_pt_options()
bool trackhat_camera::init_regs()
{
- auto exp = (uint8_t)t.exposure;
+ auto exp = (uint8_t)t.effective_exposure();
auto exp2 = (uint8_t)(exp == 0xff ? 0xf0 : 0xff);
auto thres = (uint8_t)t.threshold;
auto thres2 = (uint8_t)3;
- auto gain = (uint8_t)((int)*t.gain);
+ auto gain = (uint8_t)t.effective_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 1e1857f5..1ae67e1c 100644
--- a/tracker-trackhat/trackhat.hpp
+++ b/tracker-trackhat/trackhat.hpp
@@ -30,9 +30,13 @@ 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,
+ 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", {0x80, 0x10, 0xff}};
- value<slider_value> gain{b, "gain", {16, 0, 47}};
+ value<slider_value> exposure{b, "exposure", {min_exposure, min_exposure, max_exposure + max_gain - min_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};