summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/ftnoir_tracker_pt_dialog.cpp38
-rw-r--r--tracker-pt/ftnoir_tracker_pt_dialog.h2
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.h7
-rw-r--r--tracker-pt/point_extractor.cpp7
4 files changed, 34 insertions, 20 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp
index a4b8c668..4094f4dc 100644
--- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp
+++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp
@@ -28,7 +28,7 @@ TrackerDialog_PT::TrackerDialog_PT()
tie_setting(s.cam_res_y, ui.res_y_spin);
tie_setting(s.cam_fps, ui.fps_spin);
- tie_setting(s.threshold, ui.threshold_slider);
+ tie_setting(s.threshold_slider, ui.threshold_slider);
tie_setting(s.min_point_size, ui.mindiam_spin);
tie_setting(s.max_point_size, ui.maxdiam_spin);
@@ -94,22 +94,32 @@ TrackerDialog_PT::TrackerDialog_PT()
tie_setting(s.blob_color, ui.blob_color);
- tie_setting(s.threshold, ui.threshold_value_display, [this](int x) {
- if (!s.auto_threshold)
- return tr("Brightness %1/255").arg(x);
- else
- {
- CamInfo info;
- int w = 640, h = 480;
+ tie_setting(s.threshold_slider, ui.threshold_value_display, [this](const slider_value& val) {
+ return threshold_display_text(int(val));
+ });
- if (tracker && tracker->get_cam_info(&info) && info.res_x * info.res_y != 0)
- w = info.res_x, h = info.res_y;
+ // refresh threshold display on auto-threshold checkbox state change
+ tie_setting(s.auto_threshold,
+ this,
+ [this](bool) { s.threshold_slider.notify(); });
+}
- double value = PointExtractor::threshold_radius_value(w, h, x);
+QString TrackerDialog_PT::threshold_display_text(int threshold_value)
+{
+ if (!s.auto_threshold)
+ return tr("Brightness %1/255").arg(threshold_value);
+ else
+ {
+ CamInfo info;
+ int w = 640, h = 480;
- return tr("LED radius %1 pixels").arg(value, 0, 'f', 2);
- }
- });
+ if (tracker && tracker->get_cam_info(&info) && info.res_x * info.res_y != 0)
+ w = info.res_x, h = info.res_y;
+
+ double value = PointExtractor::threshold_radius_value(w, h, threshold_value);
+
+ return tr("LED radius %1 pixels").arg(value, 0, 'f', 2);
+ }
}
void TrackerDialog_PT::startstop_trans_calib(bool start)
diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.h b/tracker-pt/ftnoir_tracker_pt_dialog.h
index 59519601..c1c25fb0 100644
--- a/tracker-pt/ftnoir_tracker_pt_dialog.h
+++ b/tracker-pt/ftnoir_tracker_pt_dialog.h
@@ -38,6 +38,8 @@ public slots:
signals:
void poll_tracker_info();
private:
+ QString threshold_display_text(int threshold_value);
+
settings_pt s;
Tracker_PT* tracker;
QTimer timer, calib_timer;
diff --git a/tracker-pt/ftnoir_tracker_pt_settings.h b/tracker-pt/ftnoir_tracker_pt_settings.h
index 6bbba16b..8250edba 100644
--- a/tracker-pt/ftnoir_tracker_pt_settings.h
+++ b/tracker-pt/ftnoir_tracker_pt_settings.h
@@ -26,8 +26,7 @@ struct settings_pt : opts
value<QString> camera_name;
value<int> cam_res_x,
cam_res_y,
- cam_fps,
- threshold;
+ cam_fps;
value<double> min_point_size, max_point_size;
value<int> m01_x, m01_y, m01_z;
@@ -45,13 +44,15 @@ struct settings_pt : opts
value<bool> auto_threshold;
value<pt_color_type> blob_color;
+ value<slider_value> threshold_slider;
+
settings_pt() :
opts("tracker-pt"),
camera_name(b, "camera-name", ""),
cam_res_x(b, "camera-res-width", 640),
cam_res_y(b, "camera-res-height", 480),
cam_fps(b, "camera-fps", 30),
- threshold(b, "threshold-primary", 128),
+ threshold_slider(b, "threshold-slider", slider_value(128, 0, 255)),
min_point_size(b, "min-point-size", 1),
max_point_size(b, "max-point-size", 50),
m01_x(b, "m_01-x", 0),
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index adb23d52..40054084 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -180,10 +180,11 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
const double region_size_min = s.min_point_size;
const double region_size_max = s.max_point_size;
+ const int threshold_slider_value = s.threshold_slider.to<int>();
+
if (!s.auto_threshold)
{
- const int thres = s.threshold;
- cv::threshold(frame_gray, frame_bin, thres, 255, cv::THRESH_BINARY);
+ cv::threshold(frame_gray, frame_bin, threshold_slider_value, 255, cv::THRESH_BINARY);
}
else
{
@@ -200,7 +201,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
(int const*) &hist_size,
&ranges);
- const double radius = threshold_radius_value(frame.cols, frame.rows, s.threshold);
+ const double radius = threshold_radius_value(frame.cols, frame.rows, threshold_slider_value);
float const* restrict_ptr ptr = reinterpret_cast<float const* restrict_ptr>(hist.ptr(0));
const unsigned area = uround(3 * M_PI * radius*radius);