summaryrefslogtreecommitdiffhomepage
path: root/tracker-trackhat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2021-10-16 00:00:02 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-03-29 00:04:47 +0200
commit20fc4b1b648ffc8e403c7b13e933ecd92b0458c7 (patch)
treeaeaadabc2d253e4061c0b4a9b104625f636b369c /tracker-trackhat
parentd9f0f70ce50a046046cc7c88b992876dac7782b2 (diff)
tracker/trackhat: buffer flush
Diffstat (limited to 'tracker-trackhat')
-rw-r--r--tracker-trackhat/camera.cpp22
-rw-r--r--tracker-trackhat/dialog.cpp82
-rw-r--r--tracker-trackhat/dialog.hpp29
-rw-r--r--tracker-trackhat/dialog.ui200
-rw-r--r--tracker-trackhat/frame.cpp1
-rw-r--r--tracker-trackhat/lang/nl_NL.ts28
-rw-r--r--tracker-trackhat/lang/ru_RU.ts28
-rw-r--r--tracker-trackhat/lang/stub.ts28
-rw-r--r--tracker-trackhat/lang/zh_CN.ts28
-rw-r--r--tracker-trackhat/metadata.cpp9
-rw-r--r--tracker-trackhat/metadata.hpp9
-rw-r--r--tracker-trackhat/settings.cpp66
-rw-r--r--tracker-trackhat/trackhat-res.qrc5
-rw-r--r--tracker-trackhat/trackhat.hpp50
14 files changed, 486 insertions, 99 deletions
diff --git a/tracker-trackhat/camera.cpp b/tracker-trackhat/camera.cpp
index c744a9f9..1c87229e 100644
--- a/tracker-trackhat/camera.cpp
+++ b/tracker-trackhat/camera.cpp
@@ -32,7 +32,15 @@ QString trackhat_camera::get_active_name() const
void trackhat_camera::set_fov(pt_camera::f) {}
void trackhat_camera::show_camera_settings() {}
-trackhat_camera::trackhat_camera() = default;
+trackhat_camera::trackhat_camera()
+{
+ s.set_raii_dtor_state(false);
+ t.set_raii_dtor_state(false);
+
+ QObject::connect(t.b.get(), &options::bundle_::changed,
+ &sig, &trackhat_impl::setting_receiver::settings_changed,
+ Qt::DirectConnection);
+}
trackhat_camera::~trackhat_camera()
{
@@ -41,6 +49,13 @@ trackhat_camera::~trackhat_camera()
pt_camera::result trackhat_camera::get_frame(pt_frame& frame_)
{
+ if (sig.test_and_clear())
+ {
+ set_pt_options();
+ qDebug() << "tracker/trackhat: set regs";
+ init_regs();
+ }
+
auto& ret = *frame_.as<trackhat_frame>();
trackhat_frame frame;
trackHat_ExtendedPoints_t points = {};
@@ -81,6 +96,9 @@ int trackhat_camera::init_regs()
constexpr uint8_t regs[][3] = {
{ 0x0c, 0x0f, 0xf0 }, // exposure lo
{ 0x0c, 0x10, 0x7f }, // exposure hi
+ { 0x00, 0x0b, 0xff }, // blob area max size
+ { 0x00, 0x0c, 0x03 }, // blob area min size
+ { 0x00, 0x01, 0x01 }, // bank0 sync
{ 0x01, 0x01, 0x01 }, // bank1 sync
};
@@ -98,6 +116,8 @@ bool trackhat_camera::start(const pt_settings&)
{
int attempts = 0;
+ set_pt_options();
+
if (status >= th_running)
return true;
diff --git a/tracker-trackhat/dialog.cpp b/tracker-trackhat/dialog.cpp
index e69de29b..c51b0d59 100644
--- a/tracker-trackhat/dialog.cpp
+++ b/tracker-trackhat/dialog.cpp
@@ -0,0 +1,82 @@
+#include "dialog.hpp"
+
+using namespace options;
+
+trackhat_dialog::trackhat_dialog()
+{
+ ui.setupUi(this);
+ poll_tracker_info();
+ poll_timer.setInterval(250);
+
+ struct {
+ const char* name;
+ model_type t;
+ } model_types[] = {
+ { "Cap", model_cap },
+ { "Clip (left)", model_clip_left },
+ { "Clip (right)", model_clip_right },
+ { "Mini Clip (left)", model_mini_clip_left },
+ { "Mini Clip (right)", model_mini_clip_right },
+ };
+
+ ui.model_type->clear();
+
+ for (auto x : model_types)
+ ui.model_type->addItem(QIcon{}, tr(x.name), (QVariant)(int)x.t);
+
+ tie_setting(t.min_pt_size, ui.min_point_size);
+ tie_setting(t.max_pt_size, ui.max_point_size);
+ tie_setting(t.exposure, ui.exposure_slider);
+ tie_setting(t.model, ui.model_type);
+ tie_setting(t.threshold, ui.threshold_slider);
+ 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.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(ui.buttonBox, &QDialogButtonBox::accepted, this, &trackhat_dialog::doOK);
+ connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &trackhat_dialog::doCancel);
+}
+
+void trackhat_dialog::register_tracker(ITracker* tracker)
+{
+ tracker = static_cast<Tracker_PT*>(tracker);
+ poll_timer.start();
+}
+
+void trackhat_dialog::unregister_tracker()
+{
+ tracker = nullptr;
+ poll_timer.stop();
+}
+
+void trackhat_dialog::doOK()
+{
+ s.b->save();
+ t.b->save();
+ close();
+}
+
+void trackhat_dialog::doCancel()
+{
+ close();
+}
+
+void trackhat_dialog::poll_tracker_info()
+{
+ if (!tracker)
+ {
+ poll_timer.stop();
+ ui.status_label->setText(tr("Tracking stopped."));
+ return;
+ }
+
+ ui.status_label->setText(tr("Tracking. %1 points detected.").arg(tracker->get_n_points()));
+}
+
+trackhat_dialog::~trackhat_dialog() = default;
diff --git a/tracker-trackhat/dialog.hpp b/tracker-trackhat/dialog.hpp
index e69de29b..0726a2c0 100644
--- a/tracker-trackhat/dialog.hpp
+++ b/tracker-trackhat/dialog.hpp
@@ -0,0 +1,29 @@
+#pragma once
+#include "trackhat.hpp"
+#include "ui_dialog.h"
+#include "tracker-pt/ftnoir_tracker_pt.h"
+#include "api/plugin-api.hpp"
+#include <QTimer>
+
+class trackhat_dialog : public ITrackerDialog
+{
+ Q_OBJECT
+
+ Ui_trackhat_dialog ui;
+ Tracker_PT* tracker = nullptr;
+ QTimer poll_timer{this};
+
+ pt_settings s{trackhat_metadata::module_name};
+ trackhat_settings t;
+
+public:
+ trackhat_dialog();
+ ~trackhat_dialog() override;
+ void register_tracker(ITracker *tracker) override;
+ void unregister_tracker() override;
+
+public slots:
+ void doOK();
+ void doCancel();
+ void poll_tracker_info();
+};
diff --git a/tracker-trackhat/dialog.ui b/tracker-trackhat/dialog.ui
index db966ab2..ade5f6b2 100644
--- a/tracker-trackhat/dialog.ui
+++ b/tracker-trackhat/dialog.ui
@@ -1,17 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Form</class>
- <widget class="QWidget" name="Form">
+ <class>trackhat_dialog</class>
+ <widget class="QDialog" name="trackhat_dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>415</width>
- <height>226</height>
+ <width>365</width>
+ <height>334</height>
</rect>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>365</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="windowTitle">
- <string>TrackHat tracker</string>
+ <string>TrackHat</string>
+ </property>
+ <property name="windowIcon">
+ <iconset resource="trackhat-res.qrc">
+ <normaloff>:/images/trackhat-64x64.png</normaloff>:/images/trackhat-64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@@ -20,26 +30,6 @@
<string>Camera</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <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">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </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">
@@ -49,29 +39,18 @@
</sizepolicy>
</property>
<property name="maximum">
- <number>200</number>
+ <number>65535</number>
+ </property>
+ <property name="pageStep">
+ <number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <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">
+ <widget class="QSlider" name="threshold_slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -79,40 +58,56 @@
</sizepolicy>
</property>
<property name="maximum">
- <number>200</number>
+ <number>191</number>
</property>
<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="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="1" column="2">
- <widget class="QSpinBox" name="gain_label">
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="exposure_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>65535</number>
+ </property>
</widget>
</item>
- <item row="2" column="2">
- <widget class="QSpinBox" name="threshold_label">
- <property name="readOnly">
- <bool>true</bool>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Exposure</string>
</property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Threshold</string>
</property>
</widget>
</item>
@@ -142,7 +137,7 @@
<widget class="QComboBox" name="model_type">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>8</horstretch>
+ <horstretch>9</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
@@ -215,8 +210,105 @@
</layout>
</widget>
</item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Tracking</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QWidget" name="widget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="enable_point_filter">
+ <property name="text">
+ <string>Point filter</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="point_filter_slider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximum">
+ <number>300</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="point_filter_label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="suffix">
+ <string> px</string>
+ </property>
+ <property name="maximum">
+ <double>300.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="status_label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Status</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
- <resources/>
+ <resources>
+ <include location="trackhat-res.qrc"/>
+ </resources>
<connections/>
</ui>
diff --git a/tracker-trackhat/frame.cpp b/tracker-trackhat/frame.cpp
index 1ae3413f..c008ac87 100644
--- a/tracker-trackhat/frame.cpp
+++ b/tracker-trackhat/frame.cpp
@@ -102,7 +102,6 @@ void trackhat_frame::init_points(trackHat_ExtendedPoints_t points_, double min_s
if (i < 3 && radius >= min_size && radius <= max_size)
p.ok = true;
- p.radius = radius;
p.brightness = pt.m_averageBrightness;
p.W = std::max(1, pt.m_boundryRigth - pt.m_boundryLeft);
p.H = std::max(1, pt.m_boundryDown - pt.m_boundryUp);
diff --git a/tracker-trackhat/lang/nl_NL.ts b/tracker-trackhat/lang/nl_NL.ts
index e375a7a4..1f46e7e3 100644
--- a/tracker-trackhat/lang/nl_NL.ts
+++ b/tracker-trackhat/lang/nl_NL.ts
@@ -2,9 +2,9 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
- <name>Form</name>
+ <name>trackhat_dialog</name>
<message>
- <source>TrackHat tracker</source>
+ <source>TrackHat</source>
<translation type="unfinished"></translation>
</message>
<message>
@@ -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>
@@ -43,6 +39,26 @@
<source> px</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Point filter</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking stopped.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking. %1 points detected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Status</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 e375a7a4..1f46e7e3 100644
--- a/tracker-trackhat/lang/ru_RU.ts
+++ b/tracker-trackhat/lang/ru_RU.ts
@@ -2,9 +2,9 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
- <name>Form</name>
+ <name>trackhat_dialog</name>
<message>
- <source>TrackHat tracker</source>
+ <source>TrackHat</source>
<translation type="unfinished"></translation>
</message>
<message>
@@ -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>
@@ -43,6 +39,26 @@
<source> px</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Point filter</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking stopped.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking. %1 points detected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Status</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 e375a7a4..1f46e7e3 100644
--- a/tracker-trackhat/lang/stub.ts
+++ b/tracker-trackhat/lang/stub.ts
@@ -2,9 +2,9 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
- <name>Form</name>
+ <name>trackhat_dialog</name>
<message>
- <source>TrackHat tracker</source>
+ <source>TrackHat</source>
<translation type="unfinished"></translation>
</message>
<message>
@@ -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>
@@ -43,6 +39,26 @@
<source> px</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Point filter</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking stopped.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking. %1 points detected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Status</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 e375a7a4..1f46e7e3 100644
--- a/tracker-trackhat/lang/zh_CN.ts
+++ b/tracker-trackhat/lang/zh_CN.ts
@@ -2,9 +2,9 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
- <name>Form</name>
+ <name>trackhat_dialog</name>
<message>
- <source>TrackHat tracker</source>
+ <source>TrackHat</source>
<translation type="unfinished"></translation>
</message>
<message>
@@ -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>
@@ -43,6 +39,26 @@
<source> px</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Point filter</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking stopped.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Tracking. %1 points detected.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Status</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>trackhat_module</name>
diff --git a/tracker-trackhat/metadata.cpp b/tracker-trackhat/metadata.cpp
index a6dd12f8..8c6f4de0 100644
--- a/tracker-trackhat/metadata.cpp
+++ b/tracker-trackhat/metadata.cpp
@@ -1,9 +1,10 @@
#include "metadata.hpp"
#include "api/plugin-api.hpp"
#include "trackhat.hpp"
+#include "dialog.hpp"
// XXX TODO
-const QString trackhat_metadata::module_name = QStringLiteral("tracker-pt");
+const QString trackhat_metadata::module_name = QStringLiteral("tracker-trackhat/pt");
pt_runtime_traits::pointer<pt_camera> trackhat_metadata::make_camera() const
{
@@ -35,8 +36,4 @@ trackhat_pt::trackhat_pt() :
{
}
-trackhat_pt_dialog::trackhat_pt_dialog() : TrackerDialog_PT(trackhat_metadata::module_name)
-{
-}
-
-OPENTRACK_DECLARE_TRACKER(trackhat_pt, trackhat_pt_dialog, trackhat_module)
+OPENTRACK_DECLARE_TRACKER(trackhat_pt, trackhat_dialog, trackhat_module)
diff --git a/tracker-trackhat/metadata.hpp b/tracker-trackhat/metadata.hpp
index d8d053b1..c0f7567c 100644
--- a/tracker-trackhat/metadata.hpp
+++ b/tracker-trackhat/metadata.hpp
@@ -1,7 +1,6 @@
#pragma once
#include "trackhat.hpp"
#include "../tracker-pt/ftnoir_tracker_pt.h"
-#include "../tracker-pt/ftnoir_tracker_pt_dialog.h"
class trackhat_pt final : public Tracker_PT
{
@@ -11,14 +10,6 @@ public:
trackhat_pt();
};
-class trackhat_pt_dialog final : public TrackerDialog_PT
-{
- Q_OBJECT
-
-public:
- trackhat_pt_dialog();
-};
-
class trackhat_module final : public Metadata
{
Q_OBJECT
diff --git a/tracker-trackhat/settings.cpp b/tracker-trackhat/settings.cpp
new file mode 100644
index 00000000..a2fd5c8c
--- /dev/null
+++ b/tracker-trackhat/settings.cpp
@@ -0,0 +1,66 @@
+#include "trackhat.hpp"
+
+namespace trackhat_impl {
+
+trackhat_settings::trackhat_settings() : opts{"tracker-trackhat"}
+{
+}
+
+void setting_receiver::settings_changed()
+{
+ changed = true;
+}
+
+bool setting_receiver::test_and_clear()
+{
+ bool x = true;
+ return changed.compare_exchange_strong(x, false);
+}
+
+} // ns trackhat_impl
+
+void trackhat_camera::set_pt_options()
+{
+ s.min_point_size = t.min_pt_size;
+ s.max_point_size = t.max_pt_size;
+
+ switch (t.model)
+ {
+ default:
+ case model_cap:
+ s.t_MH_x = 0; s.t_MH_y = 0; s.t_MH_z = 0;
+ break;
+ case model_clip_left:
+ case model_mini_clip_left:
+ s.t_MH_x = -135; s.t_MH_y = 0; s.t_MH_z = 0;
+ break;
+ case model_clip_right:
+ case model_mini_clip_right:
+ s.t_MH_x = 135; s.t_MH_y = 0; s.t_MH_z = 0;
+ break;
+ }
+
+ switch (t.model)
+ {
+ default:
+ eval_once(qDebug() << "tracker/trackhat: unknown model");
+ [[fallthrough]];
+ case model_clip_left:
+ case model_clip_right:
+ s.clip_tz = 27; s.clip_ty = 43; s.clip_by = 62; s.clip_bz = 74;
+ break;
+ case model_mini_clip_left:
+ case model_mini_clip_right:
+ s.clip_tz = 13; s.clip_ty = 42; s.clip_by = 60; s.clip_bz = 38;
+ break;
+ case model_cap:
+ s.cap_x = 60; s.cap_y = 90; s.cap_z = 95;
+ break;
+ }
+
+ s.active_model_panel = t.model == model_cap ? 1 : 0;
+ s.enable_point_filter = t.enable_point_filter;
+ s.point_filter_coefficient = *t.point_filter_coefficient;
+
+ s.b->save();
+}
diff --git a/tracker-trackhat/trackhat-res.qrc b/tracker-trackhat/trackhat-res.qrc
new file mode 100644
index 00000000..9aeb8879
--- /dev/null
+++ b/tracker-trackhat/trackhat-res.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource>
+ <file>images/trackhat-64x64.png</file>
+ </qresource>
+</RCC>
diff --git a/tracker-trackhat/trackhat.hpp b/tracker-trackhat/trackhat.hpp
index b0096cc3..2cdc083b 100644
--- a/tracker-trackhat/trackhat.hpp
+++ b/tracker-trackhat/trackhat.hpp
@@ -3,10 +3,53 @@
#include "../tracker-pt/pt-api.hpp"
#include "track_hat_driver.h"
#include "compat/macros.hpp"
+#include "options/options.hpp"
#include <array>
+#include <atomic>
#include <opencv2/core.hpp>
+enum model_type : int
+{
+ model_cap = 1,
+ model_clip_left,
+ model_clip_right,
+ model_mini_clip_left,
+ model_mini_clip_right,
+};
+
+namespace trackhat_impl
+{
+using namespace options;
+
+struct trackhat_settings : opts
+{
+ trackhat_settings();
+ value<slider_value> exposure{b, "exposure", {0xfff0, 1, 0xfff0}};
+ value<slider_value> threshold{b, "threshold", {0x97, 64, 0xff}};
+ 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};
+ value<bool> enable_point_filter{b, "enable-point-filter", true };
+ value<slider_value> point_filter_coefficient{b, "point-filter-coefficient", { 1, 0, 4 }};
+};
+
+class setting_receiver : public QObject
+{
+ Q_OBJECT
+
+public:
+ bool test_and_clear();
+public slots:
+ void settings_changed();
+private:
+ std::atomic<bool> changed{false};
+};
+
+} // ns trackhat_impl
+
+using typename trackhat_impl::trackhat_settings;
+
struct trackhat_metadata final : pt_runtime_traits
{
pt_runtime_traits::pointer<pt_camera> make_camera() const override;
@@ -25,7 +68,6 @@ struct trackhat_metadata final : pt_runtime_traits
struct point
{
- double radius;
int brightness = 0, x, y, W, H;
bool ok = false;
};
@@ -40,6 +82,7 @@ struct trackhat_camera final : pt_camera
bool start(const pt_settings& s) override;
void stop() override;
[[nodiscard]] int init_regs();
+ void set_pt_options();
pt_camera::result get_frame(pt_frame& frame) override;
pt_camera::result get_info() const override;
@@ -57,11 +100,13 @@ struct trackhat_camera final : pt_camera
private:
enum device_status { th_noinit, th_init, th_detect, th_connect, th_running, };
+ trackhat_impl::setting_receiver sig;
trackHat_Device_t device {};
device_status status = th_noinit;
TH_ErrorCode error_code = TH_SUCCESS;
pt_settings s{trackhat_metadata::module_name};
+ trackhat_settings t;
};
struct trackhat_frame final : pt_frame
@@ -99,7 +144,4 @@ struct trackhat_extractor final : pt_point_extractor
trackhat_extractor() = default;
~trackhat_extractor() override = default;
-
-private:
- pt_settings s{trackhat_metadata::module_name};
};