Fix nan issue in features
[trackerpp.git] / include / Tracker.h
1 #ifndef _TRACKER_H_
2 #define _TRACKER_H_
3
4 #include <opencv2/opencv.hpp>
5 #include <string>
6 #include <vector>
7 #include "SharedPtr.h"
8 #include "MultiTracker.h"
9 #include "Detector.h"
10
11 namespace suanzi {
12
13     TK_DECLARE_PTR(Tracker);
14     TK_DECLARE_PTR(Patch);
15     typedef enum 
16     {
17         Fire = -1,
18         Active = 2,
19         Lost,
20         Delete
21     } TrackerStatus;
22
23     class Tracker
24     {
25     public:
26         Tracker(const cv::Mat& image, const Detection& d, int id = 0);
27         virtual ~Tracker();
28         void updateState(const cv::Mat& image);
29         void addPatch(PatchPtr p);
30         void correct(const cv::Mat& image, const Detection& d);
31         void predict();
32         std::vector<PatchPtr> patches;
33         Detection detection;
34         TrackerStatus status = TrackerStatus::Fire;
35         static constexpr int MaxPatch = 5;
36
37     private:
38         TrackerStatus preStatus = TrackerStatus::Fire;
39         int id;
40         int age = 1;
41         int last_active = 1;
42         cv::KalmanFilter KF = {4,2};
43     };
44 }
45
46 #endif /* _TRACKER_H_ */