Skip to content

Commit

Permalink
[Issue #626] - Frame publisher function to get landmarks and keypoint…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
Skwangles authored Jan 6, 2025
1 parent 27c5915 commit 1d6a595
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/stella_vslam/publish/frame_publisher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ std::string frame_publisher::get_tracking_state() {
return state_str;
}

std::pair<std::vector<cv::KeyPoint>, std::vector<std::shared_ptr<data::landmark>>> frame_publisher::get_keypoints_and_landmarks() {
std::lock_guard<std::mutex> lock(mtx_);

return std::make_pair(curr_keypts_, curr_lms_);
}

std::vector<cv::KeyPoint> frame_publisher::get_keypoints() {
std::lock_guard<std::mutex> lock(mtx_);
return curr_keypts_;
Expand Down Expand Up @@ -194,6 +200,7 @@ void frame_publisher::update(const std::vector<std::shared_ptr<data::landmark>>&

img.copyTo(img_);

assert(keypts.size() == curr_lms.size());
curr_keypts_ = keypts;
tracking_time_elapsed_ms_ = tracking_time_elapsed_ms;
extraction_time_elapsed_ms_ = extraction_time_elapsed_ms;
Expand Down
3 changes: 3 additions & 0 deletions src/stella_vslam/publish/frame_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <mutex>
#include <vector>
#include <memory>
#include <utility>

#include <opencv2/core/mat.hpp>
#include <opencv2/core/types.hpp>
Expand Down Expand Up @@ -61,6 +62,8 @@ class frame_publisher {

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

std::pair<std::vector<cv::KeyPoint>, std::vector<std::shared_ptr<data::landmark>>> get_keypoints_and_landmarks();

cv::Mat get_image();

double get_tracking_time_elapsed_ms();
Expand Down

0 comments on commit 1d6a595

Please sign in to comment.