summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2021-10-16 16:35:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-03-29 00:04:47 +0200
commit4f8ec1a2ab434c3896763685fb5dfba7194be143 (patch)
treef02ba54ef97152c8c2440e5eeb6eea6337fc199e
parentd7b4a8b6f40285f08f1e83b4cd921dffe9569cc0 (diff)
tracker/trackhat: buffer flush
-rw-r--r--tracker-trackhat/camera.cpp41
-rw-r--r--tracker-trackhat/dialog.cpp46
-rw-r--r--tracker-trackhat/dialog.ui112
-rw-r--r--tracker-trackhat/lang/nl_NL.ts8
-rw-r--r--tracker-trackhat/lang/ru_RU.ts8
-rw-r--r--tracker-trackhat/lang/stub.ts8
-rw-r--r--tracker-trackhat/lang/zh_CN.ts8
-rw-r--r--tracker-trackhat/trackhat.hpp2
8 files changed, 193 insertions, 40 deletions
diff --git a/tracker-trackhat/camera.cpp b/tracker-trackhat/camera.cpp
index 5338f11c..77175616 100644
--- a/tracker-trackhat/camera.cpp
+++ b/tracker-trackhat/camera.cpp
@@ -37,13 +37,12 @@ trackhat_camera::trackhat_camera()
s.set_raii_dtor_state(false);
t.set_raii_dtor_state(false);
- QObject::connect(&t.exposure, options::value_::value_changed<options::slider_value>(),
- &sig, &trackhat_impl::setting_receiver::settings_changed,
- Qt::DirectConnection);
-
- QObject::connect(&t.threshold, options::value_::value_changed<options::slider_value>(),
- &sig, &trackhat_impl::setting_receiver::settings_changed,
- Qt::DirectConnection);
+ for (auto* slider : { &t.exposure, &t.gain, &t.threshold, &t.threshold_2 })
+ {
+ QObject::connect(slider, options::value_::value_changed<options::slider_value>(),
+ &sig, &trackhat_impl::setting_receiver::settings_changed,
+ Qt::DirectConnection);
+ }
}
trackhat_camera::~trackhat_camera()
@@ -99,20 +98,28 @@ error:
int trackhat_camera::init_regs()
{
- auto exp = (uint8_t)t.exposure;
- auto thres = (uint8_t)t.threshold;
unsigned attempts = 0;
constexpr unsigned max_attempts = 5;
+ auto exp = (uint8_t)t.exposure;
+ auto thres = (uint8_t)t.threshold;
+ auto thres2 = (uint8_t)std::clamp((int)*t.threshold_2, 0, std::max(0, (int)*t.threshold - 1));
+
+ auto gain = (uint8_t)*t.gain;
+ auto gain_c = (uint8_t)(gain < 0x0f ? 0 : (gain / 0x0f + 1) & 3);
+ gain %= 0x0f;
+
const uint8_t regs[][3] = {
- { 0x0c, 0x0f, 0xf0 }, // exposure lo
- { 0x0c, 0x10, exp }, // exposure hi
- { 0x00, 0x0b, 0xff }, // blob area max size
- { 0x00, 0x0c, 0x03 }, // blob area min size
- { 0x0c, 0x47, thres }, // min brightness
- { 0x00, 0x0f, (uint8_t)(thres/10) }, // brightness margin, formula is `thres >= px > thres - fuzz'
- { 0x00, 0x01, 0x01 }, // bank0 sync
- { 0x01, 0x01, 0x01 }, // bank1 sync
+ { 0x0c, 0x0f, 0xf0 }, // exposure lo
+ { 0x0c, 0x10, exp }, // exposure hi
+ { 0x00, 0x0b, 0xff }, // blob area max size
+ { 0x00, 0x0c, 0x03 }, // blob area min size
+ { 0x0c, 0x08, gain }, // gain
+ { 0x0c, 0x0c, gain_c }, // gain multiplier
+ { 0x0c, 0x47, thres }, // min brightness
+ { 0x00, 0x0f, thres2 }, // brightness margin, formula is `thres >= px > thres - fuzz'
+ { 0x00, 0x01, 0x01 }, // bank0 sync
+ { 0x01, 0x01, 0x01 }, // bank1 sync
};
start:
diff --git a/tracker-trackhat/dialog.cpp b/tracker-trackhat/dialog.cpp
index 6a9ad56c..b51fbc3b 100644
--- a/tracker-trackhat/dialog.cpp
+++ b/tracker-trackhat/dialog.cpp
@@ -24,27 +24,55 @@ trackhat_dialog::trackhat_dialog()
for (auto x : model_types)
ui.model_type->addItem(QIcon{}, tr(x.name), (QVariant)(int)x.t);
- ui.exposure_label->setValue((int)*t.exposure);
- ui.threshold_label->setValue((int)*t.threshold);
- ui.point_filter_label->setValue((int)*t.point_filter_coefficient);
-
+ tie_setting(t.model, ui.model_type);
tie_setting(t.min_pt_size, ui.min_point_size);
tie_setting(t.max_pt_size, ui.max_point_size);
+
+ ui.exposure_label->setValue((int)*t.exposure);
+ ui.gain_label->setValue((int)*t.gain);
tie_setting(t.exposure, ui.exposure_slider);
- tie_setting(t.model, ui.model_type);
- tie_setting(t.threshold, ui.threshold_slider);
+ tie_setting(t.gain, ui.gain_slider);
+
+ ui.point_filter_label->setValue((int)*t.point_filter_coefficient);
tie_setting(t.enable_point_filter, ui.enable_point_filter);
tie_setting(t.point_filter_coefficient, ui.point_filter_slider);
+
connect(&t.exposure, value_::value_changed<slider_value>(), ui.exposure_label,
[this] { ui.exposure_label->setValue((int)*t.exposure); }, Qt::QueuedConnection);
- connect(&t.threshold, value_::value_changed<slider_value>(), ui.threshold_label,
- [this] { ui.threshold_label->setValue((int)*t.threshold); }, 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_coefficient, value_::value_changed<slider_value>(), ui.point_filter_label,
[this] { ui.point_filter_label->setValue((int)*t.point_filter_coefficient); }, Qt::QueuedConnection);
- connect(&poll_timer, &QTimer::timeout, this, &trackhat_dialog::poll_tracker_info);
+ connect(&poll_timer, &QTimer::timeout, this, &trackhat_dialog::poll_tracker_info);
connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &trackhat_dialog::doOK);
connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &trackhat_dialog::doCancel);
+
+ connect(&t.threshold, value_::value_changed<slider_value>(), ui.threshold_label, [=] {
+ ui.threshold_label->setValue((int)*t.threshold);
+ }, Qt::QueuedConnection);
+
+ connect(&t.threshold_2, value_::value_changed<slider_value>(), ui.threshold_2_label, [=] {
+ ui.threshold_2_label->setValue((int)*t.threshold_2);
+ }, Qt::QueuedConnection);
+
+ ui.threshold_2_slider->setValue(std::min(ui.threshold_2_slider->value(), ui.threshold_slider->value()-1));
+
+ connect(ui.threshold_slider, &QSlider::valueChanged, this, [this] (int value) {
+ if (value <= ui.threshold_2_slider->value())
+ ui.threshold_2_slider->setValue(value-1);
+ }, Qt::DirectConnection);
+
+ connect(ui.threshold_2_slider, &QSlider::valueChanged, this, [this] (int value) {
+ if (value >= ui.threshold_slider->value())
+ ui.threshold_slider->setValue(value+1);
+ }, Qt::DirectConnection);
+
+ ui.threshold_label->setValue((int)*t.threshold);
+ ui.threshold_2_label->setValue((int)*t.threshold_2);
+ tie_setting(t.threshold, ui.threshold_slider);
+ tie_setting(t.threshold_2, ui.threshold_2_slider);
}
void trackhat_dialog::register_tracker(ITracker* tracker)
diff --git a/tracker-trackhat/dialog.ui b/tracker-trackhat/dialog.ui
index 5eb21956..a1199a19 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>334</height>
+ <height>388</height>
</rect>
</property>
<property name="minimumSize">
@@ -30,8 +30,8 @@
<string>Camera</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1">
- <widget class="QSlider" name="exposure_slider">
+ <item row="1" column="1">
+ <widget class="QSlider" name="gain_slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -39,18 +39,15 @@
</sizepolicy>
</property>
<property name="maximum">
- <number>239</number>
- </property>
- <property name="pageStep">
- <number>10</number>
+ <number>51</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QSlider" name="threshold_slider">
+ <item row="0" column="1">
+ <widget class="QSlider" name="exposure_slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -58,14 +55,17 @@
</sizepolicy>
</property>
<property name="maximum">
- <number>191</number>
+ <number>239</number>
+ </property>
+ <property name="pageStep">
+ <number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="1" column="2">
+ <item row="2" column="2">
<widget class="QSpinBox" name="threshold_label">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -93,7 +93,49 @@
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
- <number>65535</number>
+ <number>999</number>
+ </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="1" column="2">
+ <widget class="QSpinBox" name="gain_label">
+ <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>
+ <item row="2" column="1">
+ <widget class="QSlider" name="threshold_slider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>64</number>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@@ -105,9 +147,51 @@
</widget>
</item>
<item row="1" column="0">
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="label_2">
<property name="text">
- <string>Threshold</string>
+ <string>Gain</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Fuzz</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSlider" name="threshold_2_slider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>254</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="threshold_2_label">
+ <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 1f46e7e3..d23b6528 100644
--- a/tracker-trackhat/lang/nl_NL.ts
+++ b/tracker-trackhat/lang/nl_NL.ts
@@ -59,6 +59,14 @@
<source>Status</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Fuzz</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 1f46e7e3..d23b6528 100644
--- a/tracker-trackhat/lang/ru_RU.ts
+++ b/tracker-trackhat/lang/ru_RU.ts
@@ -59,6 +59,14 @@
<source>Status</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Fuzz</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 1f46e7e3..d23b6528 100644
--- a/tracker-trackhat/lang/stub.ts
+++ b/tracker-trackhat/lang/stub.ts
@@ -59,6 +59,14 @@
<source>Status</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Fuzz</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 1f46e7e3..d23b6528 100644
--- a/tracker-trackhat/lang/zh_CN.ts
+++ b/tracker-trackhat/lang/zh_CN.ts
@@ -59,6 +59,14 @@
<source>Status</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Gain</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Fuzz</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>trackhat_module</name>
diff --git a/tracker-trackhat/trackhat.hpp b/tracker-trackhat/trackhat.hpp
index 9f87da66..ade162ef 100644
--- a/tracker-trackhat/trackhat.hpp
+++ b/tracker-trackhat/trackhat.hpp
@@ -27,7 +27,9 @@ struct trackhat_settings : opts
{
trackhat_settings();
value<slider_value> exposure{b, "exposure", {0x80, 0x10, 0xff}};
+ value<slider_value> gain{b, "gain", {16, 0, 47}};
value<slider_value> threshold{b, "threshold", {0x97, 64, 0xff}};
+ value<slider_value> threshold_2{b, "threshold-2", {0x03, 1, 0xfe}};
value<model_type> model{b, "model", model_mini_clip_left};
value<double> min_pt_size{b, "min-point-size", 2};
value<double> max_pt_size{b, "max-point-size", 8};