-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtrack.h
93 lines (77 loc) · 2.33 KB
/
track.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* ocv_ar - OpenCV based Augmented Reality library
*
* Tracker class -- header file.
*
* Author: Markus Konrad <[email protected]>, June 2014.
* INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/
*
* See LICENSE for license.
*/
#ifndef OCV_AR_TRACK_H
#define OCV_AR_TRACK_H
#include <map>
#include <vector>
#include <opencv2/core/core.hpp>
#include "types.h"
#include "detect.h"
#include "threading.h"
namespace ocv_ar {
/**
* Marker map. Holds one marker mapped to a marker id.
* Note that this means that only unique markers in a
* scene can be tracked for now!
*/
typedef std::map<int, Marker> MarkerMap;
typedef std::pair<int, Marker> MarkerMapPair;
/**
* Marker tracker.
*
* Note that that only unique markers in a scene can be tracked for now!
* This means that there should not be two or more markers with the same id
* in the scene.
*/
class Track {
public:
/**
* Constructor. Pass a pointer to a detector instance <detectorPtr>.
*/
Track(Detect *detectorPtr) : newMarkersFresh(false), detectionRunning(false),
detector(detectorPtr)
{
Threading::init();
};
/**
* Detect markers in <frame>.
*/
void detect(const cv::Mat *frame);
/**
* Update 3D poses of the detected markers.
*/
void update();
/**
* Lock the detected markers data. This is importent when detect(), update()
* and/or drawing of the markers is done in different threads.
*/
void lockMarkers();
/**
* Unlock the detected markers data.
*/
void unlockMarkers();
/**
* Return a pointer to the detected markers map.
* The mapping is marker id -> Marker object.
*/
const MarkerMap *getMarkers() const { return &markers; }
private:
std::vector<Marker> newMarkers; // vector that holds Marker objects from the
// last time when detect() was called
bool newMarkersFresh; // is true if detect() was called before and is set
// to false in update()
MarkerMap markers; // markers to be tracked. mapping is
// marker id -> Marker object
bool detectionRunning; // is true while detect() is running
Detect *detector; // weak ref to Detect object
};
}
#endif