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;
}
Example #2
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 #3
0
  void ARBundlePublisher::arInit ()
  {



    ROS_INFO("Starting arInit");
    arInitCparam (&cam_param_);
    ROS_INFO ("*** Camera Parameter ***");
    arParamDisp (&cam_param_);

    // load in the object data - trained markers and associated bitmap files
    if ((object = ar_object::read_ObjData (pattern_filename_, &objectnum)) == NULL)
      ROS_BREAK ();
    ROS_INFO("Objectfile num = %d", objectnum);

	// load in the transform data - transform of marker frame wrt center frame
    if ((tfs= ar_transforms::read_Transforms (transforms_filename_, objectnum)) == NULL)
      ROS_BREAK ();
    ROS_INFO("Read in transforms successfully");
    
	

    sz_ = cvSize (cam_param_.xsize, cam_param_.ysize);
#if ROS_VERSION_MINIMUM(1, 9, 0)
// FIXME: Why is this not in the object
    cv_bridge::CvImagePtr capture_; 
#else
// DEPRECATED: Fuerte support ends when Hydro is released
    capture_ = cvCreateImage (sz_, IPL_DEPTH_8U, 4);
#endif

	
  }
	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);
	}
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 #6
0
/* set up the application parameters - read in from command line*/
static int init( int argc, char *argv[] )
{
    ARParam  wparam;

    /* open the video path */
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

    /* set the initial camera parameters */
    if( arParamLoad(CPARA, 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, 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_FULL_IMAGE;
    gen_image( imgMode );

    dispMode();

    return 0;
}
Example #7
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 #8
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();
}
Example #9
0
static void init( void )
{
    ARParam  wparam;
	
    /* open the video path */
    if( knVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( knVideoInqSize(&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 );
}
Example #10
0
static void init( void )
{
	/* Josh */
	ARParam wparam;
	xsize = 1024; //my size of picture
	ysize = 1024;

	//dp = opendir ("./");
	dp = opendir (directory);

	// devil
	ilInit();
	iluInit();

	if (dp == NULL)
	 {
		printf("Image directory could not be opened !!\n");
        exit(0);
	 }

	// get first image for size, then reload directory
	GetNextImage();
	dp = opendir (directory);

	// if over size limit (or possibly not detected) 
	if ((xsize >= 1024) || (ysize >= 1024) || (xsize == FALSE) || (ysize == FALSE))
	 {
		printf("Image size invalid - too big or broken !!\n");
        exit(0);
	 }

/* Josh */





	arParamChangeSize( &wparam, xsize, ysize, &cparam );
	//arVideoInqSize(&xsize, &ysize);
	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 );
}
Example #11
0
//=======================================================
// 初期化関数
//=======================================================
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 #12
0
/*
 * Class:     net_towerdefender_image_ARToolkit
 * Method:    artoolkit_init
 * Signature: (Ljava/lang/String;IIII)V
 */
JNIEXPORT void JNICALL Java_net_towerdefender_image_ARToolkit_artoolkit_1init__Ljava_lang_String_2IIII(
		JNIEnv *env, jobject object, jstring calibFile, jint imageWidth,
		jint imageHeight, jint screenWidth, jint screenHeight) {
	ARParam wparam;
	const char *cparam_name = (*env)->GetStringUTFChars(env, calibFile, NULL);

	xsize = imageHeight;
	ysize = imageHeight;
	printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

	/* set the initial camera parameters */
	if (arParamLoad(cparam_name, 1, &wparam) < 0) {
		__android_log_write(ANDROID_LOG_ERROR, "AR native",
				"Camera parameter load error !!");
		jclass exc = (*env)->FindClass(env,
				"net/towerdefender/exceptions/ARRuntimeException");
		if (exc != NULL)
			(*env)->ThrowNew(env, exc, "Camera parameter load error !!");
		//exit(EXIT_FAILURE);
	}
#ifdef DEBUG_LOGGING
	else {
		__android_log_write(ANDROID_LOG_INFO,"AR native","Camera parameter loaded successfully !!");
	}
#endif
	arParamChangeSize(&wparam, imageWidth, imageHeight, &cparam);
	arInitCparam(&cparam);
	printf("*** Camera Parameter ***\n");
	arParamDisp(&cparam);

	//initialize openGL stuff
	argInit(&cparam, 1.0, 0, screenWidth, screenHeight, 0);

	//gl_cpara
	jclass arObjectClass = (*env)->FindClass(env,
			"net/towerdefender/image/ARObject");
	if (arObjectClass != NULL) {
		jfieldID glCameraMatrixFieldID = (*env)->GetStaticFieldID(env,
				arObjectClass, "glCameraMatrix", "[F");
		if (glCameraMatrixFieldID != NULL) {
			jobject glCameraMatrixObj = (*env)->GetStaticObjectField(env,
					arObjectClass, glCameraMatrixFieldID);
			if (glCameraMatrixObj != NULL) {
				float *glCamMatrix = (*env)->GetFloatArrayElements(env,
						glCameraMatrixObj, JNI_FALSE);
				int i = 0;
				for (i = 0; i < 16; i++)
					glCamMatrix[i] = gl_cpara[i];
				(*env)->ReleaseFloatArrayElements(env, glCameraMatrixObj,
						glCamMatrix, 0);
			}
		}
	}

	(*env)->ReleaseStringUTFChars(env, calibFile, cparam_name);
}
Example #13
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 #15
0
  /* 
   * Setup artoolkit
   */
  void ARPublisher::arInit ()
  {
    arInitCparam (&cam_param_);
    ROS_INFO ("*** Camera Parameter ***");
    arParamDisp (&cam_param_);

    // load in the object data - trained markers and associated bitmap files
    if ((object = ar_object::read_ObjData (pattern_filename_, data_directory_, &objectnum)) == NULL)
      ROS_BREAK ();
    ROS_DEBUG ("Objectfile num = %d", objectnum);

    sz_ = cvSize (cam_param_.xsize, cam_param_.ysize);
    capture_ = cvCreateImage (sz_, IPL_DEPTH_8U, 4);
    configured_ = true;
  }
Example #16
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 #17
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 );
}
static void init( void )
{
	ARParam  wparam;

    /* 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 );

    /* open the graphics window */
    argInit( &cparam, 1.0, 0, 0, 0, 0 );
}
Example #20
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 #21
0
  void ARSinglePublisher::arInit ()
  {   
    arInitCparam (&cam_param_);

    ROS_INFO ("*** Camera Parameter ***");
    arParamDisp (&cam_param_);

    // load pattern file
    ROS_INFO ("Loading pattern");
    patt_id_ = arLoadPatt (pattern_filename_);
    if (patt_id_ < 0)
    {
      ROS_ERROR ("Pattern file load error: %s", pattern_filename_);
      ROS_BREAK ();
    }

    sz_ = cvSize (cam_param_.xsize, cam_param_.ysize);
    capture_ = cvCreateImage (sz_, IPL_DEPTH_8U, 4);
  }
Example #22
0
void ARMultiPublisher::arInit()
{
  arInitCparam(&cam_param_);
  ROS_INFO("Camera parameters for ARMultiPublisher are:");
  arParamDisp(&cam_param_);

  if ((multi_marker_config_ = arMultiReadConfigFile(pattern_filename_)) == NULL)
  {
    ROS_ASSERT_MSG(false, "Could not load configurations for ARMultiPublisher.");
  }
  // load in the object data - trained markers and associated bitmap files
  // if ((object = ar_object::read_ObjData(pattern_filename_, &objectnum)) == NULL)
  // ROS_BREAK ();

  num_total_markers_ = multi_marker_config_->marker_num;
  ROS_INFO("Read >%i< objects from file.", num_total_markers_);

  size_ = cvSize(cam_param_.xsize, cam_param_.ysize);
  capture_ = cvCreateImage(size_, IPL_DEPTH_8U, 4);
}
Example #23
0
int CWebCam::SetupWebCam(const char *cparam_names, char *vconfs)
{
	int			xsize, ysize;
	ARParam		wparam;

	if((ARTVideo = ar2VideoOpen(vconfs)) == 0) return(0);
	if(ar2VideoInqSize(ARTVideo, &xsize, &ysize) < 0) return(0);
	if(arParamLoad(cparam_names, 1, &wparam) < 0) return(0);

	arParamChangeSize(&wparam, xsize, ysize, &ARTCparam);
	arInitCparam(&ARTCparam);
	arParamDisp(&ARTCparam);
	ARTThreshhold = 100;

	arglCameraFrustumRH(&ARTCparam, VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, projectionMat);

	if(ar2VideoCapStart(ARTVideo) != 0) return(0);

	ar2VideoCapNext(ARTVideo);

	return(1);
}
Example #24
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 #25
0
int main(int argc, char **argv)
{
    ARUint8 *dataPtr;

    //
    // Camera configuration.
    //
#ifdef _WIN32
    char			*vconf = "Data\\WDM_camera_flipV.xml";
#else
    char			*vconf = "";
#endif

    int             count = 0;

   // char           *cparam_name    = "../calib_camera2/newparam.dat";

    char path[100];
    char cparam_name[100];
    char* cur_filename;
   
    if (argc < 2) {
        fprintf(stderr,"provide a jpeg file name\n");
        return;
    }
    

    int one = 1;
    //glutInit(&one,argv);


    cur_filename = argv[1];
    frame_ind = atoi(argv[3]);

    if (argc > 2) {
        sprintf(path,"%s/", argv[2]);
    } else {
        sprintf(path, "");
    }

    fprintf(stderr,"%d %s,\n", argc, cur_filename);

    /// make this get an image with curl
	dataPtr	    = loadImage(cur_filename,&xsize,&ysize);

	ARParam  wparam;

    sprintf(cparam_name,"%s%s",path,"camera_para.dat");
    fprintf(stderr,"%s\n", cparam_name);

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

    int patt_id;
    char buffer[100];
    
    sprintf(buffer,"%spatt.hiro",path);
    if( (patt_id=arLoadPatt(buffer)) < 0 ) {
        fprintf(stderr,"pattern load error !!\n");
        exit(0);
    }
   fprintf(stderr,"patt.hiro %d\n", patt_id);

    sprintf(buffer,"%spatt.sample1",path);
    if( (patt_id=arLoadPatt(buffer)) < 0 ) {
        fprintf(stderr,"pattern load error !!\n");
        exit(0);
    }
   fprintf(stderr,"patt.sample1 %d\n", patt_id);

    sprintf(buffer,"%spatt.sample2",path);
    if( (patt_id=arLoadPatt(buffer)) < 0 ) {
        fprintf(stderr,"pattern load error !!\n");
        exit(0);
    }
   fprintf(stderr,"patt.sample2 %d\n", patt_id);


    sprintf(buffer,"%spatt.kanji",path);
    if( (patt_id=arLoadPatt(buffer)) < 0 ) {
        fprintf(stderr,"pattern load error !!\n");
        exit(0);
    }
   fprintf(stderr,"patt.kanji %d\n", patt_id);


#if 0
	fprintf(stderr,"xysize %d %d\n\
cparam %g\t%g\t%g\t%g\n \
mat\n \
%g\t%g\t%g\t%g\n \
%g\t%g\t%g\t%g\n \
%g\t%g\t%g\t%g\n", 
		cparam.xsize, cparam.ysize,
		cparam.dist_factor[0], cparam.dist_factor[1], cparam.dist_factor[2], cparam.dist_factor[3], 
		cparam.mat[0][0], cparam.mat[0][1], cparam.mat[0][2], cparam.mat[0][3], 	
		cparam.mat[1][0], cparam.mat[1][1], cparam.mat[1][2], cparam.mat[1][3], 	
		cparam.mat[2][0], cparam.mat[2][1], cparam.mat[2][2], cparam.mat[2][3]	
		);
#endif

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

    //printf("%s,\t\n",cur_filename);
	findMarkers(dataPtr);

    argCleanup();
}
Example #26
0
int main(int argc, char **argv)
{
	int one = 1;
	glutInit(&one,argv);
	init();
	
	cur_filename = argv[1];

	fprintf(stderr,"%d %s,\n", argc, cur_filename);
	fprintf(stdout,"%s,\t",cur_filename);

	if (argc > 2) {
		fprintf(stderr,"showing graphics\n");
		singleLoop = 0;	
	}

	////

	dataPtr	    = loadImage(cur_filename);


	///
	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);
    //fprintf(stderr,"Image size (x,y) = (%d,%d)\n", xsize, image->rows);

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

    if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
        fprintf(stderr,"pattern load error !!\n");
        exit(0);
    }

#if 0

	fprintf(stderr,"xysize %d %d\n\
cparam %g\t%g\t%g\t%g\n \
mat\n \
%g\t%g\t%g\t%g\n \
%g\t%g\t%g\t%g\n \
%g\t%g\t%g\t%g\n", 
		cparam.xsize, cparam.ysize,
		cparam.dist_factor[0], cparam.dist_factor[1], cparam.dist_factor[2], cparam.dist_factor[3], 
		cparam.mat[0][0], cparam.mat[0][1], cparam.mat[0][2], cparam.mat[0][3], 	
		cparam.mat[1][0], cparam.mat[1][1], cparam.mat[1][2], cparam.mat[1][3], 	
		cparam.mat[2][0], cparam.mat[2][1], cparam.mat[2][2], cparam.mat[2][3]	
		);
#endif


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



    //arVideoCapStart();

	findMarkers();



	if (singleLoop) {
		//mainLoop();
	} else {
    	argMainLoop( NULL, NULL /*keyEvent*/, mainLoop );
	}
}
Example #27
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;
}
Example #28
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 #29
0
/*
* Class:     com_clab_artoolkit_port_JARToolkit
* Method:    JARInitCparam
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_net_sourceforge_jartoolkit_core_JARToolKit_initCparam(JNIEnv *, jobject)
{
	if(cparam==NULL)
		return -1;
	return arInitCparam( cparam );
}
Example #30
0
	bool BazARTracker::init(int xsize, int ysize, 
			const std::string& bazar_config_name,
			const std::string& camera_name)
	{
		
		/*OSGART*/
		ARParam  wparam;
	    // Set the initial camera parameters.
		cparamName = camera_name;
	    if(arParamLoad((char*)cparamName.c_str(), 1, &wparam) < 0) {
			std::cerr << "ERROR: Camera parameter load error." << std::endl;
			return false;
	    }
	    arParamChangeSize(&wparam, xsize, ysize,&(m_cparam->cparam));

		arInitCparam(&(m_cparam->cparam));
	    arParamDisp(&(m_cparam->cparam));
		

	/*BAZAR*/
		// load BazAR's configuration files and detector parameters
		if (!loadBazARConfig(bazar_config_name, &bazconf)) exit(0);
		// load BazAR's camera calibration file
		if (!loadBazARCamParams((char*)(bazconf.camCalFileName),&bazconf)) exit(0);

		// init bazar tracker
		matCameraRT4_4 = cvCreateMat(4, 4, CV_64F); //64 bit double precision float
		g_matIntrinsic   = cvCreateMat(3, 3, CV_64F);
		
		// output windows
		if (getDebugMode()){
			cvNamedWindow("Gray", CV_WINDOW_AUTOSIZE);
			cvNamedWindow("Result_BAZAR", CV_WINDOW_AUTOSIZE);
		}
		// fine tuning for accuracy - careful!!
		detector.ransac_dist_threshold = (float)bazconf.ransac_dist_threshold;
		detector.max_ransac_iterations = (float)bazconf.max_ransac_iterations;
		detector.non_linear_refine_threshold = (float)bazconf.non_linear_refine_threshold;
		detector.match_score_threshold = (float)bazconf.match_score_threshold;	// A lower threshold will allow detection in harder conditions, but
																				// might lead to false positives
		// Train or load classifier
		if(!detector.build_with_cache(
			// hse25: no hard coded stuff :) -- jaja
			(char*)(bazconf.modelFileName),	// mode image file name
			400,               // maximum number of keypoints on the model
			32,                // patch size in pixels
			3,                 // yape radius. Use 3,5 or 7.
			16,                // number of trees for the classifier. Somewhere between 12-50
			3                  // number of levels in the gaussian pyramid
			))
		{
		cerr << "BazARTracker: Unable to load the model image " << (char*)(bazconf.modelFileName) <<" or its classifier.\n";
		return false;
		}
		 
		// set camera parameters for BAZAR
		char	*camCal = (char*)(bazconf.camCalFileName);
		char	*camExt = (char*)(bazconf.camExtFileName);
		if(!augment.LoadOptimalStructureFromFile(camCal, camExt))
		{
			std::cerr << "BazARTracker: couldn't load camera parameters: " << camCal << " " << camExt << std::endl;
			return false;
		}
		
		// image buffers needed for detection, conversion..
		image     = cvCreateImage(cvSize(xsize, ysize), IPL_DEPTH_8U, 4); // captured image
		gray      = cvCreateImage(cvSize(xsize, ysize), IPL_DEPTH_8U, 1); // detector input
		display   = cvCreateImage(cvSize(xsize, ysize), IPL_DEPTH_8U, 4); // debug
		
		// use bazar's camera calibration 
		m_cparam->cparam.mat[0][0] = bazconf.camCalMatrix[0][0];	m_cparam->cparam.mat[0][1] = bazconf.camCalMatrix[0][1];    m_cparam->cparam.mat[0][2] = bazconf.camCalMatrix[0][2];
		m_cparam->cparam.mat[1][0] = bazconf.camCalMatrix[1][0];	m_cparam->cparam.mat[1][1] = bazconf.camCalMatrix[1][1];    m_cparam->cparam.mat[1][2] = bazconf.camCalMatrix[1][2];
		m_cparam->cparam.mat[2][0] = bazconf.camCalMatrix[2][0];	m_cparam->cparam.mat[2][1] = bazconf.camCalMatrix[2][1];    m_cparam->cparam.mat[2][2] = bazconf.camCalMatrix[2][2];
		
		for(int i=0; i<3; i++)
		{
			for(int j=0; j<3; j++)
			{
				cvmSet(g_matIntrinsic, i, j, m_cparam->cparam.mat[i][j]);
			}
		}
	// end BAZAR
	  
		setProjection(10.0f, 8000.0f);
		setDebugMode(m_debugmode);
		
		setupMarkers();

		// Success
		return true;
	}