Fix nan issue in features
[trackerpp.git] / include / MultiTracker.h
1 #ifndef _MULTI_TRACKER_H_
2 #define _MULTI_TRACKER_H_
3
4 #include "Tracker.h"
5 #include "Detector.h"
6 #include "SharedPtr.h"
7 #include "PredictorWrapper.h"
8 #include <opencv2/opencv.hpp>
9 #include <utility>
10 #include "Engine.h"
11
12 namespace suanzi {
13
14     TK_DECLARE_PTR(Patch);
15     TK_DECLARE_PTR(MultiTracker);
16     TK_DECLARE_PTR(Tracker);
17     TK_DECLARE_PTR(Engine);
18
19     class MultiTracker 
20     {
21     public:
22         MultiTracker(EngineWPtr e);
23         virtual ~MultiTracker();
24         void update(unsigned int total, const Detection* d, const cv::Mat& image);
25
26     private:
27         std::vector<TrackerPtr> trackers;
28         int max_id = 0;
29         PatchPtr createPatch(const cv::Mat& image, const Detection& d);
30         double distance(TrackerPtr t, const cv::Mat& image, const Detection& d);
31         void addTracker(TrackerPtr t);
32         PredictorWrapperPtr predictor;
33         cv::HOGDescriptor descriptor;
34         EngineWPtr engine;
35     };
36
37     class Patch
38     {
39     public:
40         ~Patch(){};
41         cv::Mat image_crop;
42         // hog is a hog descriptor of the image (calculated by hog.compute. size is 3780 )
43         // hue is a histogram of the image, (calcHist(), is a Mat with (width x height) 64 x 45)
44         std::pair<std::vector<double>, cv::Mat> features;
45         Detection detection;
46     protected:
47         friend class MultiTracker;
48         Patch(){};
49     };
50
51
52 }
53
54 #endif /* _MULTI_TRACKER_H_ */