summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-02-17 04:40:53 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-02-17 04:41:10 +0100
commit38306b389951c69d050e3e4b929b442b5bd0ada5 (patch)
tree5f282d68ca80bae8e64000ceb7315ff12c6efa1c /tracker-pt
parent925c0811d6b24069eb9f527c2c02301cc1ba5ca4 (diff)
tracker/pt: protect get_n_points()
There's a race here since further accesses to the points array aren't protected by a mutex in the extractor class. There's no race in "get_points()" in the extractor since it's only used in same thread where updates take place.
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h2
-rw-r--r--tracker-pt/point_extractor.h1
2 files changed, 2 insertions, 1 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h
index dff0c30a..5f30c66f 100644
--- a/tracker-pt/ftnoir_tracker_pt.h
+++ b/tracker-pt/ftnoir_tracker_pt.h
@@ -41,7 +41,7 @@ public:
void data(double* data) override;
Affine pose() { return point_tracker.pose(); }
- int get_n_points() { return point_extractor.get_points().size(); }
+ int get_n_points() { return point_extractor.get_n_points(); }
bool get_cam_info(CamInfo* info) { QMutexLocker lock(&camera_mtx); return camera.get_info(*info); }
public slots:
void apply_settings();
diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h
index 030251ff..8bcc2437 100644
--- a/tracker-pt/point_extractor.h
+++ b/tracker-pt/point_extractor.h
@@ -23,6 +23,7 @@ public:
// WARNING: returned reference is valid as long as object
const std::vector<cv::Vec2f> &extract_points(cv::Mat &frame);
const std::vector<cv::Vec2f>& get_points() { QMutexLocker l(&mtx); return points; }
+ int get_n_points() const { QMutexLocker l(&mtx); return points.size(); }
PointExtractor();
settings_pt s;