Skip to content

Commit

Permalink
added getter for the number of tracked features
Browse files Browse the repository at this point in the history
  • Loading branch information
petrlmat committed Apr 2, 2024
1 parent 22d0666 commit ca0285c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ov_core/src/track/TrackBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ void TrackBase::display_active(cv::Mat &img_out, int r1, int g1, int b1, int r2,
}
}

size_t TrackBase::get_num_tracks() {

std::map<size_t, cv::Mat> img_last_cache;
std::unordered_map<size_t, std::vector<size_t>> ids_last_cache;
{
std::lock_guard<std::mutex> lckv(mtx_last_vars);
img_last_cache = img_last;
ids_last_cache = ids_last;
}

size_t num_tracks = 0;

for (auto const &pair : img_last_cache) {
num_tracks += ids_last_cache[pair.first].size();
}

return num_tracks;
}

void TrackBase::display_history(cv::Mat &img_out, int r1, int g1, int b1, int r2, int g2, int b2, std::vector<size_t> highlighted,
std::string overlay) {

Expand Down Expand Up @@ -245,4 +264,4 @@ void TrackBase::change_feat_id(size_t id_old, size_t id_new) {
}
}
}
}
}
2 changes: 2 additions & 0 deletions ov_core/src/track/TrackBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class TrackBase {
*/
virtual void display_active(cv::Mat &img_out, int r1, int g1, int b1, int r2, int g2, int b2, std::string overlay = "");


size_t get_num_tracks();
/**
* @brief Shows a "trail" for each feature (i.e. its history)
* @param img_out image to which we will overlayed features on
Expand Down

0 comments on commit ca0285c

Please sign in to comment.