diff --git a/modules/gapi/src/3rdparty/vasot/src/components/ot/mtt/objects_associator.cpp b/modules/gapi/src/3rdparty/vasot/src/components/ot/mtt/objects_associator.cpp index f2ad032dcb..9a4c3da433 100644 --- a/modules/gapi/src/3rdparty/vasot/src/components/ot/mtt/objects_associator.cpp +++ b/modules/gapi/src/3rdparty/vasot/src/components/ot/mtt/objects_associator.cpp @@ -141,6 +141,12 @@ ObjectsAssociator::ComputeRgbDistance(const std::vector &detections, if (tracking_per_class_ && (detections[d].class_label != tracklets[t]->label)) continue; + // Check if RGB features are available + auto t_rgb_features = tracklets[t]->GetRgbFeatures(); + if (!t_rgb_features || t_rgb_features->empty()) { + continue; // Skip if no RGB features are available + } + // Find best match in rgb feature history float min_dist = 1000.0f; for (const auto &t_rgb_feature : *(tracklets[t]->GetRgbFeatures())) { diff --git a/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.cpp b/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.cpp index 62e8d10cf6..7327325a4a 100644 --- a/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.cpp +++ b/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.cpp @@ -7,13 +7,15 @@ #include "tracklet.hpp" #include +#include namespace vas { namespace ot { Tracklet::Tracklet() : id(0), label(-1), association_idx(kNoMatchDetection), status(ST_DEAD), age(0), confidence(0.f), - occlusion_ratio(0.f), association_delta_t(0.f), association_fail_count(0) { + occlusion_ratio(0.f), association_delta_t(0.f), association_fail_count(0), + rgb_features_(std::make_shared>()) { } Tracklet::~Tracklet() { @@ -45,12 +47,13 @@ void Tracklet::RenewTrajectory(const cv::Rect2f &bounding_box) { trajectory_filtered.push_back(bounding_box); } -#define DEFINE_STRING_VAR(var_name, value) \ - std::stringstream __##var_name; \ - __##var_name << value; \ - std::string var_name = __##var_name.str(); +std::deque *Tracklet::GetRgbFeatures() { + return rgb_features_.get(); // Return the raw pointer from the shared_ptr +} -#define ROUND_F(value, scale) (round((value)*scale) / scale) +void Tracklet::AddRgbFeature(const cv::Mat &feature) { + rgb_features_->push_back(feature); +} std::string Tracklet::Serialize() const { #ifdef DUMP_OTAV @@ -97,10 +100,6 @@ std::string Tracklet::Serialize() const { #endif } -std::deque *Tracklet::GetRgbFeatures() { - return nullptr; -} - ZeroTermImagelessTracklet::ZeroTermImagelessTracklet() : Tracklet(), birth_count(1) { } diff --git a/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.hpp b/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.hpp index 762e3f6ea6..4ed9042d7a 100644 --- a/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.hpp +++ b/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.hpp @@ -13,6 +13,7 @@ #include #include +#include namespace vas { namespace ot { @@ -45,6 +46,7 @@ class Tracklet { virtual void RenewTrajectory(const cv::Rect2f &bounding_box); virtual std::deque *GetRgbFeatures(); + void AddRgbFeature(const cv::Mat &feature); virtual std::string Serialize() const; // Returns key:value with comma separated format public: @@ -63,6 +65,9 @@ class Tracklet { std::deque trajectory_filtered; cv::Rect2f predicted; // Result from Kalman prediction. It is for debugging (OTAV) mutable std::vector otav_msg; // Messages for OTAV + + private: + std::shared_ptr> rgb_features_; }; class ZeroTermImagelessTracklet : public Tracklet {