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/module | |
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/module')
-rw-r--r-- | tracker-pt/module/camera.cpp | 9 | ||||
-rw-r--r-- | tracker-pt/module/point_extractor.cpp | 14 |
2 files changed, 6 insertions, 17 deletions
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; } |