Example #1
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 #2
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 );
}
	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 #4
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 #5
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 #6
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 );
}
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( 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 );
}
//=======================================================
// 初期化関数
//=======================================================
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 #10
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 #11
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 #13
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");
}
Example #14
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;

}
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 #17
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 #18
0
//
// Function: cmdKeyboardLoad
//
// Load keyboard commands interactively in a linked list structure
//
int cmdKeyboardLoad(cmdLine_t **cmdLineRoot, cmdRepeat_t **cmdRepeatRoot,
  cmdInput_t *cmdInput)
{
  cmdLine_t *cmdLineLast = NULL;	// The last cmdline in linked list
  cmdRepeat_t *cmdRepeatLast = NULL;	// The last cmdrepeat in linked list
  int repeatCount = 0;			// rw vs rn command count
  char prompt[] = ">> ";
  int init = GLCD_TRUE;
  int lineNum = 1;
  char *input = NULL;
  int retVal = CMD_RET_OK;

  // Init return pointers
  *cmdLineRoot = NULL;
  *cmdRepeatRoot = NULL;

  // Do not read from the keyboard yet as we already have the first
  // command in the input buffer. Once we've processed that one we'll
  // continue reading the input stream using the control structure we've
  // been handed over.

  // Add each line entered via keyboard in a command linked list.
  // The list is complete when all 'rw' commands are matched with a 'rn'
  // command, or when the user entered ^D.
  while ((repeatCount != 0 && retVal == CMD_RET_OK) || init == GLCD_TRUE)
  {
    // Create new command line and add it to the linked list
    // by administering lots of pointers
    cmdLineLast = cmdLineCreate(cmdLineLast, cmdLineRoot);

    // Fill in functional payload of the list element
    cmdLineLast->lineNum = lineNum;
    cmdLineLast->input = malloc(strlen(cmdInput->input) + 1);
    strcpy(cmdLineLast->input, (const char *)cmdInput->input);

    // We need to know if this is a repeat while or repeat next command
    input = cmdLineLast->input;
    argInit(&input);
    retVal = argScan(argRepeatCmd, sizeof(argRepeatCmd) / sizeof(argItem_t),
      &input, GLCD_TRUE);

    // Process the scan result
    if (retVal != CMD_RET_OK)
    {
      // Most likely an empty line
      cmdLineLast->cmdRepeatType = CMD_REPEAT_NONE;
      retVal = CMD_RET_OK;
    }
    else if (strcmp(argWord[0], "rn") == 0)
    {
      // This is a repeat next command
      repeatCount--;
      cmdLineLast->cmdRepeatType = CMD_REPEAT_NEXT;

      // We must find a repeat while command to associate with
      retVal = cmdRepeatLinkWhile(cmdRepeatLast, cmdLineLast);
      if (retVal != CMD_RET_OK)
      {
        printf("parse:%s:%d:internal: no associated rw for this rn\n", "-",
          lineNum);
        return CMD_RET_ERROR;
      }

      // If this 'rn' associates with the most outer 'rw' we're done
      if (repeatCount == 0)
      {
        break;
      }
    }
    else if (strcmp(argWord[0], "rw") == 0)
    {
      // This is a repeat while command
      repeatCount++;
      cmdLineLast->cmdRepeatType = CMD_REPEAT_WHILE;

      // Create new repeat structure, add it to the linked list and
      // link it to the repeat while command
      cmdRepeatLast = cmdRepeatCreate(cmdRepeatLast, cmdRepeatRoot,
        cmdLineLast);
    }
    else
    {
      // Anything else
      cmdLineLast->cmdRepeatType = CMD_REPEAT_NONE;
    }

    // Next command line linenumber
    lineNum++;

    // If this is the first loop entry we've just processed the
    // initial repeat while command. We must now switch to our own
    // command input scanner.
    init = GLCD_FALSE;

    // Get the next keyboard input line
    cmdInputRead(prompt, cmdInput);
    if (cmdInput->input == NULL)
    {
      printf("\n<ctrl>d - quit\n");
      return CMD_RET_ERROR;
    }
  }

  // We do not need to postprocess the repeat linked list as we keep
  // track of the number of 'rw' vs 'rn' commands.
  // When we get here all 'rw' commands are matched with a 'rn' command.
  return CMD_RET_OK;
}
Example #19
0
//
// Function: cmdFileLoad
//
// Load command file contents in a linked list structure
//
int cmdFileLoad(cmdLine_t **cmdLineRoot, cmdRepeat_t **cmdRepeatRoot,
  char *fileName)
{
  FILE *fp;				// Input file pointer
  cmdLine_t *cmdLineLast = NULL;	// The last cmdline in linked list
  cmdRepeat_t *cmdRepeatLast = NULL;	// The last cmdrepeat in linked list
  cmdRepeat_t *searchRepeat = NULL;	// Active cmdrepeat in search efforts
  int unlinkedFound = GLCD_FALSE;	// 'rw' command not linked to 'rn'
  int lineNum = 1;
  char *input = NULL;
  cmdInput_t cmdInput;
  int retVal = CMD_RET_OK;

  // Init the pointers to the command line and the repeat lists
  *cmdLineRoot = NULL;
  *cmdRepeatRoot = NULL;

  // Open command file
  fp = fopen(fileName, "r");
  if (fp == NULL)
  {
    printf("cannot open command file \"%s\"\n", fileName);
    return CMD_RET_ERROR;
  }

  // Initialize our file readline interface and do the first read
  cmdInput.file = fp;
  cmdInput.readMethod = CMD_INPUT_MANUAL;
  cmdInputInit(&cmdInput);
  cmdInputRead("", &cmdInput);

  // Add each line in the command file in a command linked list
  while (cmdInput.input != NULL)
  {
    // Set work pointer
    input = cmdInput.input;

    // Create new command line and add it to the linked list
    cmdLineLast = cmdLineCreate(cmdLineLast, cmdLineRoot);

    // Fill in functional payload of the list element
    cmdLineLast->lineNum = lineNum;
    cmdLineLast->input = malloc(strlen(input) + 1);
    strcpy(cmdLineLast->input, (const char *)input);

    // See if this is a repeat while or repeat next command 
    argInit(&input);
    retVal = argScan(argRepeatCmd, sizeof(argRepeatCmd) / sizeof(argItem_t),
      &input, GLCD_TRUE);

    if (retVal != CMD_RET_OK)
    {
      // Most likely an empty line
      cmdLineLast->cmdRepeatType = CMD_REPEAT_NONE;
    }
    else if (strcmp(argWord[0], "rn") == 0)
    {
      // This is a repeat next command
      cmdLineLast->cmdRepeatType = CMD_REPEAT_NEXT;

      // We must find a repeat while command to associate with
      retVal = cmdRepeatLinkWhile(cmdRepeatLast, cmdLineLast);
      if (retVal != CMD_RET_OK)
      {
        printf("parse:%s:%d:no associated rw for this rn\n", fileName, lineNum);
        cmdInputCleanup(&cmdInput);
        fclose(fp);
        return CMD_RET_ERROR;
      }
    }
    else if (strcmp(argWord[0], "rw") == 0)
    {
      // This is a repeat while command
      cmdLineLast->cmdRepeatType = CMD_REPEAT_WHILE;

      // Create new repeat structure, add it to the linked list and link
      // it to the repeat while command
      cmdRepeatLast = cmdRepeatCreate(cmdRepeatLast, cmdRepeatRoot, cmdLineLast);
    }
    else
    {
      // Anything else
      cmdLineLast->cmdRepeatType = CMD_REPEAT_NONE;
    }

    // Next file line number
    lineNum++;

    // And get next input line
    cmdInputRead("", &cmdInput);
  }

  // File content is loaded in a linked list
  cmdInputCleanup(&cmdInput);
  fclose(fp);

  // Postprocessing the linked lists.
  // We may not find a repeat while command without an associated
  // repeat next command.
  unlinkedFound = GLCD_FALSE;
  searchRepeat = cmdRepeatLast;
  while (searchRepeat != NULL && unlinkedFound == GLCD_FALSE)
  {
    if (searchRepeat->cmdLineRn == NULL)
    {
      // Found a repeat while not associated with a repeat next
      unlinkedFound = GLCD_TRUE;
    }
    else
    {
      // Continue search backwards
      searchRepeat = searchRepeat->prev;
    }
  }
  if (unlinkedFound == GLCD_TRUE)
  {
    printf("parse:%s:%d:no associated rn for this rw\n", fileName,
      searchRepeat->cmdLineRw->lineNum);
    return CMD_RET_ERROR;
  }

  // The file contents have been read into linked lists and is verified
  // for its integrity on matching 'rw'/'rn' repeat constructs
  return CMD_RET_OK;
}
Example #20
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 );
	}
}