Merge lp:~joseluis-hidalgo+launchpad/artoolkitplus/ARToolkitPlus-win into lp:artoolkitplus

Proposed by Jose L. Hidalgo Valiño
Status: Merged
Merged at revision: 97
Proposed branch: lp:~joseluis-hidalgo+launchpad/artoolkitplus/ARToolkitPlus-win
Merge into: lp:artoolkitplus
Diff against target: 744 lines (+207/-112)
18 files modified
CMakeLists.txt (+45/-0)
include/ARToolKitPlus/Camera.h (+3/-4)
include/ARToolKitPlus/Tracker.h (+9/-9)
include/ARToolKitPlus/TrackerMultiMarker.h (+1/-1)
include/ARToolKitPlus/TrackerSingleMarker.h (+2/-2)
include/ARToolKitPlus/ar.h (+3/-3)
include/ARToolKitPlus/arBitFieldPattern.h (+3/-3)
include/ARToolKitPlus/arGetInitRot2Sub.h (+2/-2)
include/ARToolKitPlus/arMulti.h (+2/-2)
include/ARToolKitPlus/config.h (+32/-0)
include/ARToolKitPlus/extra/BCH.h (+3/-1)
include/ARToolKitPlus/extra/Hull.h (+14/-12)
include/ARToolKitPlus/extra/rpp.h (+3/-1)
include/ARToolKitPlus/matrix.h (+9/-9)
include/ARToolKitPlus/vector.h (+6/-6)
src/Tracker.cpp (+1/-0)
src/TrackerSingleMarker.cpp (+2/-2)
src/core/arGetCode.cpp (+67/-55)
To merge this branch: bzr merge lp:~joseluis-hidalgo+launchpad/artoolkitplus/ARToolkitPlus-win
Reviewer Review Type Date Requested Status
Pavel Rojtberg Approve
Review via email: mp+39896@code.launchpad.net

Description of the change

Added support for Windows+visual_Studio

apart from adding a macro to export symbols in visual studio I changed some code related to some matrix creation on heap, Visual Studio doesn't support C99 VLAs.

Also added a CmakeLists.txt to compile using Cmake, but that's optional.

To post a comment you must log in.
Revision history for this message
Pavel Rojtberg (rojtberg) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'CMakeLists.txt'
2--- CMakeLists.txt 1970-01-01 00:00:00 +0000
3+++ CMakeLists.txt 2010-11-02 21:11:10 +0000
4@@ -0,0 +1,45 @@
5+cmake_minimum_required(VERSION 2.4)
6+project( AR )
7+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
8+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
9+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
10+
11+link_directories( ${LIBRARY_OUTPUT_PATH} )
12+include_directories( "${AR_SOURCE_DIR}/include" )
13+
14+# ARToolkitPlus core files (headers and sources)
15+file(GLOB_RECURSE HEADERS_AR "${AR_SOURCE_DIR}/include/ARToolkitPlus/*.h")
16+file(GLOB SOURCES_AR
17+ "${AR_SOURCE_DIR}/src/*.cpp"
18+ "${AR_SOURCE_DIR}/src/core/*.cpp"
19+ "${AR_SOURCE_DIR}/src/extra/*.cpp"
20+ "${AR_SOURCE_DIR}/src/librpp/*.cpp"
21+ )
22+
23+add_library(ARToolkitPlus
24+ SHARED
25+ ${HEADERS_AR}
26+ ${SOURCES_AR}
27+)
28+
29+set_target_properties(ARToolkitPlus PROPERTIES DEBUG_POSTFIX d)
30+
31+if(WIN32)
32+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
33+ add_definitions(-DAR_LIBRARY)
34+else(WIN32)
35+ set(CMAKE_C_FLAGS_DEBUG "-Wall -g ")
36+ set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g ")
37+endif(WIN32)
38+
39+if(SLB_BUILD_TESTS)
40+ enable_testing()
41+ add_subdirectory(tests)
42+endif(SLB_BUILD_TESTS)
43+
44+if(SLB_BUILD_EXAMPLES)
45+ file(GLOB ALL_EXAMPLES "${SLB_SOURCE_DIR}/examples/*")
46+ foreach(example ${ALL_EXAMPLES})
47+ add_subdirectory(${example})
48+ endforeach(example)
49+endif(SLB_BUILD_EXAMPLES)
50
51=== modified file 'include/ARToolKitPlus/Camera.h'
52--- include/ARToolKitPlus/Camera.h 2010-02-09 14:44:21 +0000
53+++ include/ARToolKitPlus/Camera.h 2010-11-02 21:11:10 +0000
54@@ -25,7 +25,6 @@
55 #include <string>
56 #include <ARToolKitPlus/config.h>
57
58-using std::string;
59
60 namespace ARToolKitPlus {
61
62@@ -36,7 +35,7 @@
63 * this class used to be called ARParam in the classical ARToolkit
64 * so do not wonder because of the method names
65 */
66-class Camera {
67+class AR_EXPORT Camera {
68 public:
69 int xsize, ysize;
70 ARFloat mat[3][4];
71@@ -48,9 +47,9 @@
72 Camera* clone();
73 bool changeFrameSize(const int frameWidth, const int frameHeight);
74 void printSettings();
75- string getFileName() const;
76+ std::string getFileName() const;
77 protected:
78- string fileName;
79+ std::string fileName;
80
81 // http://www.vision.caltech.edu/bouguetj/calib_doc/htmls/parameters.html
82 ARFloat cc[2];
83
84=== modified file 'include/ARToolKitPlus/Tracker.h'
85--- include/ARToolKitPlus/Tracker.h 2010-03-05 14:31:19 +0000
86+++ include/ARToolKitPlus/Tracker.h 2010-11-02 21:11:10 +0000
87@@ -32,7 +32,6 @@
88
89 #include <vector>
90
91-using std::vector;
92
93 namespace ARToolKitPlus {
94
95@@ -50,7 +49,7 @@
96 * - TrackerSingleMarker
97 * - TrackerMultiMarker
98 */
99-class Tracker {
100+class AR_EXPORT Tracker {
101 public:
102 Tracker(int imWidth, int imHeight, int maxImagePatterns = 8, int pattWidth = 6, int pattHeight = 6, int pattSamples = 6,
103 int maxLoadPatterns = 0);
104@@ -338,7 +337,7 @@
105 int
106 arGetCode(uint8_t *image, int *x_coord, int *y_coord, int *vertex, int *code, int *dir, ARFloat *cf, int thresh);
107
108- int arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t **ext_pat[3]);
109+ int arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t *ext_pat);
110
111 int pattern_match(uint8_t *data, int *code, int *dir, ARFloat *cf);
112
113@@ -501,7 +500,7 @@
114 arPrevInfo *prev_info;
115 int prev_num;
116
117- vector<vector<arPrevInfo> > sprev_info;
118+ std::vector<std::vector<arPrevInfo> > sprev_info;
119 int sprev_num[2];
120
121 // arDetectMarker2.cpp
122@@ -514,16 +513,16 @@
123 // arGetCode.cpp
124 int pattern_num;
125 int *patf;
126- vector<vector<vector<int> > > pat;
127+ std::vector<std::vector<std::vector<int> > > pat;
128 ARFloat (*patpow)[4];
129- vector<vector<vector<int> > > patBW;
130+ std::vector<std::vector<std::vector<int> > > patBW;
131 ARFloat (*patpowBW)[4];
132
133- vector<vector<ARFloat> > evec;
134+ std::vector<std::vector<ARFloat> > evec;
135 ARFloat (*epat)[4][EVEC_MAX];
136 int evec_dim;
137 int evecf;
138- vector<vector<ARFloat> > evecBW;
139+ std::vector<std::vector<ARFloat> > evecBW;
140 ARFloat (*epatBW)[4][EVEC_MAX];
141 int evec_dimBW;
142 int evecBWf;
143@@ -592,7 +591,8 @@
144
145 HULL_TRACKING_MODE hullTrackingMode;
146
147- static int screenWidth, screenHeight;
148+ static int screenWidth;
149+ static int screenHeight;
150 int thresh;
151
152 ARFloat gl_para[16];
153
154=== modified file 'include/ARToolKitPlus/TrackerMultiMarker.h'
155--- include/ARToolKitPlus/TrackerMultiMarker.h 2010-03-05 14:31:19 +0000
156+++ include/ARToolKitPlus/TrackerMultiMarker.h 2010-11-02 21:11:10 +0000
157@@ -36,7 +36,7 @@
158 * Furthermore it uses only 4 'good' points of the convex hull to do the pose estimation.
159 * You can override this using the according methods.
160 */
161-class TrackerMultiMarker: public Tracker {
162+class AR_EXPORT TrackerMultiMarker: public Tracker {
163 public:
164 /**
165 * These parameters control the way the toolkit warps a found
166
167=== modified file 'include/ARToolKitPlus/TrackerSingleMarker.h'
168--- include/ARToolKitPlus/TrackerSingleMarker.h 2010-03-05 14:31:19 +0000
169+++ include/ARToolKitPlus/TrackerSingleMarker.h 2010-11-02 21:11:10 +0000
170@@ -36,7 +36,7 @@
171 *
172 * If you need multi-marker tracking use TrackerMultiMarker.
173 */
174-class TrackerSingleMarker: public Tracker {
175+class AR_EXPORT TrackerSingleMarker: public Tracker {
176 public:
177 /**
178 * These parameters control the way the toolkit warps a found
179@@ -76,7 +76,7 @@
180 * pass the image as RGBX (32-bits)
181 * @return detected markers in image
182 */
183- virtual vector<int> calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info = NULL, int* nNumMarkers = NULL);
184+ virtual std::vector<int> calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info = NULL, int* nNumMarkers = NULL);
185
186 /**
187 * manually select one of the detected markers
188
189=== modified file 'include/ARToolKitPlus/ar.h'
190--- include/ARToolKitPlus/ar.h 2010-02-08 14:55:16 +0000
191+++ include/ARToolKitPlus/ar.h 2010-11-02 21:11:10 +0000
192@@ -40,7 +40,7 @@
193 ARFloat pos[2];
194 ARFloat line[4][3];
195 ARFloat vertex[4][2];
196-} ARMarkerInfo;
197+} AR_EXPORT ARMarkerInfo;
198
199 typedef struct {
200 int area;
201@@ -49,12 +49,12 @@
202 int x_coord[AR_CHAIN_MAX];
203 int y_coord[AR_CHAIN_MAX];
204 int vertex[5];
205-} ARMarkerInfo2;
206+} AR_EXPORT ARMarkerInfo2;
207
208 typedef struct {
209 ARMarkerInfo marker;
210 int count;
211-} arPrevInfo;
212+} AR_EXPORT arPrevInfo;
213
214 } // namespace ARToolKitPlus
215
216
217=== modified file 'include/ARToolKitPlus/arBitFieldPattern.h'
218--- include/ARToolKitPlus/arBitFieldPattern.h 2010-02-12 15:11:58 +0000
219+++ include/ARToolKitPlus/arBitFieldPattern.h 2010-11-02 21:11:10 +0000
220@@ -76,13 +76,13 @@
221
222 // some internal methods. primarily needed for
223 // marker printing, etc.
224-void generatePatternSimple(int nID, IDPATTERN& nPattern);
225+void AR_EXPORT generatePatternSimple(int nID, IDPATTERN& nPattern);
226
227-void generatePatternBCH(int nID, IDPATTERN& nPattern);
228+void AR_EXPORT generatePatternBCH(int nID, IDPATTERN& nPattern);
229
230 // static void setBit(IDPATTERN& pat, int which);
231
232-bool isBitSet(IDPATTERN pat, int which);
233+bool AR_EXPORT isBitSet(IDPATTERN pat, int which);
234
235 } // namespace ARToolKitPlus
236
237
238=== modified file 'include/ARToolKitPlus/arGetInitRot2Sub.h'
239--- include/ARToolKitPlus/arGetInitRot2Sub.h 2010-02-12 15:11:58 +0000
240+++ include/ARToolKitPlus/arGetInitRot2Sub.h 2010-11-02 21:11:10 +0000
241@@ -25,7 +25,7 @@
242
243 namespace rpp {
244
245-void arGetInitRot2_sub(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],
246+void AR_EXPORT arGetInitRot2_sub(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],
247 const rpp_vec *model, const rpp_vec *iprts, const unsigned int model_iprts_size, const rpp_mat R_init,
248 const bool estimate_R_init, const rpp_float epsilon, const rpp_float tolerance,
249 const unsigned int max_iterations);
250@@ -33,4 +33,4 @@
251 } // namespace rpp
252
253
254-#endif //__ARTOOLKITPLUS_ARGETINITROT2SUB_HEADERFILE__
255+#endif //__ARTOOLKITPLUS_ARGETINITROT2SUB_HEADERFILE__
256
257=== modified file 'include/ARToolKitPlus/arMulti.h'
258--- include/ARToolKitPlus/arMulti.h 2010-03-05 14:31:19 +0000
259+++ include/ARToolKitPlus/arMulti.h 2010-11-02 21:11:10 +0000
260@@ -37,7 +37,7 @@
261 int visible;
262 /*---*/
263 int visibleR;
264-} ARMultiEachMarkerInfoT;
265+} AR_EXPORT ARMultiEachMarkerInfoT;
266
267 typedef struct {
268 ARMultiEachMarkerInfoT *marker;
269@@ -46,7 +46,7 @@
270 int prevF;
271 /*---*/
272 ARFloat transR[3][4];
273-} ARMultiMarkerInfoT;
274+} AR_EXPORT ARMultiMarkerInfoT;
275
276
277 } // namespace ARToolKitPlus
278
279=== modified file 'include/ARToolKitPlus/config.h' (properties changed: -x to +x)
280--- include/ARToolKitPlus/config.h 2010-02-12 14:55:53 +0000
281+++ include/ARToolKitPlus/config.h 2010-11-02 21:11:10 +0000
282@@ -96,5 +96,37 @@
283 #define getLUM8_from_RGB565(ptr) RGB565_to_LUM8_LUT[ (*(unsigned short*)(ptr)) ]
284 #endif //SMALL_LUM8_TABLE
285
286+// disable VisualStudio warnings
287+#if defined(_MSC_VER) && !defined(AR_ENABLE_MSVC_WARNINGS)
288+ #pragma warning( disable : 4244 )
289+ #pragma warning( disable : 4251 )
290+ #pragma warning( disable : 4275 )
291+ #pragma warning( disable : 4512 )
292+ #pragma warning( disable : 4267 )
293+ #pragma warning( disable : 4702 )
294+ #pragma warning( disable : 4511 )
295+#endif
296+
297+// Support for Visual Studio compilation
298+#if defined(AR_STATIC)
299+ #define AR_EXPORT
300+#else
301+ #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
302+ # if defined( AR_LIBRARY )
303+ # define AR_EXPORT __declspec(dllexport)
304+ # else
305+ # define AR_EXPORT __declspec(dllimport)
306+ # endif
307+ #else
308+ # define AR_EXPORT
309+ #endif
310+#endif
311+
312+#ifdef _MSC_VER
313+# if (_MSC_VER >= 1300)
314+# define __STL_MEMBER_TEMPLATES
315+# endif
316+#endif
317+
318 #endif // AR_CONFIG_H
319
320
321=== modified file 'include/ARToolKitPlus/extra/BCH.h'
322--- include/ARToolKitPlus/extra/BCH.h 2010-02-12 15:11:58 +0000
323+++ include/ARToolKitPlus/extra/BCH.h 2010-11-02 21:11:10 +0000
324@@ -22,6 +22,8 @@
325 #ifndef __BCH_CODE__H__
326 #define __BCH_CODE__H__
327
328+#include <ARToolKitPlus/config.h>
329+
330 #include <vector>
331
332 namespace ARToolKitPlus {
333@@ -62,7 +64,7 @@
334 // static void printBitPattern(_64bits n, int n_bits);
335
336
337-class BCH
338+class AR_EXPORT BCH
339 // this class implements a (36, 12, 9) binary BCH encoder/decoder
340 {
341 public:
342
343=== modified file 'include/ARToolKitPlus/extra/Hull.h'
344--- include/ARToolKitPlus/extra/Hull.h 2010-02-12 15:11:58 +0000
345+++ include/ARToolKitPlus/extra/Hull.h 2010-11-02 21:11:10 +0000
346@@ -22,12 +22,14 @@
347 #ifndef __ARTOOLKITPLUS_HULL_HEADERFILE__
348 #define __ARTOOLKITPLUS_HULL_HEADERFILE__
349
350+#include <ARToolKitPlus/config.h>
351+
352 namespace ARToolKitPlus {
353
354 const int MAX_HULL_POINTS = 64; // support up to 16 visible markers
355
356
357-struct MarkerPoint {
358+struct AR_EXPORT MarkerPoint {
359 typedef int coord_type;
360
361 coord_type x, y;
362@@ -38,17 +40,17 @@
363 return nValue >= 0 ? nValue : -nValue;
364 }
365
366-int nearHull_2D(const MarkerPoint* P, int n, int k, MarkerPoint* H);
367-
368-void findLongestDiameter(const MarkerPoint* nPoints, int nNumPoints, int &nIdx0, int &nIdx1);
369-
370-void findFurthestAway(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int& nIdxFarthest);
371-
372-void maximizeArea(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int nIdx2, int& nIdxMax);
373-
374-void sortIntegers(int& nIdx0, int& nIdx1, int& nIdx2);
375-
376-void sortInLastInteger(int& nIdx0, int& nIdx1, int& nIdx2, int &nIdx3);
377+AR_EXPORT int nearHull_2D(const MarkerPoint* P, int n, int k, MarkerPoint* H);
378+
379+AR_EXPORT void findLongestDiameter(const MarkerPoint* nPoints, int nNumPoints, int &nIdx0, int &nIdx1);
380+
381+AR_EXPORT void findFurthestAway(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int& nIdxFarthest);
382+
383+AR_EXPORT void maximizeArea(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int nIdx2, int& nIdxMax);
384+
385+AR_EXPORT void sortIntegers(int& nIdx0, int& nIdx1, int& nIdx2);
386+
387+AR_EXPORT void sortInLastInteger(int& nIdx0, int& nIdx1, int& nIdx2, int &nIdx3);
388
389 } // namespace ARToolKitPlus
390
391
392=== modified file 'include/ARToolKitPlus/extra/rpp.h'
393--- include/ARToolKitPlus/extra/rpp.h 2010-02-12 15:11:58 +0000
394+++ include/ARToolKitPlus/extra/rpp.h 2010-11-02 21:11:10 +0000
395@@ -21,11 +21,13 @@
396 #ifndef __LINK_WITH_RPP__
397 #define __LINK_WITH_RPP__
398
399+#include <ARToolKitPlus/config.h>
400+
401 typedef double rpp_float;
402 typedef double rpp_vec[3];
403 typedef double rpp_mat[3][3];
404
405-void robustPlanarPose(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],
406+AR_EXPORT void robustPlanarPose(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],
407 const rpp_vec *model, const rpp_vec *iprts, const unsigned int model_iprts_size, const rpp_mat R_init,
408 const bool estimate_R_init, const rpp_float epsilon, const rpp_float tolerance,
409 const unsigned int max_iterations);
410
411=== modified file 'include/ARToolKitPlus/matrix.h'
412--- include/ARToolKitPlus/matrix.h 2010-02-12 15:11:58 +0000
413+++ include/ARToolKitPlus/matrix.h 2010-11-02 21:11:10 +0000
414@@ -36,7 +36,7 @@
415
416 namespace ARToolKitPlus {
417
418-struct ARMat {
419+struct AR_EXPORT ARMat {
420 ARFloat *m;
421 int row;
422 int clm;
423@@ -49,14 +49,14 @@
424 /* 1 origin */
425 #define ARELEM1(mat,row,clm) ARELEM0(mat,row-1,clm-1)
426
427-ARMat *alloc(int row, int clm);
428-int free(ARMat *m);
429-
430-int dup(ARMat *dest, ARMat *source);
431-ARMat *allocDup(ARMat *source);
432-
433-int mul(ARMat *dest, ARMat *a, ARMat *b);
434-int selfInv(ARMat *m);
435+AR_EXPORT ARMat *alloc(int row, int clm);
436+AR_EXPORT int free(ARMat *m);
437+
438+AR_EXPORT int dup(ARMat *dest, ARMat *source);
439+AR_EXPORT ARMat *allocDup(ARMat *source);
440+
441+AR_EXPORT int mul(ARMat *dest, ARMat *a, ARMat *b);
442+AR_EXPORT int selfInv(ARMat *m);
443
444 } // namespace Matrix
445
446
447=== modified file 'include/ARToolKitPlus/vector.h'
448--- include/ARToolKitPlus/vector.h 2010-02-12 15:11:58 +0000
449+++ include/ARToolKitPlus/vector.h 2010-11-02 21:11:10 +0000
450@@ -27,17 +27,17 @@
451
452 struct ARMat;
453
454-struct ARVec {
455+struct AR_EXPORT ARVec {
456 ARFloat *v;
457 int clm;
458 };
459
460 namespace Vector {
461-ARVec *alloc(int clm);
462-int free(ARVec *v);
463-ARFloat household(ARVec *x);
464-ARFloat innerproduct(ARVec *x, ARVec *y);
465-int tridiagonalize(ARMat *a, ARVec *d, ARVec *e);
466+AR_EXPORT ARVec * alloc(int clm);
467+AR_EXPORT int free(ARVec *v);
468+AR_EXPORT ARFloat household(ARVec *x);
469+AR_EXPORT ARFloat innerproduct(ARVec *x, ARVec *y);
470+AR_EXPORT int tridiagonalize(ARMat *a, ARVec *d, ARVec *e);
471 }
472
473 } // namespace ARToolKitPlus
474
475=== modified file 'src/Tracker.cpp'
476--- src/Tracker.cpp 2010-03-05 14:31:19 +0000
477+++ src/Tracker.cpp 2010-11-02 21:11:10 +0000
478@@ -25,6 +25,7 @@
479
480 using std::cerr;
481 using std::endl;
482+using std::vector;
483
484 namespace ARToolKitPlus {
485
486
487=== modified file 'src/TrackerSingleMarker.cpp'
488--- src/TrackerSingleMarker.cpp 2010-03-05 14:31:19 +0000
489+++ src/TrackerSingleMarker.cpp 2010-11-02 21:11:10 +0000
490@@ -56,8 +56,8 @@
491 return true;
492 }
493
494-vector<int> TrackerSingleMarker::calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info, int* nNumMarkers) {
495- vector<int> detected;
496+std::vector<int> TrackerSingleMarker::calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info, int* nNumMarkers) {
497+ std::vector<int> detected;
498
499 if (nImage == NULL)
500 return detected;
501
502=== modified file 'src/core/arGetCode.cpp'
503--- src/core/arGetCode.cpp 2010-02-09 12:37:58 +0000
504+++ src/core/arGetCode.cpp 2010-11-02 21:11:10 +0000
505@@ -146,17 +146,23 @@
506
507 int Tracker::arGetCode(uint8_t *image, int *x_coord, int *y_coord, int *vertex, int *code, int *dir, ARFloat *cf,
508 int thresh) {
509- uint8_t ext_pat[PATTERN_HEIGHT][PATTERN_WIDTH][3];
510+ #define _M(VAR, h,w,c) VAR[(h)*(PATTERN_WIDTH*3) + (w)*3 + (c)]
511+ uint8_t *ext_pat = new uint8_t[PATTERN_HEIGHT*PATTERN_WIDTH*3];
512
513- arGetPatt(image, x_coord, y_coord, vertex, (uint8_t***) ext_pat);
514+ arGetPatt(image, x_coord, y_coord, vertex, ext_pat);
515
516 if (autoThreshold.enable) {
517 int x, y;
518
519 for (y = 0; y < PATTERN_HEIGHT; y++)
520 for (x = 0; x < PATTERN_WIDTH; x++)
521- autoThreshold.addValue(ext_pat[y][x][0], ext_pat[y][x][1], ext_pat[y][x][2], pixelFormat);
522+ autoThreshold.addValue(
523+ _M(ext_pat,y,x,0),
524+ _M(ext_pat,y,x,1),
525+ _M(ext_pat,y,x,2),
526+ pixelFormat);
527 }
528+ #undef _M
529
530 // FILE* fp = fopen("dump.raw", "wb");
531 // fwrite(ext_pat, PATTERN_HEIGHT*PATTERN_WIDTH*3, 1, fp);
532@@ -186,15 +192,15 @@
533 else
534 pattern_match((uint8_t *)ext_pat, code, dir, cf);*/
535
536+ delete[] ext_pat;
537 return (0);
538 }
539
540 //#if 1
541-int Tracker::arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t **pext_pat[3]) {
542- uint8_t (*ext_pat)[PATTERN_WIDTH][3];
543- ext_pat = (uint8_t(*)[PATTERN_WIDTH][3]) pext_pat;
544+int Tracker::arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t *ext_pat) {
545+ #define _M(VAR, h,w,c) VAR[(h)*(PATTERN_WIDTH*3) + (w)*3 + (c)]
546
547- uint32_t ext_pat2[PATTERN_HEIGHT][PATTERN_WIDTH][3];
548+ uint32_t *ext_pat2 = new uint32_t[PATTERN_HEIGHT*PATTERN_WIDTH*3];
549 ARFloat world[4][2];
550 ARFloat local[4][2];
551 ARFloat para[3][3];
552@@ -264,7 +270,7 @@
553 if (xdiv == 1 && ydiv == 1) {
554 ARFloat border = relBorderWidth * 10.0f;
555 ARFloat xyFrom = 100.0f + border, xyTo = 110.0f - border, xyStep = xyTo - xyFrom;
556- ARFloat steps[PATTERN_WIDTH];
557+ ARFloat *steps = new ARFloat[PATTERN_WIDTH];
558
559 for (i = 0; i < xdiv2; i++)
560 steps[i] = xyFrom + xyStep * (ARFloat) (i + 0.5f) / (ARFloat) xdiv2;
561@@ -288,51 +294,54 @@
562 if (xc >= 0 && xc < arImXsize && yc >= 0 && yc < arImYsize) {
563 switch (pixelFormat) {
564 case PIXEL_FORMAT_ABGR:
565- ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 4 + 1];
566- ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 4 + 2];
567- ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 4 + 3];
568+ _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 4 + 1];
569+ _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 4 + 2];
570+ _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 4 + 3];
571 break;
572
573 case PIXEL_FORMAT_BGRA:
574- ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 4 + 0];
575- ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 4 + 1];
576- ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 4 + 2];
577+ _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 4 + 0];
578+ _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 4 + 1];
579+ _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 4 + 2];
580 break;
581
582 case PIXEL_FORMAT_BGR:
583- ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 3 + 0];
584- ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 3 + 1];
585- ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 3 + 2];
586+ _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 3 + 0];
587+ _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 3 + 1];
588+ _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 3 + 2];
589 break;
590
591 case PIXEL_FORMAT_RGBA:
592- ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 4 + 2];
593- ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 4 + 1];
594- ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 4 + 0];
595+ _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 4 + 2];
596+ _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 4 + 1];
597+ _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 4 + 0];
598
599 case PIXEL_FORMAT_RGB:
600- ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 3 + 2];
601- ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 3 + 1];
602- ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 3 + 0];
603+ _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 3 + 2];
604+ _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 3 + 1];
605+ _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 3 + 0];
606 break;
607
608 case PIXEL_FORMAT_RGB565:
609 col8 = getLUM8_from_RGB565(image16+yc*arImXsize+xc);
610- ext_pat[j][i][0] = col8;
611- ext_pat[j][i][1] = col8;
612- ext_pat[j][i][2] = col8;
613+ _M(ext_pat,j,i,0) = col8;
614+ _M(ext_pat,j,i,1) = col8;
615+ _M(ext_pat,j,i,2) = col8;
616 break;
617
618 case PIXEL_FORMAT_LUM:
619 col8 = image[(yc * arImXsize + xc)];
620- ext_pat[j][i][0] = col8;
621- ext_pat[j][i][1] = col8;
622- ext_pat[j][i][2] = col8;
623+ _M(ext_pat,j,i,0) = col8;
624+ _M(ext_pat,j,i,1) = col8;
625+ _M(ext_pat,j,i,2) = col8;
626 break;
627 }
628 }
629 }
630 }
631+
632+ // free memory
633+ delete[] steps;
634 } else
635 // general case: xdiv!=1 or ydiv!=1
636 //
637@@ -363,51 +372,51 @@
638 if (xc >= 0 && xc < arImXsize && yc >= 0 && yc < arImYsize) {
639 switch (pixelFormat) {
640 case PIXEL_FORMAT_ABGR:
641- ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 4 + 1];
642- ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 4 + 2];
643- ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 4 + 3];
644+ _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 4 + 1];
645+ _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 4 + 2];
646+ _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 4 + 3];
647 break;
648
649 case PIXEL_FORMAT_BGRA:
650- ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 4 + 0];
651- ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 4 + 1];
652- ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 4 + 2];
653+ _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 4 + 0];
654+ _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 4 + 1];
655+ _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 4 + 2];
656 break;
657
658 case PIXEL_FORMAT_BGR:
659- ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 3 + 0];
660- ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 3 + 1];
661- ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 3 + 2];
662+ _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 3 + 0];
663+ _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 3 + 1];
664+ _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 3 + 2];
665 break;
666
667 case PIXEL_FORMAT_RGBA:
668- ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 4 + 2];
669- ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 4 + 1];
670- ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 4 + 0];
671+ _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 4 + 2];
672+ _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 4 + 1];
673+ _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 4 + 0];
674 break;
675
676 case PIXEL_FORMAT_RGB:
677- ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 3 + 2];
678- ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 3 + 1];
679- ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 3 + 0];
680+ _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 3 + 2];
681+ _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 3 + 1];
682+ _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 3 + 0];
683 break;
684
685 case PIXEL_FORMAT_RGB565:
686 jy = j / ydiv;
687 ix = i / xdiv;
688 col8 = getLUM8_from_RGB565(image16+yc*arImXsize+xc);
689- ext_pat2[jy][ix][0] += col8;
690- ext_pat2[jy][ix][1] += col8;
691- ext_pat2[jy][ix][2] += col8;
692+ _M(ext_pat2,jy,ix,0) += col8;
693+ _M(ext_pat2,jy,ix,1) += col8;
694+ _M(ext_pat2,jy,ix,2) += col8;
695 break;
696
697 case PIXEL_FORMAT_LUM:
698 jy = j / ydiv;
699 ix = i / xdiv;
700 col8 = image[yc * arImXsize + xc];
701- ext_pat2[jy][ix][0] += col8;
702- ext_pat2[jy][ix][1] += col8;
703- ext_pat2[jy][ix][2] += col8;
704+ _M(ext_pat2,jy,ix,0) += col8;
705+ _M(ext_pat2,jy,ix,1) += col8;
706+ _M(ext_pat2,jy,ix,2) += col8;
707 break;
708 }
709 }
710@@ -416,19 +425,21 @@
711
712 for (j = 0; j < PATTERN_HEIGHT; j++) {
713 for (i = 0; i < PATTERN_HEIGHT; i++) {
714- ext_pat[j][i][0] = ext_pat2[j][i][0] / (xdiv * ydiv);
715- ext_pat[j][i][1] = ext_pat2[j][i][1] / (xdiv * ydiv);
716- ext_pat[j][i][2] = ext_pat2[j][i][2] / (xdiv * ydiv);
717+ _M(ext_pat,j,i,0) = _M(ext_pat2,j,i,0) / (xdiv * ydiv);
718+ _M(ext_pat,j,i,1) = _M(ext_pat2,j,i,1) / (xdiv * ydiv);
719+ _M(ext_pat,j,i,2) = _M(ext_pat2,j,i,2) / (xdiv * ydiv);
720 }
721 }
722 }
723
724+ #undef _M
725+ delete[] ext_pat2;
726 return (0);
727 }
728
729 int Tracker::pattern_match(uint8_t *data, int *code, int *dir, ARFloat *cf) {
730 ARFloat invec[EVEC_MAX];
731- int input[PATTERN_HEIGHT * PATTERN_WIDTH * 3];
732+ int *input = new int[PATTERN_HEIGHT * PATTERN_WIDTH * 3];
733 int i, j, l;
734 int k = 0; // fix VC7 compiler warning: uninitialized variable
735 int ave, sum, res, res2;
736@@ -563,7 +574,8 @@
737 #ifdef ARTK_DEBUG
738 printf("%d %d %f\n", res2, res, max);
739 #endif
740-
741+
742+ delete[] input;
743 return 0;
744 }
745

Subscribers

People subscribed via source and target branches