diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-01-05 21:05:30 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-01-05 21:10:40 +0100 |
commit | f531c3164271f69cb2caef0334b2e24fdd3f1efc (patch) | |
tree | 18093912f5927f55db418b1d8f6f7ad2f5a448e3 /tracker-pt | |
parent | d98d36c9acc66fb3158f77274189c92b1330fbf6 (diff) |
tracker/pt: clean up grayscale handling. add migration.
The averaging mode is slower than the opencv SIMD implementation
for BT.709. Remove it.
Make it optional to perform hardware grayscaling using the ps3eye sensor
with the open driver. Default to grayscaling using the CPU.
Diffstat (limited to 'tracker-pt')
-rw-r--r-- | tracker-pt/FTNoIR_PT_Controls.ui | 4 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt_dialog.cpp | 4 | ||||
-rw-r--r-- | tracker-pt/lang/nl_NL.ts | 16 | ||||
-rw-r--r-- | tracker-pt/lang/ru_RU.ts | 16 | ||||
-rw-r--r-- | tracker-pt/lang/stub.ts | 16 | ||||
-rw-r--r-- | tracker-pt/lang/zh_CN.ts | 16 | ||||
-rw-r--r-- | tracker-pt/module/camera.cpp | 9 | ||||
-rw-r--r-- | tracker-pt/module/point_extractor.cpp | 14 | ||||
-rw-r--r-- | tracker-pt/pt-settings.hpp | 6 |
9 files changed, 45 insertions, 56 deletions
diff --git a/tracker-pt/FTNoIR_PT_Controls.ui b/tracker-pt/FTNoIR_PT_Controls.ui index 015dcada..5a9b1963 100644 --- a/tracker-pt/FTNoIR_PT_Controls.ui +++ b/tracker-pt/FTNoIR_PT_Controls.ui @@ -157,12 +157,12 @@ </property> <item> <property name="text"> - <string>Average</string> + <string>Grayscale BT.709</string> </property> </item> <item> <property name="text"> - <string>Natural</string> + <string>Grayscale (from hardware)</string> </property> </item> <item> diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 4f17f186..2bab280a 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -92,8 +92,8 @@ TrackerDialog_PT::TrackerDialog_PT(const QString& module_name) : poll_tracker_info_impl(); constexpr pt_color_type color_types[] = { - pt_color_average, - pt_color_natural, + pt_color_bt709, + pt_color_hardware, pt_color_red_only, pt_color_green_only, pt_color_blue_only, diff --git a/tracker-pt/lang/nl_NL.ts b/tracker-pt/lang/nl_NL.ts index 5b55148d..72cb5d6d 100644 --- a/tracker-pt/lang/nl_NL.ts +++ b/tracker-pt/lang/nl_NL.ts @@ -108,14 +108,6 @@ <translation type="unfinished"></translation> </message> <message> - <source>Average</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Natural</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Red only</source> <translation type="unfinished"></translation> </message> @@ -296,6 +288,14 @@ Don't roll or change position.</source> <source>Limit</source> <translation type="unfinished"></translation> </message> + <message> + <source>Grayscale BT.709</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Grayscale (from hardware)</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>pt_impl::TrackerDialog_PT</name> diff --git a/tracker-pt/lang/ru_RU.ts b/tracker-pt/lang/ru_RU.ts index e53052d3..469fabd1 100644 --- a/tracker-pt/lang/ru_RU.ts +++ b/tracker-pt/lang/ru_RU.ts @@ -112,14 +112,6 @@ <translation type="unfinished"></translation> </message> <message> - <source>Average</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Natural</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Red only</source> <translation type="unfinished"></translation> </message> @@ -301,6 +293,14 @@ ROLL или X/Y-смещения.</translation> <source>Limit</source> <translation type="unfinished"></translation> </message> + <message> + <source>Grayscale BT.709</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Grayscale (from hardware)</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>pt_impl::TrackerDialog_PT</name> diff --git a/tracker-pt/lang/stub.ts b/tracker-pt/lang/stub.ts index 5d8e0e4a..e2781648 100644 --- a/tracker-pt/lang/stub.ts +++ b/tracker-pt/lang/stub.ts @@ -108,14 +108,6 @@ <translation type="unfinished"></translation> </message> <message> - <source>Average</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Natural</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Red only</source> <translation type="unfinished"></translation> </message> @@ -296,6 +288,14 @@ Don't roll or change position.</source> <source>Limit</source> <translation type="unfinished"></translation> </message> + <message> + <source>Grayscale BT.709</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Grayscale (from hardware)</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>pt_impl::TrackerDialog_PT</name> diff --git a/tracker-pt/lang/zh_CN.ts b/tracker-pt/lang/zh_CN.ts index c35a63d2..8e04a130 100644 --- a/tracker-pt/lang/zh_CN.ts +++ b/tracker-pt/lang/zh_CN.ts @@ -200,14 +200,6 @@ <translation type="unfinished"></translation> </message> <message> - <source>Average</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Natural</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Red only</source> <translation type="unfinished"></translation> </message> @@ -296,6 +288,14 @@ Don't roll or change position.</source> <source>Limit</source> <translation type="unfinished"></translation> </message> + <message> + <source>Grayscale BT.709</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Grayscale (from hardware)</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>pt_impl::TrackerDialog_PT</name> diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp index 73c57f37..1beba474 100644 --- a/tracker-pt/module/camera.cpp +++ b/tracker-pt/module/camera.cpp @@ -104,14 +104,7 @@ bool Camera::start(const pt_settings& s) info.width = res_x; info.height = res_y; info.use_mjpeg = use_mjpeg; - switch (*s.blob_color) - { - case pt_color_natural: - case pt_color_average: - info.num_channels = 1; break; - default: - info.num_channels = 3; break; - } + info.num_channels = s.blob_color == pt_color_hardware ? 1 : 3; if (!cap->start(info)) goto fail; diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp index fbb830d3..8c3ad7e9 100644 --- a/tracker-pt/module/point_extractor.cpp +++ b/tracker-pt/module/point_extractor.cpp @@ -175,18 +175,14 @@ void PointExtractor::color_to_grayscale(const cv::Mat& frame, cv::Mat1b& output) filter_single_channel(frame, 0.5, -1, 0.5, output); break; } - case pt_color_average: - { - const int W = frame.cols, H = frame.rows, sz = W*H; - cv::reduce(frame.reshape(1, sz), - output.reshape(1, sz), - 1, cv::REDUCE_AVG); - break; - } + case pt_color_hardware: + eval_once(qDebug() << "camera driver doesn't support grayscale"); + goto do_grayscale; default: eval_once(qDebug() << "wrong pt_color_type enum value" << int(s.blob_color)); [[fallthrough]]; - case pt_color_natural: + case pt_color_bt709: +do_grayscale: cv::cvtColor(frame, output, cv::COLOR_BGR2GRAY); break; } diff --git a/tracker-pt/pt-settings.hpp b/tracker-pt/pt-settings.hpp index cce2ba6b..54f13283 100644 --- a/tracker-pt/pt-settings.hpp +++ b/tracker-pt/pt-settings.hpp @@ -8,9 +8,9 @@ enum pt_color_type { // explicit values, gotta preserve the numbering in .ini // don't reuse when removing some of the modes - pt_color_natural = 2, + pt_color_bt709 = 2, + pt_color_hardware = 14, pt_color_red_only = 3, - pt_color_average = 5, pt_color_blue_only = 6, pt_color_green_only = 7, pt_color_red_chromakey = 8, @@ -63,7 +63,7 @@ struct pt_settings final : options::opts value<bool> dynamic_pose { b, "dynamic-pose-resolution", false }; value<int> init_phase_timeout { b, "init-phase-timeout", 250 }; value<bool> auto_threshold { b, "automatic-threshold", true }; - value<pt_color_type> blob_color { b, "blob-color", pt_color_natural }; + value<pt_color_type> blob_color { b, "blob-color", pt_color_bt709 }; value<bool> use_mjpeg { b, "use-mjpeg", false }; value<slider_value> threshold_slider { b, "threshold-slider", { 128, 0, 255 } }; |