Skip to content

Commit 1d6a595

Browse files
authored
[Issue #626] - Frame publisher function to get landmarks and keypoints with lock held (#628)
* Keypoints & Landmark sizes do not match #626 - Add function to fetch both while mtx held * [#626] Refactor - Change order of function name to intuitively match returned pair order
1 parent 27c5915 commit 1d6a595

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/stella_vslam/publish/frame_publisher.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ std::string frame_publisher::get_tracking_state() {
9494
return state_str;
9595
}
9696

97+
std::pair<std::vector<cv::KeyPoint>, std::vector<std::shared_ptr<data::landmark>>> frame_publisher::get_keypoints_and_landmarks() {
98+
std::lock_guard<std::mutex> lock(mtx_);
99+
100+
return std::make_pair(curr_keypts_, curr_lms_);
101+
}
102+
97103
std::vector<cv::KeyPoint> frame_publisher::get_keypoints() {
98104
std::lock_guard<std::mutex> lock(mtx_);
99105
return curr_keypts_;
@@ -194,6 +200,7 @@ void frame_publisher::update(const std::vector<std::shared_ptr<data::landmark>>&
194200

195201
img.copyTo(img_);
196202

203+
assert(keypts.size() == curr_lms.size());
197204
curr_keypts_ = keypts;
198205
tracking_time_elapsed_ms_ = tracking_time_elapsed_ms;
199206
extraction_time_elapsed_ms_ = extraction_time_elapsed_ms;

src/stella_vslam/publish/frame_publisher.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <mutex>
88
#include <vector>
99
#include <memory>
10+
#include <utility>
1011

1112
#include <opencv2/core/mat.hpp>
1213
#include <opencv2/core/types.hpp>
@@ -61,6 +62,8 @@ class frame_publisher {
6162

6263
std::vector<std::shared_ptr<data::landmark>> get_landmarks();
6364

65+
std::pair<std::vector<cv::KeyPoint>, std::vector<std::shared_ptr<data::landmark>>> get_keypoints_and_landmarks();
66+
6467
cv::Mat get_image();
6568

6669
double get_tracking_time_elapsed_ms();

0 commit comments

Comments
 (0)