summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tracker-pt/point_extractor.cpp7
-rw-r--r--tracker-pt/point_extractor.h4
2 files changed, 5 insertions, 6 deletions
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 3808c408..655e1412 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -29,7 +29,6 @@ const std::vector<cv::Vec2f>& PointExtractor::extract_points(cv::Mat& frame)
}
// convert to grayscale
- cv::Mat frame_gray;
cv::cvtColor(frame, frame_gray, cv::COLOR_RGB2GRAY);
const double region_size_min = s.min_point_size;
@@ -61,14 +60,11 @@ const std::vector<cv::Vec2f>& PointExtractor::extract_points(cv::Mat& frame)
const int thres = s.threshold;
if (!s.auto_threshold)
{
- cv::Mat frame_bin;
cv::threshold(frame_gray, frame_bin, thres, 255, cv::THRESH_BINARY);
cv::findContours(frame_bin, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
}
else
{
- cv::Mat hist;
- constexpr int hist_c = 8;
cv::calcHist(std::vector<cv::Mat> { frame_gray },
std::vector<int> { 0 },
cv::Mat(),
@@ -76,7 +72,7 @@ const std::vector<cv::Vec2f>& PointExtractor::extract_points(cv::Mat& frame)
std::vector<int> { 256/hist_c },
std::vector<float> { 0, 256/hist_c },
false);
- const int sz = hist.rows*hist.cols;
+ const int sz = hist.cols * hist.rows;
int val = 0;
int cnt = 0;
constexpr int min_pixels = 250;
@@ -95,7 +91,6 @@ const std::vector<cv::Vec2f>& PointExtractor::extract_points(cv::Mat& frame)
val *= 240./256.;
//qDebug() << "val" << val;
- cv::Mat frame_bin;
cv::threshold(frame_gray, frame_bin, val, 255, CV_THRESH_BINARY);
cv::findContours(frame_bin, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
}
diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h
index 979cc8b6..ad8955fc 100644
--- a/tracker-pt/point_extractor.h
+++ b/tracker-pt/point_extractor.h
@@ -27,8 +27,12 @@ public:
settings_pt s;
private:
+ enum { hist_c = 8 };
std::vector<cv::Vec2f> points;
QMutex mtx;
+ cv::Mat frame_gray;
+ cv::Mat frame_bin;
+ cv::Mat hist;
};
#endif //POINTEXTRACTOR_H