| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
tracking.h
Go to the documentation of this file.
1/*
2 * AR2/tracking.h
3 * artoolkitX
4 *
5 * This file is part of artoolkitX.
6 *
7 * artoolkitX is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * artoolkitX is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with artoolkitX. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * As a special exception, the copyright holders of this library give you
21 * permission to link this library with independent modules to produce an
22 * executable, regardless of the license terms of these independent modules, and to
23 * copy and distribute the resulting executable under terms of your choice,
24 * provided that you also meet, for each linked independent module, the terms and
25 * conditions of the license of that module. An independent module is a module
26 * which is neither derived from nor based on this library. If you modify this
27 * library, you may extend this exception to your version of the library, but you
28 * are not obligated to do so. If you do not wish to do so, delete this exception
29 * statement from your version.
30 *
31 * Copyright 2018 Realmax, Inc.
32 * Copyright 2015 Daqri, LLC.
33 * Copyright 2006-2015 ARToolworks, Inc.
34 *
35 * Author(s): Hirokazu Kato, Philip Lamb
36 *
37 */
48#ifndef AR2_TRACKING_H
49#define AR2_TRACKING_H
50#include <ARX/ARUtil/thread_sub.h>
51#include <ARX/AR/ar.h>
52#include <ARX/AR/icp.h>
53#include <ARX/AR2/config.h>
54#include <ARX/AR2/featureSet.h>
55#include <ARX/AR2/template.h>
56#include <ARX/AR2/marker.h>
57
58#define AR2_TRACKING_6DOF 1
59#define AR2_TRACKING_HOMOGRAPHY 2
60
61#define AR2_TRACKING_DEFAULT_THREAD_NUM -1
62
63#ifdef __cplusplus
64 extern "C" {
65#endif
66
67 typedef struct {
68 AR2ImageSetT *imageSet;
69 AR2FeatureSetT *featureSet;
70 AR2MarkerSetT *markerSet;
71 float trans[3][4];
72 float itrans[3][4];
73 char *jpegName;
74} AR2SurfaceT;
75
76 typedef struct {
77 AR2SurfaceT *surface;
78 int num;
79 float trans1[3][4];
80 float trans2[3][4];
81 float trans3[3][4];
82 int contNum;
83 AR2TemplateCandidateT prevFeature[AR2_SEARCH_FEATURE_MAX+1];
84} AR2SurfaceSetT;
85
86 typedef struct {
87 float sim;
88 float pos2d[2];
89 float pos3d[3];
90#if AR2_CAPABLE_ADAPTIVE_TEMPLATE
91 int blurLevel;
92#endif
93} AR2Tracking2DResultT;
94
95
96 typedef struct _AR2HandleT AR2HandleT;
97 typedef struct _AR2Tracking2DParamT AR2Tracking2DParamT;
98
99// Structure to pass parameters to threads spawned to run ar2Tracking2d().
100 struct _AR2Tracking2DParamT {
101 struct _AR2HandleT *ar2Handle; // Reference to parent AR2HandleT.
102 AR2SurfaceSetT *surfaceSet;
103 AR2TemplateCandidateT *candidate;
104 ARUint8 *dataPtr; // Input image.
105 ARUint8 *mfImage; // (Internally allocated buffer same size as input image).
106 AR2TemplateT *templ;
107#if AR2_CAPABLE_ADAPTIVE_TEMPLATE
108 AR2Template2T *templ2;
109#endif
110 AR2Tracking2DResultT result;
111 int ret;
112};
113
114 struct _AR2HandleT {
115 int trackingMode;
116 int xsize;
117 int ysize;
118 ARParamLT *cparamLT;
119 ICPHandleT *icpHandle;
120 AR_PIXEL_FORMAT pixFormat;
121#if AR2_CAPABLE_ADAPTIVE_TEMPLATE
122 int blurMethod;
123 int blurLevel;
124#endif
125 int searchSize;
126 int templateSize1;
127 int templateSize2;
128 int searchFeatureNum;
129 float simThresh;
130 float trackingThresh;
131 /*--------------------------------*/
132 float wtrans1[AR2_TRACKING_SURFACE_MAX][3][4];
133 float wtrans2[AR2_TRACKING_SURFACE_MAX][3][4];
134 float wtrans3[AR2_TRACKING_SURFACE_MAX][3][4];
135 float pos[AR2_SEARCH_FEATURE_MAX+AR2_THREAD_MAX][2];
136 float pos2d[AR2_SEARCH_FEATURE_MAX][2];
137 float pos3d[AR2_SEARCH_FEATURE_MAX][3];
138 AR2TemplateCandidateT candidate[AR2_TRACKING_CANDIDATE_MAX+1];
139 AR2TemplateCandidateT candidate2[AR2_TRACKING_CANDIDATE_MAX+1];
140 AR2TemplateCandidateT usedFeature[AR2_SEARCH_FEATURE_MAX];
141 int threadNum;
142 struct _AR2Tracking2DParamT arg[AR2_THREAD_MAX];
143 THREAD_HANDLE_T *threadHandle[AR2_THREAD_MAX];
144};
145
146
170 int ar2Tracking ( AR2HandleT *ar2Handle, AR2SurfaceSetT *surfaceSet,
171 ARUint8 *dataPtr, float trans[3][4], float *err );
172 void *ar2Tracking2d ( THREAD_HANDLE_T *threadHandle );
173/*
174 int ar2Tracking2d ( AR2HandleT *ar2Handle, AR2SurfaceSetT *surfaceSet,
175 AR2TemplateCandidateT *candidate,
176 ARUint8 *dataPtr, AR2Tracking2DResultT *result );
177*/
178
192 AR2SurfaceSetT *ar2ReadSurfaceSet ( const char *filename, const char *ext, ARPattHandle *pattHandle );
193
203 int ar2FreeSurfaceSet ( AR2SurfaceSetT **surfaceSet );
204
217 int ar2SetInitTrans ( AR2SurfaceSetT *surfaceSet, float trans[3][4] );
218
237 AR2HandleT *ar2CreateHandle ( ARParamLT *cparamLT, AR_PIXEL_FORMAT pixFormat, int threadNum );
238
255 AR2HandleT *ar2CreateHandleHomography ( int xsize, int ysize, AR_PIXEL_FORMAT pixFormat, int threadNum );
256
267 int ar2DeleteHandle ( AR2HandleT **ar2Handle );
268
269#if AR2_CAPABLE_ADAPTIVE_TEMPLATE
270 int ar2SetBlurMethod ( AR2HandleT *ar2Handle, int blurMethod );
271 int ar2GetBlurMethod ( AR2HandleT *ar2Handle, int *blurMethod );
272 int ar2SetBlurLevel ( AR2HandleT *ar2Handle, int blurLevel );
273 int ar2GetBlurLevel ( AR2HandleT *ar2Handle, int *blurLevel );
274#endif
275
294 int ar2SetSearchSize ( AR2HandleT *ar2Handle, int searchSize );
295
306 int ar2GetSearchSize ( AR2HandleT *ar2Handle, int *searchSize );
307
314 int ar2SetTemplateSize1 ( AR2HandleT *ar2Handle, int templateSize1 );
315
322 int ar2GetTemplateSize1 ( AR2HandleT *ar2Handle, int *templateSize1 );
323
330 int ar2SetTemplateSize2 ( AR2HandleT *ar2Handle, int templateSize2 );
331
338 int ar2GetTemplateSize2 ( AR2HandleT *ar2Handle, int *templateSize2 );
339
346 int ar2SetSearchFeatureNum ( AR2HandleT *ar2Handle, int searchTemplateMax );
347
354 int ar2GetSearchFeatureNum ( AR2HandleT *ar2Handle, int *searchTemplateMax );
355
362 int ar2SetSimThresh ( AR2HandleT *ar2Handle, float simThresh );
363
370 int ar2GetSimThresh ( AR2HandleT *ar2Handle, float *simThresh );
371
389 int ar2SetTrackingThresh ( AR2HandleT *ar2Handle, float trackingThresh );
390
401 int ar2GetTrackingThresh ( AR2HandleT *ar2Handle, float *trackingThresh );
402
415 int ar2SetTrackingMode ( AR2HandleT *ar2Handle, int trackingMode );
416
426 int ar2GetTrackingMode ( AR2HandleT *ar2Handle, int *trackingMode );
427
428#ifdef __cplusplus
429}
430#endif
431#endif
ar.h
artoolkitX core routines.
ARUint8
unsigned char ARUint8
Definition: ar.h:92
config.h
AR2_SEARCH_FEATURE_MAX
#define AR2_SEARCH_FEATURE_MAX
Definition: config.h:130
AR2_TRACKING_CANDIDATE_MAX
#define AR2_TRACKING_CANDIDATE_MAX
Definition: config.h:126
AR2_THREAD_MAX
#define AR2_THREAD_MAX
Definition: config.h:109
AR2_TRACKING_SURFACE_MAX
#define AR2_TRACKING_SURFACE_MAX
Definition: config.h:125
featureSet.h
icp.h
marker.h
_AR2HandleT
Definition: tracking.h:114
_AR2HandleT::pos
float pos[AR2_SEARCH_FEATURE_MAX+AR2_THREAD_MAX][2]
Definition: tracking.h:135
_AR2HandleT::trackingThresh
float trackingThresh
Definition: tracking.h:130
_AR2HandleT::trackingMode
int trackingMode
Definition: tracking.h:115
_AR2HandleT::templateSize1
int templateSize1
Definition: tracking.h:126
_AR2HandleT::pixFormat
AR_PIXEL_FORMAT pixFormat
Definition: tracking.h:120
_AR2HandleT::pos2d
float pos2d[AR2_SEARCH_FEATURE_MAX][2]
Definition: tracking.h:136
_AR2HandleT::ysize
int ysize
Definition: tracking.h:117
_AR2HandleT::icpHandle
ICPHandleT * icpHandle
Definition: tracking.h:119
_AR2HandleT::searchSize
int searchSize
Definition: tracking.h:125
_AR2HandleT::templateSize2
int templateSize2
Definition: tracking.h:127
_AR2HandleT::threadHandle
THREAD_HANDLE_T * threadHandle[AR2_THREAD_MAX]
Definition: tracking.h:143
_AR2HandleT::wtrans2
float wtrans2[AR2_TRACKING_SURFACE_MAX][3][4]
Definition: tracking.h:133
_AR2HandleT::wtrans1
float wtrans1[AR2_TRACKING_SURFACE_MAX][3][4]
Definition: tracking.h:132
_AR2HandleT::cparamLT
ARParamLT * cparamLT
Definition: tracking.h:118
_AR2HandleT::simThresh
float simThresh
Definition: tracking.h:129
_AR2HandleT::arg
struct _AR2Tracking2DParamT arg[AR2_THREAD_MAX]
Definition: tracking.h:142
_AR2HandleT::threadNum
int threadNum
Definition: tracking.h:141
_AR2HandleT::xsize
int xsize
Definition: tracking.h:116
_AR2HandleT::candidate
AR2TemplateCandidateT candidate[AR2_TRACKING_CANDIDATE_MAX+1]
Definition: tracking.h:138
_AR2HandleT::usedFeature
AR2TemplateCandidateT usedFeature[AR2_SEARCH_FEATURE_MAX]
Definition: tracking.h:140
_AR2HandleT::wtrans3
float wtrans3[AR2_TRACKING_SURFACE_MAX][3][4]
Definition: tracking.h:134
_AR2HandleT::candidate2
AR2TemplateCandidateT candidate2[AR2_TRACKING_CANDIDATE_MAX+1]
Definition: tracking.h:139
_AR2HandleT::searchFeatureNum
int searchFeatureNum
Definition: tracking.h:128
_AR2HandleT::pos3d
float pos3d[AR2_SEARCH_FEATURE_MAX][3]
Definition: tracking.h:137
_AR2Tracking2DParamT
Definition: tracking.h:100
_AR2Tracking2DParamT::ret
int ret
Definition: tracking.h:111
_AR2Tracking2DParamT::result
AR2Tracking2DResultT result
Definition: tracking.h:110
_AR2Tracking2DParamT::templ
AR2TemplateT * templ
Definition: tracking.h:106
_AR2Tracking2DParamT::candidate
AR2TemplateCandidateT * candidate
Definition: tracking.h:103
_AR2Tracking2DParamT::ar2Handle
struct _AR2HandleT * ar2Handle
Definition: tracking.h:101
_AR2Tracking2DParamT::dataPtr
ARUint8 * dataPtr
Definition: tracking.h:104
_AR2Tracking2DParamT::surfaceSet
AR2SurfaceSetT * surfaceSet
Definition: tracking.h:102
_AR2Tracking2DParamT::mfImage
ARUint8 * mfImage
Definition: tracking.h:105
_THREAD_HANDLE_T
Definition: thread_sub.c:78
AR2FeatureSetT
Definition: featureSet.h:73
AR2ImageSetT
Definition: imageSet.h:64
AR2MarkerSetT
Definition: marker.h:54
AR2SurfaceSetT
Definition: tracking.h:76
AR2SurfaceSetT::num
int num
Definition: tracking.h:78
AR2SurfaceSetT::surface
AR2SurfaceT * surface
Definition: tracking.h:77
AR2SurfaceSetT::contNum
int contNum
Definition: tracking.h:82
AR2SurfaceT
Definition: tracking.h:67
AR2SurfaceT::featureSet
AR2FeatureSetT * featureSet
Definition: tracking.h:69
AR2SurfaceT::markerSet
AR2MarkerSetT * markerSet
Definition: tracking.h:70
AR2SurfaceT::imageSet
AR2ImageSetT * imageSet
Definition: tracking.h:68
AR2SurfaceT::jpegName
char * jpegName
Definition: tracking.h:73
AR2TemplateCandidateT
Definition: template.h:77
AR2TemplateT
Definition: template.h:54
AR2Tracking2DResultT
Definition: tracking.h:86
AR2Tracking2DResultT::sim
float sim
Definition: tracking.h:87
ARParamLT
Structure holding camera parameters, in lookup table form.
Definition: param.h:151
ARPattHandle
A structure which holds descriptions of trained patterns for template matching.
Definition: ar.h:268
ICPHandleT
Definition: icp.h:75
template.h
thread_sub.h
ar2ReadSurfaceSet
AR2SurfaceSetT * ar2ReadSurfaceSet(const char *filename, const char *ext, ARPattHandle *pattHandle)
Definition: surface.c:51
ar2GetTemplateSize2
int ar2GetTemplateSize2(AR2HandleT *ar2Handle, int *templateSize2)
Definition: handle.c:277
ar2GetTemplateSize1
int ar2GetTemplateSize1(AR2HandleT *ar2Handle, int *templateSize1)
Definition: handle.c:263
ar2SetSearchFeatureNum
int ar2SetSearchFeatureNum(AR2HandleT *ar2Handle, int searchTemplateMax)
Definition: handle.c:236
ar2Tracking
int ar2Tracking(AR2HandleT *ar2Handle, AR2SurfaceSetT *surfaceSet, ARUint8 *dataPtr, float trans[3][4], float *err)
Definition: tracking.c:68
ar2GetSearchFeatureNum
int ar2GetSearchFeatureNum(AR2HandleT *ar2Handle, int *searchTemplateMax)
Definition: handle.c:249
ar2SetTemplateSize1
int ar2SetTemplateSize1(AR2HandleT *ar2Handle, int templateSize1)
Definition: handle.c:256
ar2SetTemplateSize2
int ar2SetTemplateSize2(AR2HandleT *ar2Handle, int templateSize2)
Definition: handle.c:270
ar2DeleteHandle
int ar2DeleteHandle(AR2HandleT **ar2Handle)
Definition: handle.c:125
ar2GetTrackingThresh
int ar2GetTrackingThresh(AR2HandleT *ar2Handle, float *trackingThresh)
Definition: handle.c:215
ar2SetSearchSize
int ar2SetSearchSize(AR2HandleT *ar2Handle, int searchSize)
Definition: handle.c:222
ar2SetSimThresh
int ar2SetSimThresh(AR2HandleT *ar2Handle, float simThresh)
Definition: handle.c:194
ar2Tracking2d
void * ar2Tracking2d(THREAD_HANDLE_T *threadHandle)
Definition: tracking2d.c:59
ar2SetTrackingMode
int ar2SetTrackingMode(AR2HandleT *ar2Handle, int trackingMode)
Definition: handle.c:149
ar2CreateHandleHomography
AR2HandleT * ar2CreateHandleHomography(int xsize, int ysize, AR_PIXEL_FORMAT pixFormat, int threadNum)
Definition: handle.c:64
ar2CreateHandle
AR2HandleT * ar2CreateHandle(ARParamLT *cparamLT, AR_PIXEL_FORMAT pixFormat, int threadNum)
Definition: handle.c:50
ar2GetTrackingMode
int ar2GetTrackingMode(AR2HandleT *ar2Handle, int *trackingMode)
Definition: handle.c:157
ar2SetTrackingThresh
int ar2SetTrackingThresh(AR2HandleT *ar2Handle, float trackingThresh)
Definition: handle.c:208
ar2FreeSurfaceSet
int ar2FreeSurfaceSet(AR2SurfaceSetT **surfaceSet)
Definition: surface.c:212
ar2SetInitTrans
int ar2SetInitTrans(AR2SurfaceSetT *surfaceSet, float trans[3][4])
Definition: surface.c:234
ar2GetSearchSize
int ar2GetSearchSize(AR2HandleT *ar2Handle, int *searchSize)
Definition: handle.c:229
ar2GetSimThresh
int ar2GetSimThresh(AR2HandleT *ar2Handle, float *simThresh)
Definition: handle.c:201