From f531c3164271f69cb2caef0334b2e24fdd3f1efc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 5 Jan 2022 21:05:30 +0100 Subject: 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. --- tracker-pt/FTNoIR_PT_Controls.ui | 4 ++-- tracker-pt/ftnoir_tracker_pt_dialog.cpp | 4 ++-- tracker-pt/lang/nl_NL.ts | 16 ++++++++-------- tracker-pt/lang/ru_RU.ts | 16 ++++++++-------- tracker-pt/lang/stub.ts | 16 ++++++++-------- tracker-pt/lang/zh_CN.ts | 16 ++++++++-------- tracker-pt/module/camera.cpp | 9 +-------- tracker-pt/module/point_extractor.cpp | 14 +++++--------- tracker-pt/pt-settings.hpp | 6 +++--- 9 files changed, 45 insertions(+), 56 deletions(-) (limited to 'tracker-pt') diff --git a/tracker-pt/FTNoIR_PT_Controls.ui b/tracker-pt/FTNoIR_PT_Controls.ui index 015dcada9..5a9b19632 100644 --- a/tracker-pt/FTNoIR_PT_Controls.ui +++ b/tracker-pt/FTNoIR_PT_Controls.ui @@ -157,12 +157,12 @@ - Average + Grayscale BT.709 - Natural + Grayscale (from hardware) diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 4f17f186f..2bab280a0 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 5b55148d9..72cb5d6d9 100644 --- a/tracker-pt/lang/nl_NL.ts +++ b/tracker-pt/lang/nl_NL.ts @@ -107,14 +107,6 @@ Color channels used - - Average - - - - Natural - - Red only @@ -296,6 +288,14 @@ Don't roll or change position. Limit + + Grayscale BT.709 + + + + Grayscale (from hardware) + + pt_impl::TrackerDialog_PT diff --git a/tracker-pt/lang/ru_RU.ts b/tracker-pt/lang/ru_RU.ts index e53052d3f..469fabd19 100644 --- a/tracker-pt/lang/ru_RU.ts +++ b/tracker-pt/lang/ru_RU.ts @@ -111,14 +111,6 @@ Color channels used - - Average - - - - Natural - - Red only @@ -301,6 +293,14 @@ ROLL или X/Y-смещения. Limit + + Grayscale BT.709 + + + + Grayscale (from hardware) + + pt_impl::TrackerDialog_PT diff --git a/tracker-pt/lang/stub.ts b/tracker-pt/lang/stub.ts index 5d8e0e4a3..e27816484 100644 --- a/tracker-pt/lang/stub.ts +++ b/tracker-pt/lang/stub.ts @@ -107,14 +107,6 @@ Color channels used - - Average - - - - Natural - - Red only @@ -296,6 +288,14 @@ Don't roll or change position. Limit + + Grayscale BT.709 + + + + Grayscale (from hardware) + + pt_impl::TrackerDialog_PT diff --git a/tracker-pt/lang/zh_CN.ts b/tracker-pt/lang/zh_CN.ts index c35a63d21..8e04a1300 100644 --- a/tracker-pt/lang/zh_CN.ts +++ b/tracker-pt/lang/zh_CN.ts @@ -199,14 +199,6 @@ Color channels used - - Average - - - - Natural - - Red only @@ -296,6 +288,14 @@ Don't roll or change position. Limit + + Grayscale BT.709 + + + + Grayscale (from hardware) + + pt_impl::TrackerDialog_PT diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp index 73c57f37e..1beba474e 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 fbb830d3d..8c3ad7e9a 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 cce2ba6b3..54f132837 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 dynamic_pose { b, "dynamic-pose-resolution", false }; value init_phase_timeout { b, "init-phase-timeout", 250 }; value auto_threshold { b, "automatic-threshold", true }; - value blob_color { b, "blob-color", pt_color_natural }; + value blob_color { b, "blob-color", pt_color_bt709 }; value use_mjpeg { b, "use-mjpeg", false }; value threshold_slider { b, "threshold-slider", { 128, 0, 255 } }; -- cgit v1.2.3