forked from vaiv/Random-Dot-Marker-SLAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotmarkers.cpp
90 lines (75 loc) · 1.98 KB
/
dotmarkers.cpp
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
#include "dotmarkers.h"
DotMarkers::DotMarkers()
{
Max_ID=1;
}
bool DotMarkers::find(Dot& Marker)
{
int count = 0;
for(int i=0;i<Markers.size();i++)
{
Dot curr_Marker = Markers[i];
if( curr_Marker.withinROI(Marker.getCenter()) && curr_Marker.matchDescriptors(Marker.getDescriptors()))
{
Marker.setId(curr_Marker.getId());
srand(time(NULL));
if(rand()%10==0)
Markers[i].updateMotionModel(Marker);
std::cout<<"number of candidates evaluated"<<count<<std::endl;
return true;
}
}
return false;
}
bool DotMarkers::insert(Dot& Marker)
{
Marker.setId(Max_ID);
Marker.resetMotionModel();
Max_ID++;
Markers.push_back(Marker);
}
bool DotMarkers::set3DPos(Dot Marker, cv::Point3f pt)
{
for(int i=0;i<Markers.size();i++)
{
if(Markers[i].matchDescriptors(Marker.getDescriptors()))
{
Markers[i].set3DPos(pt);
return true;
}
}
return false;
}
bool DotMarkers::get3DPos(long id, cv::Point3f &pt)
{
for(int i=0;i<Markers.size();i++)
{
Dot curr_Marker = Markers[i];
if(curr_Marker.getId() == id)
{
curr_Marker.get3DPos(pt);
if(pt.x!=0 || pt.y!=0 || pt.z!=0)
return true;
}
}
return false;
}
//Mat DotMarkers::getAllDescriptors()
//{
// int DescSize;
// cv::Mat allDesc(Markers.size(),DescSize,CV_32FC1);
// for(int i=0;i<Markers.size();i++)
// {
// std::vector< std::vector<int> >> Desc = Markers[i].getDescriptors();
// for(int j=0;j<DescSize;j++)
// {
// }
// }
//}
void DotMarkers::debug()
{
std::vector< std::vector<int> > Desc2 = Markers[1].getDescriptors();
std::vector< std::vector<int> > Desc12 = Markers[20].getDescriptors();
std::vector< std::vector<int> > Desc20 = Markers[24].getDescriptors();
//std::vector< std::vector<int> > Desc27 = Markers[26].getDescriptors();
}