Extending ARToolKit’s video buffer size

C & C++ Dec 10, 2012

Are you wondering why the ARToolKit or its ROS implementation (ccny_visionon)  cannot deal with all resolutions, provided by your camera? The simple  reason for this is that the values for the video buffers are fixed and  have to be changed by hand …

Simply edit file “/lib/SRC/AR/arLabeling.c” and change the values in  lines 38 (HARDCODED_BUFFER_WIDTH) and 39 (HARDCODED_BUFFER_HEIGHT):

/*******************************************************
 *
 * Author: Hirokazu Kato
 *
 *         kato@sys.im.hiroshima-cu.ac.jp
 *
 * Revision: 3.1
 * Date: 01/12/07
 *
 *
 * modified by Thomas Pintaric [tp], Vienna University of Technology
 **********************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <AR/ar.h>

#ifdef _WIN32
#  include <windows.h>
#  define put_zero(p,s) ZeroMemory(p, s)
#else
#  include <string.h>
#  define put_zero(p,s) memset((void *)p, 0, s)
#endif

#define USE_OPTIMIZATIONS
#define WORK_SIZE   1024*32

/*****************************************************************************/
// BUG in ARToolkit 2.65
// Hardcoded buffer (600*500) is too small for full-size DV-PAL/NTSC resolutions
// 720x576 and 720x480, respectively. Results in segment faults.
/*
static ARInt16      l_imageL[640*500];
static ARInt16      l_imageR[640*500];
*/

#define HARDCODED_BUFFER_WIDTH  1024
#define HARDCODED_BUFFER_HEIGHT 1024

static ARInt16      l_imageL[HARDCODED_BUFFER_WIDTH*HARDCODED_BUFFER_HEIGHT];
static ARInt16      l_imageR[HARDCODED_BUFFER_WIDTH*HARDCODED_BUFFER_HEIGHT];
/*****************************************************************************/