-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy patharuco.i
More file actions
156 lines (127 loc) · 3.65 KB
/
Copy patharuco.i
File metadata and controls
156 lines (127 loc) · 3.65 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/************************************
Swig Module for ArUco Python wrapper
************************************/
// module name
%module(directors="1") aruco
// needed
%include <std_string.i>
%include "pyabc.i"
%include "std_vector.i"
%{
#define SWIG_FILE_WITH_INIT
using namespace std;
%}
// NumPy <--> OpenCV typemaps
%include "okapi-typemaps.i"
//%include <opencv.i>
//%cv_instantiate_all_defaults
/************************************
ArUco stuff
************************************/
%{
// #define SWIG_FILE_WITH_INIT
#include<aruco_cvversioning.h>
#include<aruco_export.h>
#include<aruco.h>
#include<cameraparameters.h>
#include<cvdrawingutils.h>
#include<debug.h>
#include<dictionary_based.h>
#include<dictionary.h>
#include<fractaldetector.h>
#include<ippe.h>
#include<levmarq.h>
#include<markerdetector.h>
#include<markerdetector_impl.h>
#include<marker.h>
#include<markerlabeler.h>
#include<markermap.h>
#include<picoflann.h>
#include<posetracker.h>
#include<timers.h>
// #include<fractallabelers/fractallabeler.h>
// #include<fractallabelers/fractalmarker.h>
// #include<fractallabelers/fractalmarkerset.h>
// #include<fractallabelers/fractalposetracker.h>
#include<dcf/dcfmarkermaptracker.h>
#include<dcf/dcfmarkertracker.h>
#include<dcf/dcf_utils.h>
#include<dcf/trackerimpl.h>
// using namespace aruco;
%}
// Marker is std::vector< cv::Point2f >, template definition
// needed for std::vector -> Python List conversion
//namespace std {
// // for vector<int> to Python list conversion
// %template(VectorInt) vector<int>;
//};
namespace std {
%template(VectorInt) vector<int>;
%template(Point2fVec) vector<cv::Point2f>;
%template(Point3fVec) vector<cv::Point3f>;
%template(MarkerPoint3fVecVec) vector< aruco::Marker, allocator< aruco::Marker > >;
%template(VectorMarker3DInfo) vector< aruco::Marker3DInfo >;
};
%include <aruco.h>
%include <aruco_export.h>
%include <cameraparameters.h>
%include <cvdrawingutils.h>
%include <debug.h>
%include <dictionary.h>
//%include <ippe.h>
%include <levmarq.h>
%include <marker.h>
/***
Workaround:
std::vector<Point2f>.at() --> Point2f conversion doesn't work
so I just implemented the Python __getitem__() method for aruco::Marker
to get corner points of the Marker object and added VectorIterator to
support for-loops
***/
%pythoncode %{
class VectorIterator(object):
def __init__(self, pointerToVector):
self.pointerToVector = pointerToVector
self.index = -1
def __iter__(self):
return self
def __next__(self):
self.index += 1
if self.index < len(self.pointerToVector):
return self.pointerToVector[self.index]
else:
raise StopIteration
def next(self):
self.index += 1
if self.index < len(self.pointerToVector):
return self.pointerToVector[self.index]
else:
raise StopIteration
%}
%extend aruco::Marker {
public:
cv::Point2f __getitem__(int i) {
return $self->at($self->size()-1);
}
int __len__() {
return $self->size();
}
}
%extend aruco::Marker {
%pythoncode {
def __iter__(self):
return VectorIterator(self)
}
}
%include <markerdetector.h>
%include <markerdetector_impl.h>
%include <markerlabeler.h>
%include <fractaldetector.h>
%include <markermap.h>
%include <picoflann.h>
%include <posetracker.h>
%include <fractallabelers/fractalposetracker.h>
%include <fractallabelers/fractallabeler.h>
%include <fractallabelers/fractalmarkerset.h>
%include <fractallabelers/fractalmarker.h>
%include <timers.h>