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

Loading...
Searching...
No Matches
template.h
Go to the documentation of this file.
1/*
2 * AR2/template.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 */
38
39#ifndef AR2_TEMPLATE_H
40#define AR2_TEMPLATE_H
41#include <ARX/AR/ar.h>
42#include <ARX/AR2/config.h>
43#include <ARX/AR2/imageSet.h>
44#include <ARX/AR2/featureSet.h>
45
46#ifdef __cplusplus
47 extern "C" {
48#endif
49
50
51#define AR2_TEMPLATE_NULL_PIXEL 0x1000
52
53
54 typedef struct {
55 int xsize, ysize; /* template size */
56 int xts1, xts2; /* template size */
57 int yts1, yts2; /* template size */
58 ARUint16 *img1; /* template for mode 0 */
59 int vlen; /* length of vector *img */
60 int sum;
61 int validNum;
62} AR2TemplateT;
63
64#if AR2_CAPABLE_ADAPTIVE_TEMPLATE
65 typedef struct {
66 int xsize, ysize; /* template size */
67 int xts1, xts2; /* template size */
68 int yts1, yts2; /* template size */
69 ARUint16 *img1[3]; /* template for mode 0 */
70 int vlen[3]; /* length of vector *img */
71 int sum[3];
72 int validNum;
73} AR2Template2T;
74#endif
75
76
77 typedef struct {
78 int snum;
79 int level;
80 int num;
81 int flag; // Set to -1 to indicate that this candidate is the last candidate in the list/array (i.e. candidate count has reached AR2_TRACKING_CANDIDATE_MAX). 0 to indicate a valid candidate. Set to 1 to indicate that this template has been chosen as a candidate.
82 float sx, sy;
83} AR2TemplateCandidateT;
84
85
86
87#if AR2_CAPABLE_ADAPTIVE_TEMPLATE
88 AR_EXTERN AR2TemplateT *ar2GenTemplate ( int ts1, int ts2 );
89 AR_EXTERN AR2Template2T *ar2GenTemplate2 ( int ts1, int ts2 );
90 AR_EXTERN int ar2FreeTemplate ( AR2TemplateT *templ );
91 AR_EXTERN int ar2FreeTemplate2( AR2Template2T *templ2 );
92
93 AR_EXTERN int ar2SetTemplateSub ( const ARParamLT *cparamLT, const float trans[3][4], AR2ImageSetT *imageSet,
94 AR2FeaturePointsT *featurePoints, int num, int blurLevel,
95 AR2TemplateT *templ );
96 AR_EXTERN int ar2SetTemplate2Sub( const ARParamLT *cparamLT, const float trans[3][4], AR2ImageSetT *imageSet,
97 AR2FeaturePointsT *featurePoints, int num, int blurLevel,
98 AR2Template2T *templ2 );
99#else
100 AR_EXTERN AR2TemplateT *ar2GenTemplate ( int ts1, int ts2 );
101 AR_EXTERN int ar2FreeTemplate( AR2TemplateT *templ );
102
103 AR_EXTERN int ar2SetTemplateSub ( const ARParamLT *cparamLT, const float trans[3][4], AR2ImageSetT *imageSet,
104 AR2FeaturePointsT *featurePoints, int num,
105 AR2TemplateT *templ );
106#endif
107
108
109 AR_EXTERN int ar2GetBestMatching ( ARUint8 *img, ARUint8 *mfImage, int xsize, int ysize, AR_PIXEL_FORMAT pixFormat,
110 AR2TemplateT *mtemp, int rx, int ry,
111 int search[3][2], int *bx, int *by, float *val);
112
113#if AR2_CAPABLE_ADAPTIVE_TEMPLATE
114 AR_EXTERN int ar2GetBestMatching2( ARUint8 *img, ARUint8 *mfImage, int xsize, int ysize, AR_PIXEL_FORMAT pixFormat,
115 AR2Template2T *mtemp, int rx, int ry,
116 int search[3][2], int *bx, int *by, float *val, int *blurLevel);
117#else
118 AR_EXTERN int ar2GetBestMatching2(void);
119#endif
120
121 AR_EXTERN int ar2GetResolution( const ARParamLT *cparamLT, const float trans[3][4], const float pos[2], float dpi[2] );
122 AR_EXTERN int ar2GetResolution2( const ARParam *cparam, const float trans[3][4], const float pos[2], float dpi[2] );
123
124// Returns -1 if no template selected, otherwise returns the 0-based index of the selected template
125// and sets 'flag' of the template to 1.
126 AR_EXTERN int ar2SelectTemplate( AR2TemplateCandidateT *candidate, AR2TemplateCandidateT *prevFeature, int num,
127 float pos[4][2], int xsize, int ysize );
128
129
130
131#ifdef __cplusplus
132}
133#endif
134#endif
ar.h
artoolkitX core routines.
ARUint8
unsigned char ARUint8
Definition: ar.h:92
ARUint16
unsigned short ARUint16
Definition: ar.h:93
AR_EXTERN
#define AR_EXTERN
Definition: ar.h:131
config.h
featureSet.h
imageSet.h
AR2FeaturePointsT
Definition: featureSet.h:64
AR2ImageSetT
Definition: imageSet.h:64
AR2TemplateCandidateT
Definition: template.h:77
AR2TemplateCandidateT::level
int level
Definition: template.h:79
AR2TemplateCandidateT::snum
int snum
Definition: template.h:78
AR2TemplateCandidateT::num
int num
Definition: template.h:80
AR2TemplateCandidateT::flag
int flag
Definition: template.h:81
AR2TemplateCandidateT::sx
float sx
Definition: template.h:82
AR2TemplateT
Definition: template.h:54
AR2TemplateT::validNum
int validNum
Definition: template.h:61
AR2TemplateT::img1
ARUint16 * img1
Definition: template.h:58
AR2TemplateT::xsize
int xsize
Definition: template.h:55
AR2TemplateT::sum
int sum
Definition: template.h:60
AR2TemplateT::vlen
int vlen
Definition: template.h:59
AR2TemplateT::xts1
int xts1
Definition: template.h:56
AR2TemplateT::yts1
int yts1
Definition: template.h:57
ARParam
Structure holding camera parameters, including image size, projection matrix and lens distortion para...
Definition: param.h:99
ARParamLT
Structure holding camera parameters, in lookup table form.
Definition: param.h:151
ar2SelectTemplate
AR_EXTERN int ar2SelectTemplate(AR2TemplateCandidateT *candidate, AR2TemplateCandidateT *prevFeature, int num, float pos[4][2], int xsize, int ysize)
Definition: selectTemplate.c:134
ar2SetTemplateSub
AR_EXTERN int ar2SetTemplateSub(const ARParamLT *cparamLT, const float trans[3][4], AR2ImageSetT *imageSet, AR2FeaturePointsT *featurePoints, int num, AR2TemplateT *templ)
Definition: template.c:115
ar2GetResolution
AR_EXTERN int ar2GetResolution(const ARParamLT *cparamLT, const float trans[3][4], const float pos[2], float dpi[2])
Definition: selectTemplate.c:51
ar2GetBestMatching2
AR_EXTERN int ar2GetBestMatching2(void)
Definition: matching2.c:168
ar2FreeTemplate
AR_EXTERN int ar2FreeTemplate(AR2TemplateT *templ)
Definition: template.c:90
ar2GenTemplate
AR_EXTERN AR2TemplateT * ar2GenTemplate(int ts1, int ts2)
Definition: template.c:53
ar2GetResolution2
AR_EXTERN int ar2GetResolution2(const ARParam *cparam, const float trans[3][4], const float pos[2], float dpi[2])
Definition: selectTemplate.c:61
ar2GetBestMatching
AR_EXTERN int ar2GetBestMatching(ARUint8 *img, ARUint8 *mfImage, int xsize, int ysize, AR_PIXEL_FORMAT pixFormat, AR2TemplateT *mtemp, int rx, int ry, int search[3][2], int *bx, int *by, float *val)
Get best match for a candidate feature template.
Definition: matching.c:81