Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #626] - Frame publisher function to get landmarks and keypoints with lock held #628

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Copy link
Contributor Author

@Skwangles Skwangles Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen anywhere in the frame_publisher that asserts this assumption, and it is not clear to me as a reader the relationship between keypts and curr_lms, so I thought i'd add one.

With the issue with iridescence viewer having these two mismatched, it just feels right to assert the assumption here to make clear their relationship and track any issues further up the chain.

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
Loading