wangrong
2025-01-03 2c4b8838f89bebca97615c5f0bac2c58e0349771
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
 
#include <vector>
#include <set>
#include <map>
#include "vp_track_node.h"
#include "sort/Hungarian.h"
#include "sort/KalmanTracker.h"
 
namespace vp_nodes {
    // track node using sort
    class vp_sort_track_node: public vp_track_node
    {
    private:
        /* config data for sort algo */
        /* data */
        typedef struct TrackingBox
        {
            //int frame;
            int id;
            Rect_<float> box;
        }TrackingBox;
 
        int max_age = 1;
        int min_hits = 3;
        double iouThreshold = 0.5;
        // vector<KalmanTracker> trackers;
        std::map<int, std::vector<KalmanTracker>> all_trackers;
        std::vector<cv::Rect_<float>> predictedBoxes;
        std::vector<vector<double>> iouMatrix;
        std::vector<int> assignment;
        std::set<int> unmatchedDetections;
        std::set<int> unmatchedTrajectories;
        std::set<int> allItems;
        std::set<int> matchedItems;
        std::vector<cv::Point> matchedPairs;
        std::vector<TrackingBox> frameTrackingResult;
    private:
        double GetIOU(cv::Rect_<float> bb_test, cv::Rect_<float> bb_gt);
    protected:
        // fill track_ids using sort algo
        virtual void track(int channel_index, const std::vector<vp_objects::vp_rect>& target_rects, 
                        const std::vector<std::vector<float>>& target_embeddings, 
                        std::vector<int>& track_ids) override;
    public:
        vp_sort_track_node(std::string node_name, vp_track_for track_for = vp_track_for::NORMAL);
        virtual ~vp_sort_track_node();
    };
 
}