static int setupCamera(const char *cparam_name, char *vconf, ARParam *cparam)
{	
    ARParam			wparam;
	int				xsize, ysize;

    // Open the video path.
    if (arVideoOpen(vconf) < 0) {
    	fprintf(stderr, "setupCamera(): Unable to open connection to camera.\n");
    	return (FALSE);
	}
	
    // Find the size of the window.
    if (arVideoInqSize(&xsize, &ysize) < 0) return (FALSE);
    fprintf(stdout, "Camera image size (x,y) = (%d,%d)\n", xsize, ysize);
	
	// Load the camera parameters, resize for the window and init.
    if (arParamLoad(cparam_name, 1, &wparam) < 0) {
		fprintf(stderr, "setupCamera(): Error loading parameter file %s for camera.\n", cparam_name);
        return (FALSE);
    }
    arParamChangeSize(&wparam, xsize, ysize, cparam);
    fprintf(stdout, "*** Camera Parameter ***\n");
    arParamDisp(cparam);
	
    arInitCparam(cparam);

	if (arVideoCapStart() != 0) {
    	fprintf(stderr, "setupCamera(): Unable to begin camera data capture.\n");
		return (FALSE);		
	}
	
	return (TRUE);
}
Example #2
0
File: ar.cpp Project: imclab/3deye
static void init( void )
{
    ARParam  wparam;
	
    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
    
    /* set the initial camera parameters */
    if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
        printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );
    
    if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
        printf("pattern load error !!\n");
        exit(0);
    }
    
    /* open the graphics window */
    argInit( &cparam, 1.0, 0, 0, 0, 0 );
}
static void init( void )
{
    ARParam  wparam;

    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    /* set the initial camera parameters */
    if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
        printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );

    if( (config = arMultiReadConfigFile(config_name)) == NULL ) {
        printf("config data load error !!\n");
        exit(0);
    }

    /* open the graphics window */
    argInit( &cparam, 1.0, 0, 2, 1, 0 );
    arFittingMode   = AR_FITTING_TO_IDEAL;
    arImageProcMode = AR_IMAGE_PROC_IN_HALF;
    argDrawMode     = AR_DRAW_BY_TEXTURE_MAPPING;
    argTexmapMode   = AR_DRAW_TEXTURE_HALF_IMAGE;
}
	static void init() {
		ARParam  wparam;

		//Open video path, vconf is default camera config
		if (arVideoOpen(vconf) < 0) {
			exit(0);
		}

		//Get size of window
		if (arVideoInqSize(&xsize, &ysize) < 0) {
			exit(0);
		}

		//Set camera paramaters
		if (arParamLoad(cparam_name, 1, &wparam) < 0) {
			printf("Couldn't load camera parameters");
			exit(0);
		}
		arParamChangeSize(&wparam, xsize, ysize, &cparam);
		arInitCparam(&cparam);

		//Load pattern
		if ((patt_id = arLoadPatt(patt_name)) < 0) {
			printf("Failed to load pattern");
			exit(0);
		}

		//Open graphics window
		argInit(&cparam, 1, 0, 0, 0, 0);
	}
Example #5
0
static void init( void )
{
    ARParam  wparam;

    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    /* set the initial camera parameters */
    if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
        printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );

    /* load in the object data - trained markers and associated bitmap files */
    if( (object=read_ObjData(model_name, &objectnum)) == NULL ) exit(0);
    printf("Objectfile num = %d\n", objectnum);

    /* open the graphics window */
    argInit( &cparam, 2.0, 0, 0, 0, 0 );
}
Example #6
0
static void init( void )
{
    ARParam  wparam;
	int i;
	
    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    /* set the initial camera parameters */
    if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
        printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );

	for( i=0; i < PTT_NUM; i++){ 
		if( (object[i].patt_id = arLoadPatt(object[i].patt_name)) < 0 ) {
			printf("パターン読み込みに失敗しました!! %s\n", object[i].patt_name);
			exit(0);
		}
	}

    /* open the graphics window */
    argInit( &cparam, 1.0, 0, 0, 0, 0 );

}
Example #7
0
static void init( void )
{
    ARParam  wparam;
    char     name1[256], name2[256];

    printf("Enter camera parameter filename");
    printf("(Data/camera_para.dat): ");
    if( fgets(name1, 256, stdin) == NULL ) exit(0);
    if( sscanf(name1, "%s", name2) != 1 ) {
        strcpy( name2, "Data/camera_para.dat");
    }
    if( arParamLoad(name2, 1, &wparam) < 0 ) {
        printf("Parameter load error !!\n");
        exit(0);
    }

    if( arVideoOpen(vconf) < 0 ) exit(0);
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    arMalloc( image, ARUint8, xsize*ysize*AR_PIX_SIZE );
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    arParamChangeSize( &wparam, xsize, ysize, &param );
    arParamDisp( &param );
    arInitCparam( &param );

    argInit( &param, 1.0, 0, 0, 0, 0 );
    argDrawMode2D();
}
//=======================================================
// 初期化関数
//=======================================================
void Init(void)
{
	ARParam wparam;		// カメラパラメータ

	// ビデオデバイスの設定
	if( arVideoOpen( vconf_name ) < 0 ){
		printf("ビデオデバイスのエラー\n");
		exit(0);
	}

	// ウィンドウサイズの取得
	if( arVideoInqSize( &xsize, &ysize ) < 0 ) exit(0);
	printf("Image size (x,y) = (%d,$d)\n", xsize, ysize);

	// カメラパラメータの設定
	if( arParamLoad( cparam_name, 1, &wparam ) < 0 ){
		printf("カメラパラメータの読み込みに失敗しました\n");
		exit(0);
	}

	// カメラパラメータのサイズ調整
	arParamChangeSize( &wparam, xsize, ysize, &cparam );
	// カメラパラメータの初期化
	arInitCparam( &cparam );
	printf("*** Camera Parameter ***\n");
	arParamDisp( &cparam );

	// パターンファイルのロード
	for( int i=0; i<MARK_NUM; i++ ){
		if( (marker[i].patt_id = arLoadPatt(marker[i].patt_name)) < 0){
			printf("パターンファイルの読み込みに失敗しました\n");
			printf("%s\n", marker[i].patt_name);
			exit(0);
		}
	}

	// gsubライブラリの初期化
	argInit( &cparam, 1.0, 0, 0, 0, 0 );

	mqoInit(); //メタセコイアの初期化

	// モデルの読み込み

	for(int i=0;i<8;i++){
		if ( (model[i] = mqoCreateModel( mqo_name[i], 1.0 )) == NULL ) {
				printf("モデルの読み込みに失敗しました\n");
			//	return -1;
		}
	}
	if ( (rmodel = mqoCreateModel( mqo_rnm, 1.0 )) == NULL ) {
		printf("モデルの読み込みに失敗しました\n");
		//	return -1;
	}


	// ウィンドウタイトルの設定
	glutSetWindowTitle("PaperPiano");
}
Example #9
0
int main(int argc,char**argv){

    ARParam cparam;
    ARParam wparam;
    int xsize,ysize;
    glutInit(&argc,argv);

    if(arVideoOpen(vconf_name)<0){
	puts("ビデオデバイスエラー");
	return -1;
    }

    if(arVideoInqSize(&xsize,&ysize) < 0)return -1;

    if(arParamLoad(cparam_name,1,&wparam)< 0){
	puts("パラメータ読み込み失敗");
	return -1;
    }

    arParamChangeSize(&wparam,xsize,ysize,&cparam);
    arInitCparam(&cparam);
    nyobj = nyar_NyARTransMat_O2_create(&cparam);

    if( (patt_id=arLoadPatt(pattern_name)) < 0){
	puts("パターン読み込みエラー");
	return -1;
    }

    argInit(&cparam, 1.0, 0, 0, 0, 0); 
    mqoInit();

    if(Data_Load()==-1)
	return -1;

    arVideoCapStart();
    InitGame();

    arUtilTimerReset();
#ifdef _WIN32
    TIMECAPS Caps;
    timeGetDevCaps(&Caps, sizeof(TIMECAPS)); // 性能取得
    timeBeginPeriod(Caps.wPeriodMin);
#endif
    argMainLoop(MouseEvent,KeyEvent,MainLoop);
#ifdef _WIN32
    timeEndPeriod(Caps.wPeriodMin);
#endif
    nyar_NyARTransMat_O2_free(nyobj);
    return 0;


}
static void init( void )
{
  ARParam  wparam;
	
    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    /* set the initial camera parameters */
    if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
        printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );

	/* load the paddle marker file */
	if( (paddleInfo = paddleInit(paddle_name)) == NULL ) {
		printf("paddleInit error!!\n");
		exit(0);
	}
	printf("Loaded Paddle File\n");

	if( (config = arMultiReadConfigFile(config_name)) == NULL ) {
        printf("config data load error !!\n");
        exit(0);
    }
	printf("Loaded Multi Marker File\n");

	/* init items */
	myListItem.itemnum=4;
	myListItem.item[0].pos[0]=0.;myListItem.item[0].pos[1]=0.;myListItem.item[0].onpaddle=0;
	myListItem.item[1].pos[0]=100.;myListItem.item[1].pos[1]=-100.;myListItem.item[1].onpaddle=0;
	myListItem.item[2].pos[0]=200.;myListItem.item[2].pos[1]=0.;myListItem.item[2].onpaddle=0;
	myListItem.item[3].pos[0]=0.;myListItem.item[3].pos[1]=0.;myListItem.item[3].onpaddle=1;	

	/* set up the initial paddle contents */
	myPaddleItem.item = 3;
	myPaddleItem.angle = 0.0;
	myPaddleItem.x = 0.0;
	myPaddleItem.y = 0.0;

    /* open the graphics window */
	argInit( &cparam, 1.0, 0, 0, 0, 0 );
}
Example #11
0
int main(int argc, char **argv) 
{
	ARParam cparam;
	ARParam wparam;
	int xsize, ysize;

	printf("test\n");


	
	glutInit(&argc, argv);


	
	if (arVideoOpen(vconf_name) < 0) {
		printf("ビデオデバイスのエラー");
		return -1;

	}

	if (arVideoInqSize(&xsize, &ysize) < 0)	return -1;

	if (arParamLoad(cparam_name, 1, &wparam) < 0) {
		printf("カメラパラメータの読み込みに失敗しました\n");
		return -1;

	}

	arParamChangeSize(&wparam, xsize, ysize, &cparam);
	arInitCparam(&cparam);

	if ((patt_id = arLoadPatt(patt_name)) < 0) {
		printf("パターンファイルの読み込みに失敗しました\n");
		return -1;
			
	}

	argInit(&cparam, 1.0, 0, 0, 0, 0);

	arVideoCapStart();

	argMainLoop(MouseEvent, KeyEvent, MainLoop);
	
	return 0;

}
Example #12
0
//initialisation artoolkit
void arInit()
{
    printf("Debut initialisation AR\n");
	cout << vconf << endl;
    ARParam wparam;

    ///ouverture fenetre de dialogue  de parametrage
    if( arVideoOpen( vconf ) < 0 ) /*exit(0)*/ printf("Connexion a la webcam impossible\n");
    if( arVideoInqSize(&xsize, &ysize) < 0 ) /*exit(0)*/printf("Impossible de recuperer la taille de la video\n");
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    ///parametrage de la camera via la fentre de dialogue precedente
   if( arParamLoad(cparam_name, 1, &wparam) < 0 )
    {
        printf("Camera parameter load error !!\n");
        //exit(0);
    }
	//changement des param de base par ceux choisi lors de l'affichage de la fenetre de configuration
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam ); ///affichage parametres

    ///fin init camera

    ///debut init marker de detection
    for( int i = 0; i < 2; i++ )
    {
        if( (object[i].patt_id=arLoadPatt(object[i].patt_name)) < 0 )
        {
            printf("pattern load error: %s\n", object[i].patt_name);
            //exit(0);
        }
    }


	argInit( &cparam, 1.0, 0, 0, 0, 0 );
	
	glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    printf("Fin initialisation AR\n");
}
static void init( void )
{
	ARParam  wparam;
	int i;

    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    /* set the initial camera parameters */
    if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
        printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );

	/* load the paddle marker file */
	if( (paddleInfo = paddleInit(paddle_name)) == NULL ) {
		printf("paddleInit error!!\n");
		exit(0);
	}
	printf("Loaded Paddle File\n");

	if( (config = arMultiReadConfigFile(config_name)) == NULL ) {
        printf("config data load error !!\n");
        exit(0);
    }
	printf("Loaded Multi Marker File\n");

	/* initialize the targets */
	for (i=0;i<TARGET_NUM;i++){
		myTarget[i].pos[0] = 50.0*i;
		myTarget[i].pos[1] = -50.0*i;
		myTarget[i].pos[2] = 50.0*i;
		myTarget[i].state = NOT_TOUCHED;
	}

    /* open the graphics window */
    argInit( &cparam, 1.0, 0, 0, 0, 0 );
}
Example #14
0
static int setupCamera(ARParam *cparam)
{
    ARParam  wparam;
    char     name1[256], name2[256];
	int				xsize, ysize;

    printf("Enter camera parameter filename");
    printf("(Data/camera_para.dat): ");
    if (fgets(name1, 256, stdin) == NULL) exit(0);
    if (sscanf(name1, "%s", name2) != 1) {
        strcpy(name2, "Data/camera_para.dat");
    }

	// Load the camera parameters.
	if (arParamLoad(name2, 1, &wparam) < 0 ) {
        printf("Parameter load error !!\n");
        return (FALSE);
    }
	
    // Open the video path.
    if (arVideoOpen(vconf) < 0) {
    	fprintf(stderr, "setupCamera(): Unable to open connection to camera.\n");
    	return (FALSE);
	}
	
    // Find the size of the window.
    if (arVideoInqSize(&xsize, &ysize) < 0) return (FALSE);
    fprintf(stdout, "Camera image size (x,y) = (%d,%d)\n", xsize, ysize);
	
	// Resize for the window and init.
    arParamChangeSize(&wparam, xsize, ysize, cparam);
    fprintf(stdout, "*** Camera Parameter ***\n");
    arParamDisp(cparam);
	
    arInitCparam(cparam);
	
	if (arVideoCapStart() != 0) {
    	fprintf(stderr, "setupCamera(): Unable to begin camera data capture.\n");
		return (FALSE);		
	}
	
	return (TRUE);
}
Example #15
0
File: exview.c Project: SNce/ARMaze
/* set up the application parameters - read in from command line*/
static int init(void)
{
    char     cparaname[256];
    char     pattname[256];
    ARParam  wparam;

    strcpy( cparaname, "Data/camera_para.dat" );
    strcpy( pattname,  "Data/patt.hiro" );
    
    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    /* set the initial camera parameters */
    if( arParamLoad(cparaname, 1, &wparam) < 0 ) {
       printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );

    /* open the graphics window */
    argInit( &cparam, 2.0, 0, 2, 1, 0 );

    if( (target_id = arLoadPatt(pattname)) < 0 ) {
        printf("Target pattern load error!!\n");
        exit(0);
    }

    arDebug = 0;

    return 0;
}
Example #16
0
File: main.c Project: SNce/ARMaze
static void init( int argc, char *argv[] )
{
    double  length;
    char    line[512];
    int     i, j;

    patt.h_num    = H_NUM;
    patt.v_num    = V_NUM;
    patt.loop_num = 0;
    if( patt.h_num < 3 || patt.v_num < 3 ) exit(0);

    printf("Input the length between each markers: ");
    scanf("%lf", &length); while( getchar()!='\n' );
    patt.world_coord = (CALIB_COORD_T *)malloc( sizeof(CALIB_COORD_T)*patt.h_num*patt.v_num );
    for( j = 0; j < patt.v_num; j++ ) {
        for( i = 0; i < patt.h_num; i++ ) {
            patt.world_coord[j*patt.h_num+i].x_coord =  length * i;
            patt.world_coord[j*patt.h_num+i].y_coord =  length * j;
        }
    }

    strcpy( line, vconf );
    for( i = 1; i < argc; i++ ) {
        strcat( line, " " );
        strcat( line, argv[i] );
    }
    if( arVideoOpen( line ) < 0 ) exit(0);
    if( arVideoInqSize( &xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

#ifdef __APPLE__
    glutInit(&argc, argv);
#endif
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    glutInitWindowSize(xsize, ysize);
    glutInitWindowPosition(100,100);
    win = glutCreateWindow("Calib distotion param");

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, xsize, 0, ysize, -1.0, 1.0);
    glViewport(0, 0, xsize, ysize);

    clipImage = (unsigned char *)malloc( xsize*ysize*AR_PIX_SIZE );
    if( clipImage == NULL ) exit(0);

#ifdef USE_TEXMAP
    glGenTextures(2, glid);
    glBindTexture( GL_TEXTURE_2D, glid[0] );
    glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
    glBindTexture( GL_TEXTURE_2D, glid[1] );
    glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
    if( xsize > 512 ) {
        tex1Xsize1 = 512;
        tex1Xsize2 = 1;
        while( tex1Xsize2 < xsize - tex1Xsize1 ) tex1Xsize2 *= 2;
    }
    else {
        tex1Xsize1 = 1;
        while( tex1Xsize1 < xsize ) tex1Xsize1 *= 2;
    }
    tex1Ysize  = 1;
    while( tex1Ysize < ysize ) tex1Ysize *= 2;
#endif
}
Example #17
0
//========
// 初期化
//========
bool cARTK::initialize( void )
{
	const char	*szCameraParamFName = "Data/camera_para.dat";
#ifdef _WIN32
	char		*szVConfFName = "Data/WDM_camera_flipV.xml";
#else
	char		*vconf = "";
#endif

	ARParam			sCamParamTemp;
	int				iCamImgSizeX,
					iCamImgSizeY;

	// カメラデバイスのオープン
	if( arVideoOpen( szVConfFName ) < 0 )
	{
		ErrorMessage( "Unable to open connection to camera.\n" );
		return false;
	}

	// カメラ画像のサイズを取得
	if( arVideoInqSize( &iCamImgSizeX, &iCamImgSizeY ) < 0 ) return false;

	// カメラパラメータファイルの読込み
	if( arParamLoad( szCameraParamFName, 1, &sCamParamTemp ) < 0 )
	{
		ErrorMessage( "Error loading parameter file for camera.\n" );
		return false;
	}

	// カメラパラメータのサイズ部分を変更
	arParamChangeSize( &sCamParamTemp, iCamImgSizeX, iCamImgSizeY, &m_sCameraParam );

	// ライブラリ内のカメラパラメータの初期化
	arInitCparam( &m_sCameraParam );

	// NyARTransMatの初期化
	m_pNyARInst = nyar_NyARTransMat_O2_create( &m_sCameraParam );

	// カメラ画像のキャプチャを開始
	if( arVideoCapStart() != 0 )
	{
		ErrorMessage( "Unable to begin camera data capture.\n" );
		return false;
	}

	// マーカーパターンファイルの読込み
	for( int i = 0 ; i < ARMK_MAXNUM ; i++ )
	{
		if( (m_sMarkerInfo[i].iPattID = arLoadPatt( g_szPattFName[i] )) < 0 )
		{
			ErrorMessage( "Pattern file load error !!\n" );
			return false;
		}

		m_sMarkerInfo[i].dWidth = g_dPattWidth[i];
		m_sMarkerInfo[i].dCenterPos[0] = m_sMarkerInfo[i].dCenterPos[1] = 0.0f;
		m_sMarkerInfo[i].bVisible = false;
	}

	// ちょっとずらす
	m_sMarkerInfo[1].dCenterPos[0] =  0.0f;
	m_sMarkerInfo[1].dCenterPos[1] = 30.0f;

	m_iThreshold = 120;
	m_dViewScaleFactor = 0.16;

	return true;
}
Example #18
0
//========
// 初期化
//========
bool cARTK::initialize( void )
{
	const char	*szCameraParamFName = "../Data/camera_para.dat";
	const char	*szPattFName  = "../Data/patt.00";
#ifdef _WIN32
	char		*szVConfFName = "../Data/WDM_camera_flipV.xml";
#else
	char		*szVConfFName = "";
#endif

	ARParam			sCamParamTemp;
	int				iCamImgSizeX,
					iCamImgSizeY;

	// カメラデバイスのオープン
	if( arVideoOpen( szVConfFName ) < 0 )
	{
		ErrorMessage( "Unable to open connection to camera.\n" );
		return false;
	}

	// カメラ画像のサイズを取得
	if( arVideoInqSize( &iCamImgSizeX, &iCamImgSizeY ) < 0 ) return false;

	// カメラパラメータファイルの読込み
	if( arParamLoad( szCameraParamFName, 1, &sCamParamTemp ) < 0 )
	{
		ErrorMessage( "Error loading parameter file for camera.\n" );
		return false;
	}

	// カメラパラメータのサイズ部分を変更
	arParamChangeSize( &sCamParamTemp, iCamImgSizeX, iCamImgSizeY, &m_sCameraParam );

	// ライブラリ内のカメラパラメータの初期化
	arInitCparam( &m_sCameraParam );

	// カメラ画像のキャプチャを開始
	if( arVideoCapStart() != 0 )
	{
		ErrorMessage( "Unable to begin camera data capture.\n" );
		return false;
	}

	// マーカーパターンファイルの読込み
    if( (m_iPattID = arLoadPatt( szPattFName )) < 0 )
    {
		ErrorMessage( "Pattern file load error !!\n" );
		return false;
    }

	m_uiARTImageSize = sizeof(ARUint8) * iCamImgSizeX * iCamImgSizeY * 3;
	m_pARTImage = (ARUint8 *)malloc( m_uiARTImageSize );
	memset( m_pARTImage, 0, m_uiARTImageSize );

	m_dViewScaleFactor = 0.16;
	m_dPattWidth = 40.0;
	m_bFirstTime = true;

	return true;
}