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
=== added file 'CMakeLists.txt'
--- CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ CMakeLists.txt 2010-11-02 21:11:10 +0000
@@ -0,0 +1,45 @@
1cmake_minimum_required(VERSION 2.4)
2project( AR )
3set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
4set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
5set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
6
7link_directories( ${LIBRARY_OUTPUT_PATH} )
8include_directories( "${AR_SOURCE_DIR}/include" )
9
10# ARToolkitPlus core files (headers and sources)
11file(GLOB_RECURSE HEADERS_AR "${AR_SOURCE_DIR}/include/ARToolkitPlus/*.h")
12file(GLOB SOURCES_AR
13 "${AR_SOURCE_DIR}/src/*.cpp"
14 "${AR_SOURCE_DIR}/src/core/*.cpp"
15 "${AR_SOURCE_DIR}/src/extra/*.cpp"
16 "${AR_SOURCE_DIR}/src/librpp/*.cpp"
17 )
18
19add_library(ARToolkitPlus
20 SHARED
21 ${HEADERS_AR}
22 ${SOURCES_AR}
23)
24
25set_target_properties(ARToolkitPlus PROPERTIES DEBUG_POSTFIX d)
26
27if(WIN32)
28 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
29 add_definitions(-DAR_LIBRARY)
30else(WIN32)
31 set(CMAKE_C_FLAGS_DEBUG "-Wall -g ")
32 set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g ")
33endif(WIN32)
34
35if(SLB_BUILD_TESTS)
36 enable_testing()
37 add_subdirectory(tests)
38endif(SLB_BUILD_TESTS)
39
40if(SLB_BUILD_EXAMPLES)
41 file(GLOB ALL_EXAMPLES "${SLB_SOURCE_DIR}/examples/*")
42 foreach(example ${ALL_EXAMPLES})
43 add_subdirectory(${example})
44 endforeach(example)
45endif(SLB_BUILD_EXAMPLES)
046
=== modified file 'include/ARToolKitPlus/Camera.h'
--- include/ARToolKitPlus/Camera.h 2010-02-09 14:44:21 +0000
+++ include/ARToolKitPlus/Camera.h 2010-11-02 21:11:10 +0000
@@ -25,7 +25,6 @@
25#include <string>25#include <string>
26#include <ARToolKitPlus/config.h>26#include <ARToolKitPlus/config.h>
2727
28using std::string;
2928
30namespace ARToolKitPlus {29namespace ARToolKitPlus {
3130
@@ -36,7 +35,7 @@
36 * this class used to be called ARParam in the classical ARToolkit35 * this class used to be called ARParam in the classical ARToolkit
37 * so do not wonder because of the method names36 * so do not wonder because of the method names
38 */37 */
39class Camera {38class AR_EXPORT Camera {
40public:39public:
41 int xsize, ysize;40 int xsize, ysize;
42 ARFloat mat[3][4];41 ARFloat mat[3][4];
@@ -48,9 +47,9 @@
48 Camera* clone();47 Camera* clone();
49 bool changeFrameSize(const int frameWidth, const int frameHeight);48 bool changeFrameSize(const int frameWidth, const int frameHeight);
50 void printSettings();49 void printSettings();
51 string getFileName() const;50 std::string getFileName() const;
52protected:51protected:
53 string fileName;52 std::string fileName;
5453
55 // http://www.vision.caltech.edu/bouguetj/calib_doc/htmls/parameters.html54 // http://www.vision.caltech.edu/bouguetj/calib_doc/htmls/parameters.html
56 ARFloat cc[2];55 ARFloat cc[2];
5756
=== modified file 'include/ARToolKitPlus/Tracker.h'
--- include/ARToolKitPlus/Tracker.h 2010-03-05 14:31:19 +0000
+++ include/ARToolKitPlus/Tracker.h 2010-11-02 21:11:10 +0000
@@ -32,7 +32,6 @@
3232
33#include <vector>33#include <vector>
3434
35using std::vector;
3635
37namespace ARToolKitPlus {36namespace ARToolKitPlus {
3837
@@ -50,7 +49,7 @@
50 * - TrackerSingleMarker49 * - TrackerSingleMarker
51 * - TrackerMultiMarker50 * - TrackerMultiMarker
52 */51 */
53class Tracker {52class AR_EXPORT Tracker {
54public:53public:
55 Tracker(int imWidth, int imHeight, int maxImagePatterns = 8, int pattWidth = 6, int pattHeight = 6, int pattSamples = 6,54 Tracker(int imWidth, int imHeight, int maxImagePatterns = 8, int pattWidth = 6, int pattHeight = 6, int pattSamples = 6,
56 int maxLoadPatterns = 0);55 int maxLoadPatterns = 0);
@@ -338,7 +337,7 @@
338 int337 int
339 arGetCode(uint8_t *image, int *x_coord, int *y_coord, int *vertex, int *code, int *dir, ARFloat *cf, int thresh);338 arGetCode(uint8_t *image, int *x_coord, int *y_coord, int *vertex, int *code, int *dir, ARFloat *cf, int thresh);
340339
341 int arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t **ext_pat[3]);340 int arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t *ext_pat);
342341
343 int pattern_match(uint8_t *data, int *code, int *dir, ARFloat *cf);342 int pattern_match(uint8_t *data, int *code, int *dir, ARFloat *cf);
344343
@@ -501,7 +500,7 @@
501 arPrevInfo *prev_info;500 arPrevInfo *prev_info;
502 int prev_num;501 int prev_num;
503502
504 vector<vector<arPrevInfo> > sprev_info;503 std::vector<std::vector<arPrevInfo> > sprev_info;
505 int sprev_num[2];504 int sprev_num[2];
506505
507 // arDetectMarker2.cpp506 // arDetectMarker2.cpp
@@ -514,16 +513,16 @@
514 // arGetCode.cpp513 // arGetCode.cpp
515 int pattern_num;514 int pattern_num;
516 int *patf;515 int *patf;
517 vector<vector<vector<int> > > pat;516 std::vector<std::vector<std::vector<int> > > pat;
518 ARFloat (*patpow)[4];517 ARFloat (*patpow)[4];
519 vector<vector<vector<int> > > patBW;518 std::vector<std::vector<std::vector<int> > > patBW;
520 ARFloat (*patpowBW)[4];519 ARFloat (*patpowBW)[4];
521520
522 vector<vector<ARFloat> > evec;521 std::vector<std::vector<ARFloat> > evec;
523 ARFloat (*epat)[4][EVEC_MAX];522 ARFloat (*epat)[4][EVEC_MAX];
524 int evec_dim;523 int evec_dim;
525 int evecf;524 int evecf;
526 vector<vector<ARFloat> > evecBW;525 std::vector<std::vector<ARFloat> > evecBW;
527 ARFloat (*epatBW)[4][EVEC_MAX];526 ARFloat (*epatBW)[4][EVEC_MAX];
528 int evec_dimBW;527 int evec_dimBW;
529 int evecBWf;528 int evecBWf;
@@ -592,7 +591,8 @@
592591
593 HULL_TRACKING_MODE hullTrackingMode;592 HULL_TRACKING_MODE hullTrackingMode;
594593
595 static int screenWidth, screenHeight;594 static int screenWidth;
595 static int screenHeight;
596 int thresh;596 int thresh;
597597
598 ARFloat gl_para[16];598 ARFloat gl_para[16];
599599
=== modified file 'include/ARToolKitPlus/TrackerMultiMarker.h'
--- include/ARToolKitPlus/TrackerMultiMarker.h 2010-03-05 14:31:19 +0000
+++ include/ARToolKitPlus/TrackerMultiMarker.h 2010-11-02 21:11:10 +0000
@@ -36,7 +36,7 @@
36 * Furthermore it uses only 4 'good' points of the convex hull to do the pose estimation.36 * Furthermore it uses only 4 'good' points of the convex hull to do the pose estimation.
37 * You can override this using the according methods.37 * You can override this using the according methods.
38 */38 */
39class TrackerMultiMarker: public Tracker {39class AR_EXPORT TrackerMultiMarker: public Tracker {
40public:40public:
41 /**41 /**
42 * These parameters control the way the toolkit warps a found42 * These parameters control the way the toolkit warps a found
4343
=== modified file 'include/ARToolKitPlus/TrackerSingleMarker.h'
--- include/ARToolKitPlus/TrackerSingleMarker.h 2010-03-05 14:31:19 +0000
+++ include/ARToolKitPlus/TrackerSingleMarker.h 2010-11-02 21:11:10 +0000
@@ -36,7 +36,7 @@
36 *36 *
37 * If you need multi-marker tracking use TrackerMultiMarker.37 * If you need multi-marker tracking use TrackerMultiMarker.
38 */38 */
39class TrackerSingleMarker: public Tracker {39class AR_EXPORT TrackerSingleMarker: public Tracker {
40public:40public:
41 /**41 /**
42 * These parameters control the way the toolkit warps a found42 * These parameters control the way the toolkit warps a found
@@ -76,7 +76,7 @@
76 * pass the image as RGBX (32-bits)76 * pass the image as RGBX (32-bits)
77 * @return detected markers in image77 * @return detected markers in image
78 */78 */
79 virtual vector<int> calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info = NULL, int* nNumMarkers = NULL);79 virtual std::vector<int> calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info = NULL, int* nNumMarkers = NULL);
8080
81 /**81 /**
82 * manually select one of the detected markers82 * manually select one of the detected markers
8383
=== modified file 'include/ARToolKitPlus/ar.h'
--- include/ARToolKitPlus/ar.h 2010-02-08 14:55:16 +0000
+++ include/ARToolKitPlus/ar.h 2010-11-02 21:11:10 +0000
@@ -40,7 +40,7 @@
40 ARFloat pos[2];40 ARFloat pos[2];
41 ARFloat line[4][3];41 ARFloat line[4][3];
42 ARFloat vertex[4][2];42 ARFloat vertex[4][2];
43} ARMarkerInfo;43} AR_EXPORT ARMarkerInfo;
4444
45typedef struct {45typedef struct {
46 int area;46 int area;
@@ -49,12 +49,12 @@
49 int x_coord[AR_CHAIN_MAX];49 int x_coord[AR_CHAIN_MAX];
50 int y_coord[AR_CHAIN_MAX];50 int y_coord[AR_CHAIN_MAX];
51 int vertex[5];51 int vertex[5];
52} ARMarkerInfo2;52} AR_EXPORT ARMarkerInfo2;
5353
54typedef struct {54typedef struct {
55 ARMarkerInfo marker;55 ARMarkerInfo marker;
56 int count;56 int count;
57} arPrevInfo;57} AR_EXPORT arPrevInfo;
5858
59} // namespace ARToolKitPlus59} // namespace ARToolKitPlus
6060
6161
=== modified file 'include/ARToolKitPlus/arBitFieldPattern.h'
--- include/ARToolKitPlus/arBitFieldPattern.h 2010-02-12 15:11:58 +0000
+++ include/ARToolKitPlus/arBitFieldPattern.h 2010-11-02 21:11:10 +0000
@@ -76,13 +76,13 @@
7676
77// some internal methods. primarily needed for77// some internal methods. primarily needed for
78// marker printing, etc.78// marker printing, etc.
79void generatePatternSimple(int nID, IDPATTERN& nPattern);79void AR_EXPORT generatePatternSimple(int nID, IDPATTERN& nPattern);
8080
81void generatePatternBCH(int nID, IDPATTERN& nPattern);81void AR_EXPORT generatePatternBCH(int nID, IDPATTERN& nPattern);
8282
83// static void setBit(IDPATTERN& pat, int which);83// static void setBit(IDPATTERN& pat, int which);
8484
85bool isBitSet(IDPATTERN pat, int which);85bool AR_EXPORT isBitSet(IDPATTERN pat, int which);
8686
87} // namespace ARToolKitPlus87} // namespace ARToolKitPlus
8888
8989
=== modified file 'include/ARToolKitPlus/arGetInitRot2Sub.h'
--- include/ARToolKitPlus/arGetInitRot2Sub.h 2010-02-12 15:11:58 +0000
+++ include/ARToolKitPlus/arGetInitRot2Sub.h 2010-11-02 21:11:10 +0000
@@ -25,7 +25,7 @@
2525
26namespace rpp {26namespace rpp {
2727
28void arGetInitRot2_sub(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],28void AR_EXPORT arGetInitRot2_sub(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],
29 const rpp_vec *model, const rpp_vec *iprts, const unsigned int model_iprts_size, const rpp_mat R_init,29 const rpp_vec *model, const rpp_vec *iprts, const unsigned int model_iprts_size, const rpp_mat R_init,
30 const bool estimate_R_init, const rpp_float epsilon, const rpp_float tolerance,30 const bool estimate_R_init, const rpp_float epsilon, const rpp_float tolerance,
31 const unsigned int max_iterations);31 const unsigned int max_iterations);
@@ -33,4 +33,4 @@
33} // namespace rpp33} // namespace rpp
3434
3535
36#endif //__ARTOOLKITPLUS_ARGETINITROT2SUB_HEADERFILE__36#endif //__ARTOOLKITPLUS_ARGETINITROT2SUB_HEADERFILE__
3737
=== modified file 'include/ARToolKitPlus/arMulti.h'
--- include/ARToolKitPlus/arMulti.h 2010-03-05 14:31:19 +0000
+++ include/ARToolKitPlus/arMulti.h 2010-11-02 21:11:10 +0000
@@ -37,7 +37,7 @@
37 int visible;37 int visible;
38/*---*/38/*---*/
39 int visibleR;39 int visibleR;
40} ARMultiEachMarkerInfoT;40} AR_EXPORT ARMultiEachMarkerInfoT;
4141
42typedef struct {42typedef struct {
43 ARMultiEachMarkerInfoT *marker;43 ARMultiEachMarkerInfoT *marker;
@@ -46,7 +46,7 @@
46 int prevF;46 int prevF;
47/*---*/47/*---*/
48 ARFloat transR[3][4];48 ARFloat transR[3][4];
49} ARMultiMarkerInfoT;49} AR_EXPORT ARMultiMarkerInfoT;
5050
5151
52} // namespace ARToolKitPlus52} // namespace ARToolKitPlus
5353
=== modified file 'include/ARToolKitPlus/config.h' (properties changed: -x to +x)
--- include/ARToolKitPlus/config.h 2010-02-12 14:55:53 +0000
+++ include/ARToolKitPlus/config.h 2010-11-02 21:11:10 +0000
@@ -96,5 +96,37 @@
96 #define getLUM8_from_RGB565(ptr) RGB565_to_LUM8_LUT[ (*(unsigned short*)(ptr)) ]96 #define getLUM8_from_RGB565(ptr) RGB565_to_LUM8_LUT[ (*(unsigned short*)(ptr)) ]
97#endif //SMALL_LUM8_TABLE97#endif //SMALL_LUM8_TABLE
9898
99// disable VisualStudio warnings
100#if defined(_MSC_VER) && !defined(AR_ENABLE_MSVC_WARNINGS)
101 #pragma warning( disable : 4244 )
102 #pragma warning( disable : 4251 )
103 #pragma warning( disable : 4275 )
104 #pragma warning( disable : 4512 )
105 #pragma warning( disable : 4267 )
106 #pragma warning( disable : 4702 )
107 #pragma warning( disable : 4511 )
108#endif
109
110// Support for Visual Studio compilation
111#if defined(AR_STATIC)
112 #define AR_EXPORT
113#else
114 #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
115 # if defined( AR_LIBRARY )
116 # define AR_EXPORT __declspec(dllexport)
117 # else
118 # define AR_EXPORT __declspec(dllimport)
119 # endif
120 #else
121 # define AR_EXPORT
122 #endif
123#endif
124
125#ifdef _MSC_VER
126# if (_MSC_VER >= 1300)
127# define __STL_MEMBER_TEMPLATES
128# endif
129#endif
130
99#endif // AR_CONFIG_H131#endif // AR_CONFIG_H
100132
101133
=== modified file 'include/ARToolKitPlus/extra/BCH.h'
--- include/ARToolKitPlus/extra/BCH.h 2010-02-12 15:11:58 +0000
+++ include/ARToolKitPlus/extra/BCH.h 2010-11-02 21:11:10 +0000
@@ -22,6 +22,8 @@
22#ifndef __BCH_CODE__H__22#ifndef __BCH_CODE__H__
23#define __BCH_CODE__H__23#define __BCH_CODE__H__
2424
25#include <ARToolKitPlus/config.h>
26
25#include <vector>27#include <vector>
2628
27namespace ARToolKitPlus {29namespace ARToolKitPlus {
@@ -62,7 +64,7 @@
62// static void printBitPattern(_64bits n, int n_bits);64// static void printBitPattern(_64bits n, int n_bits);
6365
6466
65class BCH67class AR_EXPORT BCH
66// this class implements a (36, 12, 9) binary BCH encoder/decoder68// this class implements a (36, 12, 9) binary BCH encoder/decoder
67{69{
68public:70public:
6971
=== modified file 'include/ARToolKitPlus/extra/Hull.h'
--- include/ARToolKitPlus/extra/Hull.h 2010-02-12 15:11:58 +0000
+++ include/ARToolKitPlus/extra/Hull.h 2010-11-02 21:11:10 +0000
@@ -22,12 +22,14 @@
22#ifndef __ARTOOLKITPLUS_HULL_HEADERFILE__22#ifndef __ARTOOLKITPLUS_HULL_HEADERFILE__
23#define __ARTOOLKITPLUS_HULL_HEADERFILE__23#define __ARTOOLKITPLUS_HULL_HEADERFILE__
2424
25#include <ARToolKitPlus/config.h>
26
25namespace ARToolKitPlus {27namespace ARToolKitPlus {
2628
27const int MAX_HULL_POINTS = 64; // support up to 16 visible markers29const int MAX_HULL_POINTS = 64; // support up to 16 visible markers
2830
2931
30struct MarkerPoint {32struct AR_EXPORT MarkerPoint {
31 typedef int coord_type;33 typedef int coord_type;
3234
33 coord_type x, y;35 coord_type x, y;
@@ -38,17 +40,17 @@
38 return nValue >= 0 ? nValue : -nValue;40 return nValue >= 0 ? nValue : -nValue;
39}41}
4042
41int nearHull_2D(const MarkerPoint* P, int n, int k, MarkerPoint* H);43AR_EXPORT int nearHull_2D(const MarkerPoint* P, int n, int k, MarkerPoint* H);
4244
43void findLongestDiameter(const MarkerPoint* nPoints, int nNumPoints, int &nIdx0, int &nIdx1);45AR_EXPORT void findLongestDiameter(const MarkerPoint* nPoints, int nNumPoints, int &nIdx0, int &nIdx1);
4446
45void findFurthestAway(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int& nIdxFarthest);47AR_EXPORT void findFurthestAway(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int& nIdxFarthest);
4648
47void maximizeArea(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int nIdx2, int& nIdxMax);49AR_EXPORT void maximizeArea(const MarkerPoint* nPoints, int nNumPoints, int nIdx0, int nIdx1, int nIdx2, int& nIdxMax);
4850
49void sortIntegers(int& nIdx0, int& nIdx1, int& nIdx2);51AR_EXPORT void sortIntegers(int& nIdx0, int& nIdx1, int& nIdx2);
5052
51void sortInLastInteger(int& nIdx0, int& nIdx1, int& nIdx2, int &nIdx3);53AR_EXPORT void sortInLastInteger(int& nIdx0, int& nIdx1, int& nIdx2, int &nIdx3);
5254
53} // namespace ARToolKitPlus55} // namespace ARToolKitPlus
5456
5557
=== modified file 'include/ARToolKitPlus/extra/rpp.h'
--- include/ARToolKitPlus/extra/rpp.h 2010-02-12 15:11:58 +0000
+++ include/ARToolKitPlus/extra/rpp.h 2010-11-02 21:11:10 +0000
@@ -21,11 +21,13 @@
21#ifndef __LINK_WITH_RPP__21#ifndef __LINK_WITH_RPP__
22#define __LINK_WITH_RPP__22#define __LINK_WITH_RPP__
2323
24#include <ARToolKitPlus/config.h>
25
24typedef double rpp_float;26typedef double rpp_float;
25typedef double rpp_vec[3];27typedef double rpp_vec[3];
26typedef double rpp_mat[3][3];28typedef double rpp_mat[3][3];
2729
28void robustPlanarPose(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],30AR_EXPORT void robustPlanarPose(rpp_float &err, rpp_mat &R, rpp_vec &t, const rpp_float cc[2], const rpp_float fc[2],
29 const rpp_vec *model, const rpp_vec *iprts, const unsigned int model_iprts_size, const rpp_mat R_init,31 const rpp_vec *model, const rpp_vec *iprts, const unsigned int model_iprts_size, const rpp_mat R_init,
30 const bool estimate_R_init, const rpp_float epsilon, const rpp_float tolerance,32 const bool estimate_R_init, const rpp_float epsilon, const rpp_float tolerance,
31 const unsigned int max_iterations);33 const unsigned int max_iterations);
3234
=== modified file 'include/ARToolKitPlus/matrix.h'
--- include/ARToolKitPlus/matrix.h 2010-02-12 15:11:58 +0000
+++ include/ARToolKitPlus/matrix.h 2010-11-02 21:11:10 +0000
@@ -36,7 +36,7 @@
3636
37namespace ARToolKitPlus {37namespace ARToolKitPlus {
3838
39struct ARMat {39struct AR_EXPORT ARMat {
40 ARFloat *m;40 ARFloat *m;
41 int row;41 int row;
42 int clm;42 int clm;
@@ -49,14 +49,14 @@
49/* 1 origin */49/* 1 origin */
50#define ARELEM1(mat,row,clm) ARELEM0(mat,row-1,clm-1)50#define ARELEM1(mat,row,clm) ARELEM0(mat,row-1,clm-1)
5151
52ARMat *alloc(int row, int clm);52AR_EXPORT ARMat *alloc(int row, int clm);
53int free(ARMat *m);53AR_EXPORT int free(ARMat *m);
5454
55int dup(ARMat *dest, ARMat *source);55AR_EXPORT int dup(ARMat *dest, ARMat *source);
56ARMat *allocDup(ARMat *source);56AR_EXPORT ARMat *allocDup(ARMat *source);
5757
58int mul(ARMat *dest, ARMat *a, ARMat *b);58AR_EXPORT int mul(ARMat *dest, ARMat *a, ARMat *b);
59int selfInv(ARMat *m);59AR_EXPORT int selfInv(ARMat *m);
6060
61} // namespace Matrix61} // namespace Matrix
6262
6363
=== modified file 'include/ARToolKitPlus/vector.h'
--- include/ARToolKitPlus/vector.h 2010-02-12 15:11:58 +0000
+++ include/ARToolKitPlus/vector.h 2010-11-02 21:11:10 +0000
@@ -27,17 +27,17 @@
2727
28struct ARMat;28struct ARMat;
2929
30struct ARVec {30struct AR_EXPORT ARVec {
31 ARFloat *v;31 ARFloat *v;
32 int clm;32 int clm;
33};33};
3434
35namespace Vector {35namespace Vector {
36ARVec *alloc(int clm);36AR_EXPORT ARVec * alloc(int clm);
37int free(ARVec *v);37AR_EXPORT int free(ARVec *v);
38ARFloat household(ARVec *x);38AR_EXPORT ARFloat household(ARVec *x);
39ARFloat innerproduct(ARVec *x, ARVec *y);39AR_EXPORT ARFloat innerproduct(ARVec *x, ARVec *y);
40int tridiagonalize(ARMat *a, ARVec *d, ARVec *e);40AR_EXPORT int tridiagonalize(ARMat *a, ARVec *d, ARVec *e);
41}41}
4242
43} // namespace ARToolKitPlus43} // namespace ARToolKitPlus
4444
=== modified file 'src/Tracker.cpp'
--- src/Tracker.cpp 2010-03-05 14:31:19 +0000
+++ src/Tracker.cpp 2010-11-02 21:11:10 +0000
@@ -25,6 +25,7 @@
2525
26using std::cerr;26using std::cerr;
27using std::endl;27using std::endl;
28using std::vector;
2829
29namespace ARToolKitPlus {30namespace ARToolKitPlus {
3031
3132
=== modified file 'src/TrackerSingleMarker.cpp'
--- src/TrackerSingleMarker.cpp 2010-03-05 14:31:19 +0000
+++ src/TrackerSingleMarker.cpp 2010-11-02 21:11:10 +0000
@@ -56,8 +56,8 @@
56 return true;56 return true;
57}57}
5858
59vector<int> TrackerSingleMarker::calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info, int* nNumMarkers) {59std::vector<int> TrackerSingleMarker::calc(const uint8_t* nImage, ARMarkerInfo** nMarker_info, int* nNumMarkers) {
60 vector<int> detected;60 std::vector<int> detected;
6161
62 if (nImage == NULL)62 if (nImage == NULL)
63 return detected;63 return detected;
6464
=== modified file 'src/core/arGetCode.cpp'
--- src/core/arGetCode.cpp 2010-02-09 12:37:58 +0000
+++ src/core/arGetCode.cpp 2010-11-02 21:11:10 +0000
@@ -146,17 +146,23 @@
146146
147int Tracker::arGetCode(uint8_t *image, int *x_coord, int *y_coord, int *vertex, int *code, int *dir, ARFloat *cf,147int Tracker::arGetCode(uint8_t *image, int *x_coord, int *y_coord, int *vertex, int *code, int *dir, ARFloat *cf,
148 int thresh) {148 int thresh) {
149 uint8_t ext_pat[PATTERN_HEIGHT][PATTERN_WIDTH][3];149 #define _M(VAR, h,w,c) VAR[(h)*(PATTERN_WIDTH*3) + (w)*3 + (c)]
150 uint8_t *ext_pat = new uint8_t[PATTERN_HEIGHT*PATTERN_WIDTH*3];
150151
151 arGetPatt(image, x_coord, y_coord, vertex, (uint8_t***) ext_pat);152 arGetPatt(image, x_coord, y_coord, vertex, ext_pat);
152153
153 if (autoThreshold.enable) {154 if (autoThreshold.enable) {
154 int x, y;155 int x, y;
155156
156 for (y = 0; y < PATTERN_HEIGHT; y++)157 for (y = 0; y < PATTERN_HEIGHT; y++)
157 for (x = 0; x < PATTERN_WIDTH; x++)158 for (x = 0; x < PATTERN_WIDTH; x++)
158 autoThreshold.addValue(ext_pat[y][x][0], ext_pat[y][x][1], ext_pat[y][x][2], pixelFormat);159 autoThreshold.addValue(
160 _M(ext_pat,y,x,0),
161 _M(ext_pat,y,x,1),
162 _M(ext_pat,y,x,2),
163 pixelFormat);
159 }164 }
165 #undef _M
160166
161 // FILE* fp = fopen("dump.raw", "wb");167 // FILE* fp = fopen("dump.raw", "wb");
162 // fwrite(ext_pat, PATTERN_HEIGHT*PATTERN_WIDTH*3, 1, fp);168 // fwrite(ext_pat, PATTERN_HEIGHT*PATTERN_WIDTH*3, 1, fp);
@@ -186,15 +192,15 @@
186 else192 else
187 pattern_match((uint8_t *)ext_pat, code, dir, cf);*/193 pattern_match((uint8_t *)ext_pat, code, dir, cf);*/
188194
195 delete[] ext_pat;
189 return (0);196 return (0);
190}197}
191198
192//#if 1199//#if 1
193int Tracker::arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t **pext_pat[3]) {200int Tracker::arGetPatt(uint8_t *image, int *x_coord, int *y_coord, int *vertex, uint8_t *ext_pat) {
194 uint8_t (*ext_pat)[PATTERN_WIDTH][3];201 #define _M(VAR, h,w,c) VAR[(h)*(PATTERN_WIDTH*3) + (w)*3 + (c)]
195 ext_pat = (uint8_t(*)[PATTERN_WIDTH][3]) pext_pat;
196202
197 uint32_t ext_pat2[PATTERN_HEIGHT][PATTERN_WIDTH][3];203 uint32_t *ext_pat2 = new uint32_t[PATTERN_HEIGHT*PATTERN_WIDTH*3];
198 ARFloat world[4][2];204 ARFloat world[4][2];
199 ARFloat local[4][2];205 ARFloat local[4][2];
200 ARFloat para[3][3];206 ARFloat para[3][3];
@@ -264,7 +270,7 @@
264 if (xdiv == 1 && ydiv == 1) {270 if (xdiv == 1 && ydiv == 1) {
265 ARFloat border = relBorderWidth * 10.0f;271 ARFloat border = relBorderWidth * 10.0f;
266 ARFloat xyFrom = 100.0f + border, xyTo = 110.0f - border, xyStep = xyTo - xyFrom;272 ARFloat xyFrom = 100.0f + border, xyTo = 110.0f - border, xyStep = xyTo - xyFrom;
267 ARFloat steps[PATTERN_WIDTH];273 ARFloat *steps = new ARFloat[PATTERN_WIDTH];
268274
269 for (i = 0; i < xdiv2; i++)275 for (i = 0; i < xdiv2; i++)
270 steps[i] = xyFrom + xyStep * (ARFloat) (i + 0.5f) / (ARFloat) xdiv2;276 steps[i] = xyFrom + xyStep * (ARFloat) (i + 0.5f) / (ARFloat) xdiv2;
@@ -288,51 +294,54 @@
288 if (xc >= 0 && xc < arImXsize && yc >= 0 && yc < arImYsize) {294 if (xc >= 0 && xc < arImXsize && yc >= 0 && yc < arImYsize) {
289 switch (pixelFormat) {295 switch (pixelFormat) {
290 case PIXEL_FORMAT_ABGR:296 case PIXEL_FORMAT_ABGR:
291 ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 4 + 1];297 _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 4 + 1];
292 ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 4 + 2];298 _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 4 + 2];
293 ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 4 + 3];299 _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 4 + 3];
294 break;300 break;
295301
296 case PIXEL_FORMAT_BGRA:302 case PIXEL_FORMAT_BGRA:
297 ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 4 + 0];303 _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 4 + 0];
298 ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 4 + 1];304 _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 4 + 1];
299 ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 4 + 2];305 _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 4 + 2];
300 break;306 break;
301307
302 case PIXEL_FORMAT_BGR:308 case PIXEL_FORMAT_BGR:
303 ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 3 + 0];309 _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 3 + 0];
304 ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 3 + 1];310 _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 3 + 1];
305 ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 3 + 2];311 _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 3 + 2];
306 break;312 break;
307313
308 case PIXEL_FORMAT_RGBA:314 case PIXEL_FORMAT_RGBA:
309 ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 4 + 2];315 _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 4 + 2];
310 ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 4 + 1];316 _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 4 + 1];
311 ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 4 + 0];317 _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 4 + 0];
312318
313 case PIXEL_FORMAT_RGB:319 case PIXEL_FORMAT_RGB:
314 ext_pat[j][i][0] = image[(yc * arImXsize + xc) * 3 + 2];320 _M(ext_pat,j,i,0) = image[(yc * arImXsize + xc) * 3 + 2];
315 ext_pat[j][i][1] = image[(yc * arImXsize + xc) * 3 + 1];321 _M(ext_pat,j,i,1) = image[(yc * arImXsize + xc) * 3 + 1];
316 ext_pat[j][i][2] = image[(yc * arImXsize + xc) * 3 + 0];322 _M(ext_pat,j,i,2) = image[(yc * arImXsize + xc) * 3 + 0];
317 break;323 break;
318324
319 case PIXEL_FORMAT_RGB565:325 case PIXEL_FORMAT_RGB565:
320 col8 = getLUM8_from_RGB565(image16+yc*arImXsize+xc);326 col8 = getLUM8_from_RGB565(image16+yc*arImXsize+xc);
321 ext_pat[j][i][0] = col8;327 _M(ext_pat,j,i,0) = col8;
322 ext_pat[j][i][1] = col8;328 _M(ext_pat,j,i,1) = col8;
323 ext_pat[j][i][2] = col8;329 _M(ext_pat,j,i,2) = col8;
324 break;330 break;
325331
326 case PIXEL_FORMAT_LUM:332 case PIXEL_FORMAT_LUM:
327 col8 = image[(yc * arImXsize + xc)];333 col8 = image[(yc * arImXsize + xc)];
328 ext_pat[j][i][0] = col8;334 _M(ext_pat,j,i,0) = col8;
329 ext_pat[j][i][1] = col8;335 _M(ext_pat,j,i,1) = col8;
330 ext_pat[j][i][2] = col8;336 _M(ext_pat,j,i,2) = col8;
331 break;337 break;
332 }338 }
333 }339 }
334 }340 }
335 }341 }
342
343 // free memory
344 delete[] steps;
336 } else345 } else
337 // general case: xdiv!=1 or ydiv!=1346 // general case: xdiv!=1 or ydiv!=1
338 //347 //
@@ -363,51 +372,51 @@
363 if (xc >= 0 && xc < arImXsize && yc >= 0 && yc < arImYsize) {372 if (xc >= 0 && xc < arImXsize && yc >= 0 && yc < arImYsize) {
364 switch (pixelFormat) {373 switch (pixelFormat) {
365 case PIXEL_FORMAT_ABGR:374 case PIXEL_FORMAT_ABGR:
366 ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 4 + 1];375 _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 4 + 1];
367 ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 4 + 2];376 _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 4 + 2];
368 ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 4 + 3];377 _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 4 + 3];
369 break;378 break;
370379
371 case PIXEL_FORMAT_BGRA:380 case PIXEL_FORMAT_BGRA:
372 ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 4 + 0];381 _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 4 + 0];
373 ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 4 + 1];382 _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 4 + 1];
374 ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 4 + 2];383 _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 4 + 2];
375 break;384 break;
376385
377 case PIXEL_FORMAT_BGR:386 case PIXEL_FORMAT_BGR:
378 ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 3 + 0];387 _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 3 + 0];
379 ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 3 + 1];388 _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 3 + 1];
380 ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 3 + 2];389 _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 3 + 2];
381 break;390 break;
382391
383 case PIXEL_FORMAT_RGBA:392 case PIXEL_FORMAT_RGBA:
384 ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 4 + 2];393 _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 4 + 2];
385 ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 4 + 1];394 _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 4 + 1];
386 ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 4 + 0];395 _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 4 + 0];
387 break;396 break;
388397
389 case PIXEL_FORMAT_RGB:398 case PIXEL_FORMAT_RGB:
390 ext_pat2[j / ydiv][i / xdiv][0] += image[(yc * arImXsize + xc) * 3 + 2];399 _M(ext_pat2,j / ydiv,i / xdiv,0) += image[(yc * arImXsize + xc) * 3 + 2];
391 ext_pat2[j / ydiv][i / xdiv][1] += image[(yc * arImXsize + xc) * 3 + 1];400 _M(ext_pat2,j / ydiv,i / xdiv,1) += image[(yc * arImXsize + xc) * 3 + 1];
392 ext_pat2[j / ydiv][i / xdiv][2] += image[(yc * arImXsize + xc) * 3 + 0];401 _M(ext_pat2,j / ydiv,i / xdiv,2) += image[(yc * arImXsize + xc) * 3 + 0];
393 break;402 break;
394403
395 case PIXEL_FORMAT_RGB565:404 case PIXEL_FORMAT_RGB565:
396 jy = j / ydiv;405 jy = j / ydiv;
397 ix = i / xdiv;406 ix = i / xdiv;
398 col8 = getLUM8_from_RGB565(image16+yc*arImXsize+xc);407 col8 = getLUM8_from_RGB565(image16+yc*arImXsize+xc);
399 ext_pat2[jy][ix][0] += col8;408 _M(ext_pat2,jy,ix,0) += col8;
400 ext_pat2[jy][ix][1] += col8;409 _M(ext_pat2,jy,ix,1) += col8;
401 ext_pat2[jy][ix][2] += col8;410 _M(ext_pat2,jy,ix,2) += col8;
402 break;411 break;
403412
404 case PIXEL_FORMAT_LUM:413 case PIXEL_FORMAT_LUM:
405 jy = j / ydiv;414 jy = j / ydiv;
406 ix = i / xdiv;415 ix = i / xdiv;
407 col8 = image[yc * arImXsize + xc];416 col8 = image[yc * arImXsize + xc];
408 ext_pat2[jy][ix][0] += col8;417 _M(ext_pat2,jy,ix,0) += col8;
409 ext_pat2[jy][ix][1] += col8;418 _M(ext_pat2,jy,ix,1) += col8;
410 ext_pat2[jy][ix][2] += col8;419 _M(ext_pat2,jy,ix,2) += col8;
411 break;420 break;
412 }421 }
413 }422 }
@@ -416,19 +425,21 @@
416425
417 for (j = 0; j < PATTERN_HEIGHT; j++) {426 for (j = 0; j < PATTERN_HEIGHT; j++) {
418 for (i = 0; i < PATTERN_HEIGHT; i++) {427 for (i = 0; i < PATTERN_HEIGHT; i++) {
419 ext_pat[j][i][0] = ext_pat2[j][i][0] / (xdiv * ydiv);428 _M(ext_pat,j,i,0) = _M(ext_pat2,j,i,0) / (xdiv * ydiv);
420 ext_pat[j][i][1] = ext_pat2[j][i][1] / (xdiv * ydiv);429 _M(ext_pat,j,i,1) = _M(ext_pat2,j,i,1) / (xdiv * ydiv);
421 ext_pat[j][i][2] = ext_pat2[j][i][2] / (xdiv * ydiv);430 _M(ext_pat,j,i,2) = _M(ext_pat2,j,i,2) / (xdiv * ydiv);
422 }431 }
423 }432 }
424 }433 }
425434
435 #undef _M
436 delete[] ext_pat2;
426 return (0);437 return (0);
427}438}
428439
429int Tracker::pattern_match(uint8_t *data, int *code, int *dir, ARFloat *cf) {440int Tracker::pattern_match(uint8_t *data, int *code, int *dir, ARFloat *cf) {
430 ARFloat invec[EVEC_MAX];441 ARFloat invec[EVEC_MAX];
431 int input[PATTERN_HEIGHT * PATTERN_WIDTH * 3];442 int *input = new int[PATTERN_HEIGHT * PATTERN_WIDTH * 3];
432 int i, j, l;443 int i, j, l;
433 int k = 0; // fix VC7 compiler warning: uninitialized variable444 int k = 0; // fix VC7 compiler warning: uninitialized variable
434 int ave, sum, res, res2;445 int ave, sum, res, res2;
@@ -563,7 +574,8 @@
563#ifdef ARTK_DEBUG574#ifdef ARTK_DEBUG
564 printf("%d %d %f\n", res2, res, max);575 printf("%d %d %f\n", res2, res, max);
565#endif576#endif
566577
578 delete[] input;
567 return 0;579 return 0;
568}580}
569581

Subscribers

People subscribed via source and target branches