summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/point_extractor.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-19 20:44:41 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-19 20:46:28 +0100
commitfba00166c94f066bf0d8d2174b508d2f849abe53 (patch)
tree71eac5737e99bcc435ce2658cd459193f6d1f5d7 /tracker-pt/point_extractor.cpp
parent90138a999b4c95afeb9a49d355b0234b6145e221 (diff)
tracker/pt: don't copy points array needlessly
Diffstat (limited to 'tracker-pt/point_extractor.cpp')
-rw-r--r--tracker-pt/point_extractor.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 6118f3d2..3808c408 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -16,10 +16,17 @@
PointExtractor::PointExtractor()
{
}
-std::vector<cv::Vec2f> PointExtractor::extract_points(cv::Mat& frame)
+
+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);
+ frame_bin = cv::Mat(frame.rows, frame.cols, CV_8U);;
+ }
// convert to grayscale
cv::Mat frame_gray;
@@ -151,9 +158,11 @@ std::vector<cv::Vec2f> PointExtractor::extract_points(cv::Mat& frame)
using b = const blob;
std::sort(blobs.begin(), blobs.end(), [](b& b1, b& b2) {return b1.confid > b2.confid;});
+ points.reserve(blobs.size());
+
QMutexLocker l(&mtx);
- points.clear();
+ points.clear();
for (auto& b : blobs)
{