summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/FTNoIR_PT_Controls.ui64
-rw-r--r--tracker-pt/point_extractor.cpp22
-rw-r--r--tracker-pt/point_extractor.h2
3 files changed, 60 insertions, 28 deletions
diff --git a/tracker-pt/FTNoIR_PT_Controls.ui b/tracker-pt/FTNoIR_PT_Controls.ui
index 1132d156..ac85b2cb 100644
--- a/tracker-pt/FTNoIR_PT_Controls.ui
+++ b/tracker-pt/FTNoIR_PT_Controls.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>412</width>
- <height>616</height>
+ <width>411</width>
+ <height>630</height>
</rect>
</property>
<property name="sizePolicy">
@@ -458,8 +458,8 @@
<string>Point extraction</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
- <item row="3" column="0">
- <widget class="QLabel" name="label_8">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -467,15 +467,15 @@
</sizepolicy>
</property>
<property name="text">
- <string>Max size</string>
+ <string>Threshold</string>
</property>
<property name="buddy">
- <cstring>maxdiam_spin</cstring>
+ <cstring>threshold_slider</cstring>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -483,15 +483,15 @@
</sizepolicy>
</property>
<property name="text">
- <string>Threshold</string>
+ <string>Min size</string>
</property>
<property name="buddy">
- <cstring>threshold_slider</cstring>
+ <cstring>mindiam_spin</cstring>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_7">
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -499,10 +499,10 @@
</sizepolicy>
</property>
<property name="text">
- <string>Min size</string>
+ <string>Max size</string>
</property>
<property name="buddy">
- <cstring>mindiam_spin</cstring>
+ <cstring>maxdiam_spin</cstring>
</property>
</widget>
</item>
@@ -537,8 +537,8 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_11">
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="auto_threshold">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -546,12 +546,12 @@
</sizepolicy>
</property>
<property name="text">
- <string>Automatic threshold</string>
+ <string>Enable, slider sets point size</string>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QCheckBox" name="auto_threshold">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -559,11 +559,11 @@
</sizepolicy>
</property>
<property name="text">
- <string>Enable, slider sets point size</string>
+ <string>Automatic threshold</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<widget class="QDoubleSpinBox" name="maxdiam_spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@@ -585,7 +585,7 @@
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="3" column="1">
<widget class="QDoubleSpinBox" name="mindiam_spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@@ -607,6 +607,26 @@
</property>
</widget>
</item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="threshold_value_display">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_14">
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 9030b520..adb23d52 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -101,6 +101,18 @@ void PointExtractor::separate_channels(cv::Mat const& orig, const int* order, in
ch[k].convertTo(ch_float[k], CV_32F);
}
+double PointExtractor::threshold_radius_value(int w, int h, int threshold)
+{
+ double cx = w / 640., cy = h / 480.;
+
+ const double min_radius = 1.75 * cx;
+ const double max_radius = 15 * cy;
+
+ const double radius = std::fmax(0., (max_radius-min_radius) * threshold / 255 + min_radius);
+
+ return radius;
+}
+
void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame, std::vector<vec2>& points)
{
using std::sqrt;
@@ -122,7 +134,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
case pt_color_floppy_filter:
{
// weight for blue color
- static constexpr float B = .8;
+ static constexpr float B = .667;
static constexpr int from_to[] = {
0, 0,
@@ -162,6 +174,8 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
break;
}
+ //cv::imshow("capture", frame_gray);
+ //cv::waitKey(1);
const double region_size_min = s.min_point_size;
const double region_size_max = s.max_point_size;
@@ -186,12 +200,8 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
(int const*) &hist_size,
&ranges);
- const double cx = frame.cols / 640., cy = frame.rows / 480.;
-
- const double min_radius = 1.75 * cx;
- const double max_radius = 15 * cy;
+ const double radius = threshold_radius_value(frame.cols, frame.rows, s.threshold);
- const double radius = fmax(0., (max_radius-min_radius) * s.threshold / 255 + min_radius);
float const* restrict_ptr ptr = reinterpret_cast<float const* restrict_ptr>(hist.ptr(0));
const unsigned area = uround(3 * M_PI * radius*radius);
const unsigned sz = unsigned(hist.cols * hist.rows);
diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h
index 8fd521c3..fd32e94b 100644
--- a/tracker-pt/point_extractor.h
+++ b/tracker-pt/point_extractor.h
@@ -39,6 +39,8 @@ public:
PointExtractor();
settings_pt s;
+
+ static double threshold_radius_value(int w, int h, int threshold);
private:
static constexpr int max_blobs = 16;