From c772987dde5c42aa7f236ac7708f6e7d063d4aa7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 May 2016 22:54:50 +0200 Subject: Revert "tracker/pt: experimental non-white color removal" This reverts commit 546cfb5ad52dcfe1421d1af5e7baeada588ac735. @MathijsG points out that some users have red LEDs, not uniform white. Issue: #355 --- tracker-pt/point_extractor.cpp | 65 ++---------------------------------------- tracker-pt/point_extractor.h | 7 ----- 2 files changed, 3 insertions(+), 69 deletions(-) mode change 100755 => 100644 tracker-pt/point_extractor.h diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp index be1cd59c..96c70d11 100755 --- a/tracker-pt/point_extractor.cpp +++ b/tracker-pt/point_extractor.cpp @@ -13,76 +13,17 @@ # include "opentrack-compat/timer.hpp" #endif -//#define DEBUG_SUM_OF_SQUARES -#ifdef DEBUG_SUM_OF_SQUARES -# define SUM_OF_SQUARES_WINNAME "sum-of-squares-debug" -# include -#endif - PointExtractor::PointExtractor() { -#ifdef DEBUG_SUM_OF_SQUARES - cv::namedWindow(SUM_OF_SQUARES_WINNAME); -#endif blobs.reserve(max_blobs); points.reserve(max_blobs); } -PointExtractor::~PointExtractor() -{ -#ifdef DEBUG_SUM_OF_SQUARES - cv::destroyWindow(SUM_OF_SQUARES_WINNAME); -#endif -} - -void PointExtractor::gray_square_diff(const cv::Mat &frame, cv::Mat &frame_gray) -{ - const unsigned nchans = frame.channels(); - const int rows = frame.rows; - const int cols = frame.cols; - cv::cvtColor(frame, frame_gray, cv::COLOR_RGB2GRAY); - - if (nchans == 1 || !s.auto_threshold) - return; - - cv::split(frame, gray_split_channels); - - if (nchans > gray_absdiff_channels.size()) - gray_absdiff_channels.resize(nchans); - - for (unsigned i = 0; i < nchans; i++) - cv::absdiff(frame_gray, gray_split_channels[i], gray_absdiff_channels[i]); - - if (frame_gray_tmp.rows != rows || frame_gray_tmp.cols != cols) - frame_gray_tmp = cv::Mat(rows, cols, CV_32FC1); - - frame_gray.convertTo(frame_gray_tmp, CV_32FC1); - - constexpr float scale = .9; - - if (float_absdiff_channel.cols != cols || float_absdiff_channel.rows != rows) - float_absdiff_channel = cv::Mat(rows, cols, CV_32FC1); - - for (unsigned i = 0; i < nchans; i++) - { - gray_absdiff_channels[i].convertTo(float_absdiff_channel, CV_32FC1); - - frame_gray_tmp -= float_absdiff_channel.mul(float_absdiff_channel, scale); - } - - frame_gray_tmp.convertTo(frame_gray, CV_8UC1); - -#ifdef DEBUG_SUM_OF_SQUARES - cv::imshow(SUM_OF_SQUARES_WINNAME, frame_gray); - cv::waitKey(1); -#endif -} - const std::vector& PointExtractor::extract_points(cv::Mat& frame) { const int W = frame.cols; const int H = frame.rows; - + if (frame_gray.rows != frame.rows || frame_gray.cols != frame.cols) { frame_gray = cv::Mat(frame.rows, frame.cols, CV_8U); @@ -90,11 +31,11 @@ const std::vector& PointExtractor::extract_points(cv::Mat& frame) } // convert to grayscale - gray_square_diff(frame, frame_gray); + cv::cvtColor(frame, frame_gray, cv::COLOR_RGB2GRAY); const double region_size_min = s.min_point_size; const double region_size_max = s.max_point_size; - + const int thres = s.threshold; contours.clear(); diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h old mode 100755 new mode 100644 index 5a3630be..3e4661f9 --- a/tracker-pt/point_extractor.h +++ b/tracker-pt/point_extractor.h @@ -25,22 +25,15 @@ public: const std::vector &extract_points(cv::Mat &frame); int get_n_points() { QMutexLocker l(&mtx); return points.size(); } PointExtractor(); - ~PointExtractor(); settings_pt s; private: - void gray_square_diff(const cv::Mat& frame, cv::Mat& frame_gray); - enum { hist_c = 2 }; std::vector points; QMutex mtx; cv::Mat frame_gray; - cv::Mat frame_gray_tmp; cv::Mat frame_bin; cv::Mat hist; - std::vector gray_split_channels; - std::vector gray_absdiff_channels; - cv::Mat float_absdiff_channel; enum { max_blobs = 16 }; -- cgit v1.2.3