Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
204 chris 1
/*  --------------------------------------------------------------------------
2
*   Copyright (c) 20042-2006 HIT Lab NZ.
3
*   The distribution policy is described in the file COPYING.txt furnished
4
*    with this library.
5
*   -------------------------------------------------------------------------*/
6
/**
7
*  \file ar.h
8
*  \brief ARToolKit subroutines.
9
*
10
*  Core of the ARToolKit Library. This file provides image analysis and marker
11
*  detection routines. Differents routines give access to camera and marker
12
*  configurations. Other routines manipulate marker info structures for
13
*  deliver 3D transformation of markers (more precisely the position of the camera
14
*  in function of the marker coordinate system).
15
*      
16
*   \remark
17
*
18
*   History :
19
*
20
*  \author Hirokazu Kato kato@sys.im.hiroshima-cu.ac.jp
21
*  \version 3.1
22
*  \date 01/12/07
23
**/
24
/*  --------------------------------------------------------------------------
25
*   History :
26
*   Rev         Date            Who             Changes
27
*
28
*----------------------------------------------------------------------------*/
29
 
30
#ifndef AR_H
31
#define AR_H
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
 
36
// ============================================================================
37
//      Public includes.
38
// ============================================================================
39
 
40
#include <stdio.h>
41
#ifndef __APPLE__
42
#include <malloc.h>
43
#else
44
#include <stdlib.h>
45
#endif
46
 
47
#include <AR/config.h>
48
#include <AR/param.h>
49
 
50
// ============================================================================
51
//      Public types and defines.
52
// ============================================================================
53
 
54
/** \def arMalloc(V,T,S)
55
* \brief allocation macro function
56
*
57
* allocate S elements of type T.
58
* \param V returned allocated area pointer
59
* \param T type of element
60
* \param S number of elements
61
*/
62
#define arMalloc(V,T,S)  \
63
{ if( ((V) = (T *)malloc( sizeof(T) * (S) )) == 0 ) \
64
{printf("malloc error!!\n"); exit(1);} }
65
 
66
/* overhead ARToolkit type*/
67
typedef char              ARInt8;
68
typedef short             ARInt16;
69
typedef int               ARInt32;
70
typedef unsigned char     ARUint8;
71
typedef unsigned short    ARUint16;
72
typedef unsigned int      ARUint32;
73
 
74
/** \typedef AR_PIXEL_FORMAT
75
        \brief ARToolKit pixel-format specifiers.
76
 
77
        ARToolKit functions can accept pixel data in a variety of formats.
78
        This enumerations provides a set of constants you can use to request
79
        data in a particular pixel format from an ARToolKit function that
80
        returns data to you, or to specify that data you are providing to an
81
        ARToolKit function is in a particular pixel format.
82
 
83
        AR_PIXEL_FORMAT_RGB
84
        Each pixel is represented by 24 bits. Eight bits per each Red, Green,
85
        and Blue component. This is the native 24 bit format for the Mac platform.
86
 
87
        AR_PIXEL_FORMAT_BGR
88
        Each pixel is represented by 24 bits. Eight bits per each Blue, Red, and
89
        Green component. This is the native 24 bit format for the Win32 platform.
90
 
91
        AR_PIXEL_FORMAT_RGBA
92
        Each pixel is represented by 32 bits. Eight bits per each Red, Green,
93
        Blue, and Alpha component.
94
 
95
        AR_PIXEL_FORMAT_BGRA
96
        Each pixel is represented by 32 bits. Eight bits per each Blue, Green,
97
        Red, and Alpha component. This is the native 32 bit format for the Win32
98
        platform.
99
 
100
        AR_PIXEL_FORMAT_ABGR
101
        Each pixel is represented by 32 bits. Eight bits per each Alpha, Blue,
102
        Green, and Red component. This is the native 32 bit format for the SGI
103
        platform.
104
 
105
        AR_PIXEL_FORMAT_ARGB
106
        Each pixel is represented by 32 bits. Eight bits per each Alpha, Red,
107
        Green, and Blue component. This is the native 32 bit format for the Mac
108
        platform.
109
 
110
        AR_PIXEL_FORMAT_MONO
111
        Each pixel is represented by 8 bits of luminance information.
112
 
113
        AR_PIXEL_FORMAT_2vuy
114
        8-bit 4:2:2 Component Y'CbCr format. Each 16 bit pixel is represented
115
        by an unsigned eight bit luminance component and two unsigned eight bit
116
        chroma components. Each pair of pixels shares a common set of chroma
117
        values. The components are ordered in memory; Cb, Y0, Cr, Y1. The
118
        luminance components have a range of [16, 235], while the chroma value
119
        has a range of [16, 240]. This is consistent with the CCIR601 spec.
120
        This format is fairly prevalent on both Mac and Win32 platforms.
121
        '2vuy' is the Apple QuickTime four-character code for this pixel format.
122
        The equivalent Microsoft fourCC is 'UYVY'.
123
 
124
        AR_PIXEL_FORMAT_yuvs
125
        8-bit 4:2:2 Component Y'CbCr format. Identical to the AR_PIXEL_FORMAT_2vuy except
126
        each 16 bit word has been byte swapped. This results in a component
127
        ordering of; Y0, Cb, Y1, Cr.
128
        This is most prevalent yuv 4:2:2 format on both Mac and Win32 platforms.
129
        'yuvs' is the Apple QuickTime four-character code for this pixel format.
130
        The equivalent Microsoft fourCC is 'YUY2'.
131
 */
132
typedef int AR_PIXEL_FORMAT;
133
 
134
/** \struct ARMarkerInfo
135
* \brief main structure for detected marker.
136
*
137
* Store information after contour detection (in idea screen coordinate, after distorsion compensated).
138
* \remark lines are represented by 3 values a,b,c for ax+by+c=0
139
* \param area number of pixels in the labeled region
140
* \param id marker identitied number
141
* \param dir Direction that tells about the rotation about the marker (possible values are 0, 1, 2 or 3). This parameter makes it possible to tell about the line order of the detected marker (so which line is the first one) and so find the first vertex. This is important to compute the transformation matrix in arGetTransMat().
142
* \param cf confidence value (probability to be a marker)
143
* \param pos center of marker (in ideal screen coordinates)
144
* \param line line equations for four side of the marker (in ideal screen coordinates)
145
* \param vertex edge points of the marker (in ideal screen coordinates)
146
*/
147
typedef struct {
148
    int     area;
149
    int     id;
150
    int     dir;
151
    double  cf;
152
    double  pos[2];
153
    double  line[4][3];
154
    double  vertex[4][2];
155
} ARMarkerInfo;
156
 
157
/** \struct ARMarkerInfo2
158
* \brief internal structure use for marker detection.
159
*
160
* Store information after contour detection (in observed screen coordinate, before distorsion correction).
161
* \param area number of pixels in the labeled region
162
* \param pos position of the center of the marker (in observed screen coordinates)
163
* \param coord_num numer of pixels in the contour.
164
* \param x_coord x coordinate of the pixels of contours (size limited by AR_CHAIN_MAX).
165
* \param y_coord y coordinate of the pixels of contours (size limited by AR_CHAIN_MAX).
166
* \param vertex position of the vertices of the marker. (in observed screen coordinates)
167
                 rem:the first vertex is stored again as the 5th entry in the array – for convenience of drawing a line-strip easier.
168
*
169
*/
170
typedef struct {
171
    int     area;
172
    double  pos[2];
173
    int     coord_num;
174
    int     x_coord[AR_CHAIN_MAX];
175
    int     y_coord[AR_CHAIN_MAX];
176
    int     vertex[5];
177
} ARMarkerInfo2;
178
 
179
// ============================================================================
180
//      Public globals.
181
// ============================================================================
182
 
183
/** \var int arDebug
184
* \brief activate artoolkit debug mode
185
*
186
* control debug informations in ARToolKit.
187
* the possible values are:
188
* - 0: not in debug mode
189
* - 1: in debug mode
190
* by default: 0
191
*/
192
extern int      arDebug;
193
 
194
/** \var ARUint8 *arImage
195
* \brief internal image
196
*
197
* internal image used. (access only for debugging ARToolKit)
198
* by default: NULL
199
*/
200
extern ARUint8  *arImage;
201
 
202
/** \var int arFittingMode
203
* \brief fitting display mode use by ARToolkit.
204
*
205
* Correction mode for the distorsion of the camera.
206
* You can enable a correction with a texture mapping.
207
* the possible values are:
208
* - AR_FITTING_TO_INPUT: input image
209
* - AR_FITTING_TO_IDEAL: compensated image
210
* by default: DEFAULT_FITTING_MODE in config.h
211
*/
212
extern int      arFittingMode;
213
 
214
/** \var int arImageProcMode
215
* \brief define the image size mode for marker detection.
216
*
217
* Video image size for marker detection. This control
218
* if all the image is analyzed
219
* the possible values are :
220
* - AR_IMAGE_PROC_IN_FULL: full image uses.
221
* - AR_IMAGE_PROC_IN_HALF: half image uses.
222
* by default: DEFAULT_IMAGE_PROC_MODE in config.h
223
*/
224
extern int      arImageProcMode;
225
 
226
/** \var ARParam arParam
227
* \brief internal intrinsic camera parameter
228
*
229
* internal variable for camera intrinsic parameters
230
*/
231
extern ARParam  arParam;
232
 
233
/** \var int arImXsize
234
* \brief internal image size in width.
235
*
236
* internal image size in width (generally initialize in arInitCparam)
237
*/
238
/** \var int arImYsize
239
* \brief internal image size in heigth
240
*
241
* internal image size in heigth (generally initialize in arInitCparam)
242
*/
243
extern int      arImXsize, arImYsize;
244
 
245
/** \var int arTemplateMatchingMode
246
* \brief XXXBK
247
*
248
* XXXBK
249
* the possible values are :
250
* AR_TEMPLATE_MATCHING_COLOR: Color Template
251
* AR_TEMPLATE_MATCHING_BW: BW Template
252
* by default: DEFAULT_TEMPLATE_MATCHING_MODE in config.h
253
*/
254
extern int      arTemplateMatchingMode;
255
 
256
/** \var int arMatchingPCAMode
257
* \brief XXXBK
258
*
259
* XXXBK
260
* the possible values are :
261
* -AR_MATCHING_WITHOUT_PCA: without PCA
262
* -AR_MATCHING_WITH_PCA: with PCA
263
* by default: DEFAULT_MATCHING_PCA_MODE in config.h
264
*/
265
extern int      arMatchingPCAMode;
266
 
267
// ============================================================================
268
//      Public functions.
269
// ============================================================================
270
 
271
/*
272
   Initialization
273
*/
274
 
275
/**
276
 * \brief Get the ARToolKit version information in numberic and string format.
277
 *
278
 * As of version 2.72, ARToolKit now allows querying of the version number
279
 * of the toolkit available at runtime. It is highly recommended that
280
 * any calling program that depends on features in a certain
281
 * ARToolKit version, check at runtime that it is linked to a version
282
 * of ARToolKit that can supply those features. It is NOT sufficient
283
 * to check the ARToolKit SDK header versions, since with ARToolKit implemented
284
 * in dynamically-loaded libraries, there is no guarantee that the
285
 * version of ARToolKit installed on the machine at run-time will as
286
 * recent as the version of the ARToolKit SDK which the host
287
 * program was compiled against.
288
 * The version information is reported in binary-coded decimal format,
289
 * and optionally in an ASCII string. See the config.h header
290
 * for more discussion of the definition of major, minor, tiny and build
291
 * version numbers.
292
 *
293
 * \param versionStringRef
294
 *      If non-NULL, the location pointed to will be filled
295
 *      with a pointer to a string containing the version information.
296
 *  Fields in the version string are separated by spaces. As of version
297
 *  2.72.0, there is only one field implemented, and this field
298
 *  contains the major, minor and tiny version numbers
299
 *      in dotted-decimal format. The string is guaranteed to contain
300
 *  at least this field in all future versions of the toolkit.
301
 *  Later versions of the toolkit may add other fields to this string
302
 *  to report other types of version information. The storage for the
303
 *  string is malloc'ed inside the function. The caller is responsible
304
 *  for free'ing the string.
305
 *
306
 * \return Returns the full version number of the ARToolKit in
307
 *      binary coded decimal (BCD) format.
308
 *  BCD format allows simple tests of version number in the caller
309
 *  e.g. if ((arGetVersion(NULL) >> 16) > 0x0272) printf("This release is later than 2.72\n");
310
 *      The major version number is encoded in the most-significant byte
311
 *  (bits 31-24), the minor version number in the second-most-significant
312
 *      byte (bits 23-16), the tiny version number in the third-most-significant
313
 *  byte (bits 15-8), and the build version number in the least-significant
314
 *      byte (bits 7-0).
315
 */
316
ARUint32 arGetVersion(char **versionStringRef);
317
 
318
/**
319
* \brief initialize camera parameters.
320
*
321
* set the camera parameters specified in the camera parameters structure
322
* *param to static memory in the AR library. These camera parameters are  
323
* typically read from a data file at program startup. In the video-see through
324
* AR applications, the default camera parameters are sufficient, no camera
325
* calibration is needed.
326
* \param param the camera parameter structure
327
* \return always 0
328
*/
329
int arInitCparam( ARParam *param );
330
 
331
/**
332
* \brief load markers description from a file
333
*
334
* load the bitmap pattern specified in the file filename into the pattern
335
* matching array for later use by the marker detection routines.
336
* \param filename name of the file containing the pattern bitmap to be loaded
337
* \return the identity number of the pattern loaded or –1 if the pattern load failed.
338
*/
339
int arLoadPatt( const char *filename );
340
 
341
/*
342
   Detection
343
*/
344
 
345
/**
346
* \brief main function to detect the square markers in the video input frame.
347
*
348
* This function proceeds to thresholding, labeling, contour extraction and line corner estimation
349
* (and maintains an history).
350
* It's one of the main function of the detection routine with arGetTransMat.
351
* \param dataPtr a pointer to the color image which is to be searched for square markers.
352
*                The pixel format depend of your architecture. Generally ABGR, but the images
353
*                are treated as a gray scale, so the order of BGR components does not matter.
354
*                However the ordering of the alpha comp, A, is important.
355
* \param thresh  specifies the threshold value (between 0-255) to be used to convert
356
*                the input image into a binary image.
357
* \param marker_info a pointer to an array of ARMarkerInfo structures returned
358
*                    which contain all the information about the detected squares in the image
359
* \param marker_num the number of detected markers in the image.
360
* \return 0 when the function completes normally, -1 otherwise
361
*/
362
int arDetectMarker( ARUint8 *dataPtr, int thresh,
363
                    ARMarkerInfo **marker_info, int *marker_num );
364
 
365
/**
366
* \brief main function to detect rapidly the square markers in the video input frame.
367
*
368
* this function is a simpler version of arDetectMarker that does not have the
369
* same error correction functions and so runs a little faster, but is more error prone
370
*
371
* \param dataPtr a pointer to the color image which is to be searched for square markers.
372
*                The pixel format depend of your architecture. Generally ABGR, but the images
373
*                are treated as a gray scale, so the order of BGR components does not matter.
374
*                However the ordering of the alpha component, A, is important.
375
* \param thresh  specifies the threshold value (between 0-255) to be used to convert
376
*                the input image into a binary image.
377
* \param marker_info a pointer to an array of ARMarkerInfo structures returned
378
*                    which contain all the information about the detected squares in the image
379
* \param marker_num the number of detected markers in the image.
380
* \return 0 when the function completes normally, -1 otherwise
381
*/
382
int arDetectMarkerLite( ARUint8 *dataPtr, int thresh,
383
                        ARMarkerInfo **marker_info, int *marker_num );
384
 
385
/**
386
* \brief compute camera position in function of detected markers.
387
*
388
* calculate the transformation between a detected marker and the real camera,
389
* i.e. the position and orientation of the camera relative to the tracking mark.
390
* \param marker_info the structure containing the parameters for the marker for
391
*                    which the camera position and orientation is to be found relative to.
392
*                    This structure is found using arDetectMarker.
393
* \param center the physical center of the marker. arGetTransMat assumes that the marker
394
*              is in x-y plane, and z axis is pointing downwards from marker plane.
395
*              So vertex positions can be represented in 2D coordinates by ignoring the
396
*              z axis information. The marker vertices are specified in order of clockwise.
397
* \param width the size of the marker (in mm).
398
* \param conv the transformation matrix from the marker coordinates to camera coordinate frame,
399
*             that is the relative position of real camera to the real marker
400
* \return always 0.
401
*/
402
double arGetTransMat( ARMarkerInfo *marker_info,
403
                      double center[2], double width, double conv[3][4] );
404
 
405
/**
406
* \brief compute camera position in function of detected marker with an history function.
407
*
408
* calculate the transformation between a detected marker and the real camera,
409
* i.e. the position and orientation of the camera relative to the tracking mark. Since
410
* this routine operate on previous values, the result are more stable (less jittering).
411
*
412
* \param marker_info the structure containing the parameters for the marker for
413
*                    which the camera position and orientation is to be found relative to.
414
*                    This structure is found using arDetectMarker.
415
* \param prev_conv the previous transformation matrix obtain.
416
* \param center the physical center of the marker. arGetTransMat assumes that the marker
417
*              is in x-y plane, and z axis is pointing downwards from marker plane.
418
*              So vertex positions can be represented in 2D coordinates by ignoring the
419
*              z axis information. The marker vertices are specified in order of clockwise.
420
* \param width the size of the marker (in mm).
421
* \param conv the transformation matrix from the marker coordinates to camera coordinate frame,
422
*             that is the relative position of real camera to the real marker
423
* \return always 0.
424
*/
425
double arGetTransMatCont( ARMarkerInfo *marker_info, double prev_conv[3][4],
426
                          double center[2], double width, double conv[3][4] );
427
 
428
double arGetTransMat2( double rot[3][3], double pos2d[][2],
429
                       double pos3d[][2], int num, double conv[3][4] );
430
double arGetTransMat3( double rot[3][3], double ppos2d[][2],
431
                     double ppos3d[][2], int num, double conv[3][4],
432
                     double *dist_factor, double cpara[3][4] );
433
double arGetTransMat4( double rot[3][3], double ppos2d[][2],
434
                       double ppos3d[][3], int num, double conv[3][4] );
435
double arGetTransMat5( double rot[3][3], double ppos2d[][2],
436
                       double ppos3d[][3], int num, double conv[3][4],
437
                       double *dist_factor, double cpara[3][4] );
438
 
439
/**
440
* \brief remove a pattern from memory.
441
*
442
* desactivate a pattern and remove from memory. post-condition
443
* of this function is unavailability of the pattern.
444
* \param patt_no number of pattern to free
445
* \return return 1 in success, -1 if error
446
*/
447
int arFreePatt( int patt_no );
448
 
449
/**
450
* \brief activate a pattern on the recognition procedure.
451
*
452
* Activate a pattern to be check during the template matching
453
* operation.
454
* \param patt_no number of pattern to activate
455
* \return return 1 in success, -1 if error
456
*/
457
int arActivatePatt( int pat_no );
458
 
459
/**
460
* \brief desactivate a pattern on the recognition procedure.
461
*
462
* Desactivate a pattern for not be check during the template matching
463
* operation.
464
* \param patt_no number of pattern to desactivate
465
* \return return 1 in success, -1 if error
466
*/
467
int arDeactivatePatt( int pat_no );
468
 
469
/**
470
* \brief save a marker.
471
*
472
* used in mk_patt to save a bitmap of the pattern of the currently detected marker.
473
* The saved image is a table of the normalized viewed pattern.
474
* \param image a pointer to the image containing the marker pattern to be trained.
475
* \param marker_info a pointer to the ARMarkerInfo structure of the pattern to be trained.
476
* \param filename The name of the file where the bitmap image is to be saved.
477
* \return 0 if the bitmap image is successfully saved, -1 otherwise.
478
*/
479
int arSavePatt( ARUint8 *image,
480
                ARMarkerInfo *marker_info, char *filename );
481
 
482
 
483
/*
484
    Utility
485
*/
486
 
487
/**
488
* \brief Inverse a non-square matrix.
489
*
490
* Inverse a matrix in a non homogeneous format. The matrix
491
* need to be euclidian.
492
* \param s matrix input
493
* \param d resulted inverse matrix.
494
* \return 0 if the inversion success, -1 otherwise
495
* \remark input matrix can be also output matrix
496
*/
497
int    arUtilMatInv( double s[3][4], double d[3][4] );
498
 
499
/**
500
* \brief Multiplication of two matrix.
501
*
502
* This procedure do a multiplication matrix between s1 and s2 and return
503
* the result in d : d=s1*s2. The precondition is the output matrix
504
* need to be different of input matrix. The precondition is euclidian matrix.
505
* \param s1 first matrix.
506
* \param s2 second matrix.
507
* \param d resulted multiplication matrix.
508
* \return 0 if the multiplication success, -1 otherwise
509
*/
510
int    arUtilMatMul( double s1[3][4], double s2[3][4], double d[3][4] );
511
 
512
/**
513
* \brief extract a quaternion/position of matrix.
514
*
515
* Extract a rotation (quaternion format) and a position (vector format)
516
* from a transformation matrix. The precondition is an euclidian matrix.
517
* \param m source matrix
518
* \param q a rotation represented by a quaternion.
519
* \param p a translation represented by a vector.
520
* \return 0 if the extraction success, -1 otherwise (quaternion not normalize)
521
*/
522
int    arUtilMat2QuatPos( double m[3][4], double q[4], double p[3] );
523
 
524
/**
525
* \brief create a matrix with a quaternion/position.
526
*
527
* Create a transformation matrix from a quaternion rotation and a vector translation.
528
* \param q a rotation represented by a quaternion.
529
* \param p a translation represented by a vector.
530
* \param m destination matrix
531
* \return always 0
532
*/
533
int    arUtilQuatPos2Mat( double q[4], double p[3], double m[3][4] );
534
 
535
/**
536
* \brief get the time with the ARToolkit timer.
537
*
538
* Give the time elapsed since the reset of the timer.
539
* \return elapsed time (in milliseconds)
540
*/
541
double arUtilTimer(void);
542
 
543
/**
544
* \brief reset the internal timer of ARToolkit.
545
*
546
* Reset the internal timer used by ARToolKit.
547
* timer measurement (with arUtilTimer()).
548
*/
549
void   arUtilTimerReset(void);
550
 
551
/**
552
* \brief sleep the actual thread.
553
*
554
* Sleep the actual thread.
555
* \param msec time to sleep (in millisecond)
556
*/
557
void   arUtilSleep( int msec );
558
 
559
/*
560
  Internal processing
561
*/
562
 
563
/**
564
* \brief extract connected components from image.
565
*
566
* Label the input image, i.e. extract connected components from the
567
* input video image.
568
* \param image input image, as returned by arVideoGetImage()
569
* \param thresh lighting threshold
570
* \param label_num Ouput- number of detected components
571
* \param area On return, if label_num > 0, points to an array of ints, one for each detected component.
572
* \param pos On return, if label_num > 0, points to an array of doubles, one for each detected component.
573
* \param clip On return, if label_num > 0, points to an array of ints, one for each detected component.
574
* \param label_ref On return, if label_num > 0, points to an array of ints, one for each detected component.
575
* \return returns a pointer to the labeled output image, ready for passing onto the next stage of processing.
576
*/
577
ARInt16 *arLabeling( ARUint8 *image, int thresh,
578
                     int *label_num, int **area, double **pos, int **clip,
579
                     int **label_ref );
580
 
581
/**
582
 * \brief clean up static data allocated by arLabeling.
583
 *
584
 * In debug mode, arLabeling may allocate and use static storage.
585
 * This function deallocates this storage.
586
 */
587
 void arLabelingCleanup(void);
588
 
589
 
590
/**
591
* \brief  XXXBK
592
*
593
*  XXXBK
594
* \param num XXXBK
595
* \param area XXXBK
596
* \param clip XXXBK
597
* \param pos XXXBK
598
*/
599
void arGetImgFeature( int *num, int **area, int **clip, double **pos );
600
 
601
/**
602
* \brief   XXXBK
603
*
604
*   XXXBK
605
* \param limage  XXXBK
606
* \param label_num  XXXBK
607
* \param label_ref  XXXBK
608
* \param warea  XXXBK
609
* \param wpos  XXXBK
610
* \param wclip  XXXBK
611
* \param area_max  XXXBK
612
* \param area_min  XXXBK
613
* \param factor  XXXBK
614
* \param marker_num  XXXBK
615
* \return XXXBK  XXXBK
616
*/
617
ARMarkerInfo2 *arDetectMarker2( ARInt16 *limage,
618
                                int label_num, int *label_ref,
619
                                int *warea, double *wpos, int *wclip,
620
                                int area_max, int area_min, double factor, int *marker_num );
621
 
622
/**
623
* \brief information on
624
*
625
*  XXXBK
626
* \param image XXXBK
627
* \param marker_info2 XXXBK
628
* \param marker_num XXXBK
629
* \return XXXBK
630
*/
631
ARMarkerInfo *arGetMarkerInfo( ARUint8 *image,
632
                               ARMarkerInfo2 *marker_info2, int *marker_num );
633
 
634
/**
635
* \brief  XXXBK
636
*
637
*  XXXBK
638
* \param image XXXBK
639
* \param x_coord XXXBK
640
* \param y_coord XXXBK
641
* \param vertex XXXBK
642
* \param code XXXBK
643
* \param dir XXXBK
644
* \param cf XXXBK
645
* \return XXXBK
646
*/
647
int arGetCode( ARUint8 *image, int *x_coord, int *y_coord, int *vertex,
648
               int *code, int *dir, double *cf );
649
 
650
/**
651
* \brief Get a normalized pattern from a video image.
652
*
653
* This function returns a normalized pattern from a video image. The
654
* format is a table with AR_PATT_SIZE_X by AR_PATT_SIZE_Y
655
* \param image video input image
656
* \param x_coord XXXBK
657
* \param y_coord XXXBK
658
* \param vertex XXXBK
659
* \param ext_pat detected pattern.
660
* \return  XXXBK
661
*/
662
int arGetPatt( ARUint8 *image, int *x_coord, int *y_coord, int *vertex,
663
               ARUint8 ext_pat[AR_PATT_SIZE_Y][AR_PATT_SIZE_X][3] );
664
 
665
/**
666
* \brief estimate a line from a list of point.
667
*
668
* Compute a linear regression from a list of point.
669
* \param x_coord X coordinate of points
670
* \param y_coord Y coordinate of points
671
* \param coord_num number of points
672
* \param vertex XXXBK
673
* \param line XXXBK
674
* \param v XXXBK
675
* \return  XXXBK
676
*/
677
int arGetLine(int x_coord[], int y_coord[], int coord_num,
678
              int vertex[], double line[4][3], double v[4][2]);
679
 
680
/**
681
* \brief  XXXBK
682
*
683
*  XXXBK
684
* \param limage XXXBK
685
* \param label_ref XXXBK
686
* \param label XXXBK
687
* \param clip XXXBK
688
* \param marker_info2 XXXBK
689
* \return  XXXBK
690
*/
691
int arGetContour( ARInt16 *limage, int *label_ref,
692
                  int label, int clip[4], ARMarkerInfo2 *marker_info2 );
693
 
694
/**
695
* \brief  XXXBK
696
*
697
*  XXXBK
698
* \param rot XXXBK
699
* \param trans XXXBK
700
* \param cpara XXXBK
701
* \param vertex XXXBK
702
* \param pos2d XXXBK
703
* \param num XXXBK
704
* \return XXXBK
705
*/
706
double arModifyMatrix( double rot[3][3], double trans[3], double cpara[3][4],
707
                             double vertex[][3], double pos2d[][2], int num );
708
 
709
/**
710
* \brief extract euler angle from a rotation matrix.
711
*
712
* Based on a matrix rotation representation, furnish the cprresponding euler angles.
713
* \param rot the initial rotation matrix
714
* \param wa XXXBK:which element ?
715
* \param wb XXXBK:which element ?
716
* \param wc XXXBK:which element ?
717
* \return XXXBK
718
*/
719
int arGetAngle( double rot[3][3], double *wa, double *wb, double *wc );
720
 
721
/**
722
* \brief create a rotation matrix with euler angle.
723
*
724
* Based on a euler description, furnish a rotation matrix.
725
* \param a XXXBK:which element ?
726
* \param b XXXBK:which element ?
727
* \param c XXXBK:which element ?
728
* \param rot the resulted rotation matrix
729
* \return XXXBK
730
*/
731
int arGetRot( double a, double b, double c, double rot[3][3] );
732
 
733
/**
734
* \brief XXXBK
735
*
736
* XXXBK
737
* \param a XXXBK
738
* \param b XXXBK
739
* \param c XXXBK
740
* \param trans XXXBK
741
* \param trans2 XXXBK
742
* \param cpara XXXBK
743
* \param ret XXXBK
744
* \return XXXBK
745
*/
746
int arGetNewMatrix( double a, double b, double c,
747
                    double trans[3], double trans2[3][4],
748
                    double cpara[3][4], double ret[3][4] );
749
 
750
/**
751
* \brief XXXBK
752
*
753
* XXXBK:initial of what ?
754
* \param marker_info XXXBK
755
* \param cpara XXXBK
756
* \param rot XXXBK
757
* \return XXXBK
758
*/
759
int arGetInitRot( ARMarkerInfo *marker_info, double cpara[3][4], double rot[3][3] );
760
 
761
/** \struct arPrevInfo
762
* \brief structure for temporal continuity of tracking
763
*
764
* History structure for arDetectMarkerLite and arGetTransMatCont
765
*/
766
typedef struct {
767
    ARMarkerInfo  marker;
768
    int     count;
769
} arPrevInfo;
770
 
771
 
772
/*------------------------------------*/
773
 
774
extern ARUint8  *arImageL;
775
extern ARUint8  *arImageR;
776
extern ARSParam arsParam;
777
extern double   arsMatR2L[3][4];
778
 
779
int           arsInitCparam      ( ARSParam *sparam );
780
void          arsGetImgFeature   ( int *num, int **area, int **clip, double **pos, int LorR );
781
ARInt16      *arsLabeling        ( ARUint8 *image, int thresh,
782
                                   int *label_num, int **area, double **pos, int **clip,
783
                                   int **label_ref, int LorR );
784
int           arsGetLine         ( int x_coord[], int y_coord[], int coord_num,
785
                                   int vertex[], double line[4][3], double v[4][2], int LorR);
786
ARMarkerInfo *arsGetMarkerInfo   ( ARUint8 *image,
787
                                   ARMarkerInfo2 *marker_info2, int *marker_num, int LorR );
788
int           arsDetectMarker    ( ARUint8 *dataPtr, int thresh,
789
                                   ARMarkerInfo **marker_info, int *marker_num, int LorR );
790
int           arsDetectMarkerLite( ARUint8 *dataPtr, int thresh,
791
                                   ARMarkerInfo **marker_info, int *marker_num, int LorR );
792
double        arsGetTransMat     ( ARMarkerInfo *marker_infoL, ARMarkerInfo *marker_infoR,
793
                                   double center[2], double width,
794
                                   double transL[3][4], double transR[3][4] );
795
double        arsGetTransMatCont ( ARMarkerInfo *marker_infoL, ARMarkerInfo *marker_infoR,
796
                                   double prev_conv[3][4],
797
                                   double center[2], double width,
798
                                   double transL[3][4], double transR[3][4] );
799
double        arsGetTransMat2    ( double rot[3][3],
800
                                   double ppos2dL[][2], double ppos3dL[][3], int numL,
801
                                   double ppos2dR[][2], double ppos3dR[][3], int numR,
802
                                   double transL[3][4], double transR[3][4] );
803
double        arsGetPosErr( double pos2dL[2], double pos2dR[2] );
804
int           arsCheckPosition   ( double pos2dL[2], double pos2dR[2], double thresh );
805
int           arsCheckMarkerPosition( ARMarkerInfo *marker_infoL, ARMarkerInfo *marker_infoR,
806
                                      double thresh );
807
 
808
double arsModifyMatrix( double rot[3][3], double trans[3], ARSParam *arsParam,
809
                        double pos3dL[][3], double pos2dL[][2], int numL,
810
                        double pos3dR[][3], double pos2dR[][2], int numR );
811
 
812
#ifdef __cplusplus
813
}
814
#endif
815
#endif