create new tag
, view all tags
-- AlexandreProust - 2011-08-25

Introduction on ARToolKitPlus

ARToolKit is a software library that can be used to calculate camera position and orientation relative to physical markers in real time. This enables the easy development of a wide range of Augmented Reality applications. ARToolKitPlus is an extended version of ARToolKit’s vision code that adds features. Main features over ARToolKit:

  • Up to 4096 id-based markers (no speed penalty due to large number of markers)
  • New camera pixel-formats (RGB565, Gray)
  • Variable marker border width
  • Many speed-ups for low-end devices (fixed-point arithmetic, look-up tables, etc.)
  • Loads MATLAB camera calibration toolbox files
  • Automatic thresholding
This library is an excellent solution for the tracking of an other e-bug taking a marker. To use this library add the follow header in your program:
#include <ARToolKitPlus/TrackerSingleMarker.h>

Camera calibration

Before using the ARToolKit library your need a Matlab calibration file of your camera. From multiples images of a planar checkerboard, the deformation of your camera can be calculated by the Matlab toolbox: TOOLBOX_calib. This file (Microsoft_Kinect.cal) must be placed in the same directory of or compilated program. In our case in: libfreenect/build/bin

Create a marker tracker

The first thing to detect a marker in a frame is to create a "marker tracker". For that you can use the function init_tracker(TrackerSingleMarker) of my program traker.h. TrackerSingleMarker ∗ tracker ; t r a c k e r = new T r a c k e r S i n g l e M a r k e r ( 4 8 0 , 6 4 0 , 8 , 6 , 6 , 6 , 0 ) ; init_tracker ( tracker ); The parameters of TrackerSingleMarker() are in sequence: • image width • image height • maximum number of patterns that can be analyzed in a camera image • pattern image width • pattern image height • maximum resolution at which a pattern is sampled from the camera image • maximum number of pattern files that can be loaded (if you want to add pattern at the data base)

Configure a marker tracker

With the function init_tracker() your marker tracker is set to detect BCH marker in the RGB frame of the Kinect. You can change all the configuration in the file tracker.h. Let’s see closer this function: First the tracker is initialised with the Matlab calibration file // Load camera c a l i b r a t i o n f i l e i f ( ! t r a c k e r −>i n i t ( " M i c r o s o f t _ K i ne c t . cal " , 1 . 0 f , 1 0 0 0 . 0 f ) ) Then the tracker is configurated with some parameters: // / / / / / / / / / / / / / / / / / / / // UPDATE SETTINGS // // / / / / / / / / / / / / / / / / / / / // S e t marker b o r d e r width t r a c k e r −>setBorderWidth ( 0 . 1 2 5 ) ; // S e t t h r e s h o l d i n g t r a c k e r −>s e t T h r e s h o l d ( 1 5 0 ) ; t r a c k e r −>a c t i v a t e A u t o T h r e s h o l d ( 0 ) ; t r a c k e r −>s e t N u m A u t o T h r e s h o l d R e t r i e s ( 3 ) ; // V i g n e t t i n g c o m p e n s a t i o n t r a c k e r −>a c t i v a t e V i g n e t t i n g C o m p e n s a t i o n ( 0 ) ; // S e t p i x e l f o r m a t t r a c k e r −>s e t P i x e l F o r m a t ( ARToolKitPlus : : PIXEL_FORMAT_BGR) ; // S e t u n d i s t o r t i o n mode t r a c k e r −>s e t U n d i s t o r t i o n M o d e ( ARToolKitPlus : : UNDIST_LUT ) ; // S e t p o s e e s t i m a t o r t r a c k e r −>s e t P o s e E s t i m a t o r ( ARToolKitPlus : : POSE_ESTIMATOR_ORIGINAL ) ; // S e t image p r o c e s s i n g mode t r a c k e r −>s e t I m a g e P r o c e s s i n g M o d e ( ARToolKitPlus : : IMAGE_FULL_RES ) ; // S e t marker mode t r a c k e r −>setMarkerMode ( ARToolKitPlus : : MARKER_ID_BCH) ;

The threshold setting depend on the light environment. If the AutoThreshold setting is acti- vated, the library will try different Threshold value to detect one marker. The number of retries is set by NumAutoThresholdRetries(). setPixelFormat() depend on your camera frame, you can choose between PIXEL_FORMAT_ABGR, PIXEL_FORMAT_BGRA, PIXEL_FORMAT_BGR, PIXEL_FORMAT_RGBA, PIXEL_FORMAT_RGB, PIXEL_FORMAT_RGB565 and PIXEL_FORMAT_LUM. For the Precessing mode you can choose between IMAGE_HALF_RES, IMAGE_FULL_RES. A half resolution reduces the CPU load but is less accurate for a distant marker. The setMarkerMode parameter depend on the marker used,MARKER_TEMPLATE, MARKER_ID_SIMPLE, MARKER_ID_BCH,

Find markers

First a ARMarkerInfo have to be declared in the code. This variable will contain all the infor- mation on the detected markers. // / marker c o n f i g ARToolKitPlus : : ARMarkerInfo ∗ m a rk e r _ in f o ; m a rk e r _ in f o = new ARToolKitPlus : : ARMarkerInfo ; Then to run the procedure of markers detection called the function findmarker() written in tracker.h too. This function return all information about all markers detected and the number of marker detected in marker_num. // / f i n d marker m a rk e r _ in f o = f i n d m a r k e r ( t r a c k e r , image , marker_info , &marker_num ) ;

Check markers

To check if one marker detected on a frame is a real marker the solution is to verify the marker ID. If this Id is higher than 0 it’s a good marker. i n t num_real_marker 0; f o r ( i n t i =0; i <marker_num ; i ++) { // Check i f BCH marker ID i s v a l i d i f ( m ar k e r _i n f o [ i ] . id >=0) { num_real_marker++; x_marker_real m a r ke r _ i nf o [ i ] . pos [ 0 ] ; y_marker_real= m a r ke r _ i nf o [ i ] . pos [ 1 ] ; id_marker_number = m a r k er _ i n fo [ i ] . i d ; // f i n d t h e depth o f t h e marker // draw c i r c l e and i d number on t h e frame } }

Maker depth

As you can see in comment in the previous code, with the information on one marker, the depth of this marker can be found with the function depth_info() like that: // f i n d t h e depth o f t h e marker marker_depth = d e p t h _ i n f o ( depth , x_marker_real , y_marker_real ) ; This function works exactly like the function GlViewCode seen previously but only one on point of the frame. i n t d e p t h _ i n f o ( I p l I m a g e ∗ depth , i n t x , i n t y ) { int i ; i (640∗ x)−y ; i n t b a l l _ d e p t h = ( ( s h o r t ∗ ) depth−>imageData ) [ i ] ; ball_depth = 0.1375∗ ball_depth ; i f ( b a l l _ d e p t h = 2 8 1 ) r e t u r n 0 ; e l s e return ball_depth ; }

Draw a marker on a frame

To draw a add an identification point on the marker in the display of your frame called the function draw_marker() of tracker.h. // draw c i r c l e and i d number on t h e frame draw_marker ( x_marker_real , y_marker_real , marker_depth , id_marker_number , image ) ; As you can see in the follow figures the marker ID is drawn in red and the depth in centimetre is displayed in green.

Topic attachments
I Attachment Action Size Date Who Comment
PNGpng marker_bch_id1.png manage 0.1 K 2011-08-25 - 06:03 AlexandreProust  
Topic revision: r2 - 2011-08-25 - AlexandreProust
This site is powered by the TWiki collaboration platformCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback