summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xtracker-pt/point_extractor.cpp65
-rw-r--r--[-rwxr-xr-x]tracker-pt/point_extractor.h7
2 files changed, 3 insertions, 69 deletions
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 <opencv2/highgui.hpp>
-#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<cv::Vec2f>& 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<cv::Vec2f>& 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
index 5a3630be..3e4661f9 100755..100644
--- a/tracker-pt/point_extractor.h
+++ b/tracker-pt/point_extractor.h
@@ -25,22 +25,15 @@ public:
const std::vector<cv::Vec2f> &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<cv::Vec2f> points;
QMutex mtx;
cv::Mat frame_gray;
- cv::Mat frame_gray_tmp;
cv::Mat frame_bin;
cv::Mat hist;
- std::vector<cv::Mat> gray_split_channels;
- std::vector<cv::Mat> gray_absdiff_channels;
- cv::Mat float_absdiff_channel;
enum { max_blobs = 16 };