Esempio n. 1
0
static void Keyboard(unsigned char key, int x, int y)
{
	int mode;
	switch (key) {
		case 0x1B:						// Quit.
		case 'r':
			knight->Reset();
		case 'x':
			knight->TranslateX(0.1);
			break;
		case 'y':
			knight->TranslateY(0.1);
			break;
		case 'z':
			knight->TranslateZ(0.1);
			break;
		case 'Q':
		case 'q':
			Quit();
			break;
		case ' ':
			gDrawRotate = !gDrawRotate;
			break;
		case 'C':
		case 'c':
			mode = arglDrawModeGet(gArglSettings);
			if (mode == AR_DRAW_BY_GL_DRAW_PIXELS) {
				arglDrawModeSet(gArglSettings, AR_DRAW_BY_TEXTURE_MAPPING);
				arglTexmapModeSet(gArglSettings, AR_DRAW_TEXTURE_FULL_IMAGE);
			} else {
				mode = arglTexmapModeGet(gArglSettings);
				if (mode == AR_DRAW_TEXTURE_FULL_IMAGE)	arglTexmapModeSet(gArglSettings, AR_DRAW_TEXTURE_HALF_IMAGE);
				else arglDrawModeSet(gArglSettings, AR_DRAW_BY_GL_DRAW_PIXELS);
			}
			fprintf(stderr, "*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer());
			gCallCountMarkerDetect = 0;
			arUtilTimerReset();
			debugReportMode();
			break;
		case 'D':
		case 'd':
			arDebug = !arDebug;
			break;
		case '?':
		case '/':
			printf("Keys:\n");
			printf(" q or [esc]    Quit demo.\n");
			printf(" c             Change arglDrawMode and arglTexmapMode.\n");
			printf(" d             Activate / deactivate debug mode.\n");
			printf(" ? or /        Show this help.\n");
			printf("\nAdditionally, the ARVideo library supplied the following help text:\n");
			arVideoDispOption();
			break;
		default:
			break;
	}
}
Esempio n. 2
0
ARGL_CONTEXT_SETTINGS_REF arglSetupForCurrentContext(void)
{
	ARGL_CONTEXT_SETTINGS_REF contextSettings;
	
	contextSettings = (ARGL_CONTEXT_SETTINGS_REF)calloc(1, sizeof(ARGL_CONTEXT_SETTINGS));
	// Use default pixel format handed to us by <AR/config.h>.
	if (!arglPixelFormatSet(contextSettings, AR_DEFAULT_PIXEL_FORMAT)) {
		printf("Unknown default pixel format defined in config.h.\n"); // Windows bug: when running multi-threaded, can't write to stderr!
		return (NULL);
	}
	arglDrawModeSet(contextSettings, AR_DRAW_BY_TEXTURE_MAPPING);
	arglTexmapModeSet(contextSettings, AR_DRAW_TEXTURE_FULL_IMAGE);
	arglTexRectangleSet(contextSettings, TRUE);

	return (contextSettings);
}
Esempio n. 3
0
static int setupMovie(const char *path)
{
    char *movieVconf;
    int len;
 	int				xsize, ysize;
    AR_PIXEL_FORMAT pixFormat;
    
    // Construct the vconf string.
    arMalloc(movieVconf, char, 2048); // 2Kb for URL.
    sprintf(movieVconf, "-device=QUICKTIME -movie=\""); // Make sure we're using the QuickTime video input.
    len = (int)strlen(movieVconf);
    strncat(movieVconf + len, path, 2048 - len - 1);
    len = (int)strlen(movieVconf);
    strncat(movieVconf + len, "\" -loop -pause", 2048 - len - 1); // Start the movie paused. It will be unpaused in mainLoop().

    // Open the movie.
    gMovieVideo = ar2VideoOpen(movieVconf);
    free(movieVconf);
    if (!gMovieVideo) {
    	ARLOGe("setupMovie(): Unable to open movie.\n");
    	return (FALSE);
	}
	
    // Find the size of the movie.
    if (ar2VideoGetSize(gMovieVideo, &xsize, &ysize) < 0) return (FALSE);
	
	// Get the pixel format of the movie.
	pixFormat = ar2VideoGetPixelFormat(gMovieVideo);
	if (pixFormat == AR_PIXEL_FORMAT_INVALID) {
    	ARLOGe("setupMovie(): Movie is using unsupported pixel format.\n");
		return (FALSE);
	}
	
    // Set up an ARParam object for the movie input.
    arParamClear(&gMovieCparam, xsize, ysize, AR_DIST_FUNCTION_VERSION_DEFAULT);
    
    // For convenience, we will use gsub_lite to draw the actual pixels. Set it up now.
    gMovieArglSettings = arglSetupForCurrentContext(&gMovieCparam, pixFormat);
    arglDistortionCompensationSet(gMovieArglSettings, 0);
    arglDrawModeSet(gMovieArglSettings, AR_DRAW_BY_TEXTURE_MAPPING);
    arglTexmapModeSet(gMovieArglSettings, AR_DRAW_TEXTURE_FULL_IMAGE);
    
    return (TRUE);
}
Esempio n. 4
0
ARGL_CONTEXT_SETTINGS_REF arglSetupForCurrentContext(ARParam *cparam, AR_PIXEL_FORMAT pixelFormat)
{
	ARGL_CONTEXT_SETTINGS_REF contextSettings;
	
	contextSettings = (ARGL_CONTEXT_SETTINGS_REF)calloc(1, sizeof(ARGL_CONTEXT_SETTINGS));
    contextSettings->arParam = *cparam; // Copy it.
    contextSettings->arhandle = NULL;
	
	// Use supplied pixel format.
    // This sets pixIntFormat, pixFormat, pixType, pixSize, and sets initPlease.
	if (!arglPixelFormatSet(contextSettings, pixelFormat)) {
		ARLOGe("arglSetupForCurrentContext() Error: Unknown default pixel format %s (%d).\n", arUtilGetPixelFormatName(pixelFormat), pixelFormat);
        free(contextSettings);
		return (NULL);
	}
    
	arglDrawModeSet(contextSettings, AR_DRAW_BY_TEXTURE_MAPPING);
	arglTexmapModeSet(contextSettings, AR_DRAW_TEXTURE_FULL_IMAGE);
	arglTexRectangleSet(contextSettings, TRUE);
    
	return (contextSettings);
}
Esempio n. 5
0
static void Keyboard(unsigned char key, int x, int y)
{
	int mode, threshChange = 0;
    AR_LABELING_THRESH_MODE modea;
	
	switch (key) {
		case 0x1B:						// Quit.
		case 'Q':
		case 'q':
			cleanup();
			exit(0);
			break;
		case ' ':
			gDrawRotate = !gDrawRotate;
			break;
		case 'X':
		case 'x':
            arGetImageProcMode(gARHandle, &mode);
            switch (mode) {
                case AR_IMAGE_PROC_FRAME_IMAGE:  mode = AR_IMAGE_PROC_FIELD_IMAGE; break;
                case AR_IMAGE_PROC_FIELD_IMAGE:
                default: mode = AR_IMAGE_PROC_FRAME_IMAGE; break;
            }
            arSetImageProcMode(gARHandle, mode);
			break;
		case 'C':
		case 'c':
			mode = arglDrawModeGet(gArglSettings);
			if (mode == AR_DRAW_BY_GL_DRAW_PIXELS) {
				arglDrawModeSet(gArglSettings, AR_DRAW_BY_TEXTURE_MAPPING);
				arglTexmapModeSet(gArglSettings, AR_DRAW_TEXTURE_FULL_IMAGE);
			} else {
				mode = arglTexmapModeGet(gArglSettings);
				if (mode == AR_DRAW_TEXTURE_FULL_IMAGE)	arglTexmapModeSet(gArglSettings, AR_DRAW_TEXTURE_HALF_IMAGE);
				else arglDrawModeSet(gArglSettings, AR_DRAW_BY_GL_DRAW_PIXELS);
			}
			ARLOGe("*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer());
			gCallCountMarkerDetect = 0;
			arUtilTimerReset();
			break;
		case 'a':
		case 'A':
			arGetLabelingThreshMode(gARHandle, &modea);
            switch (modea) {
                case AR_LABELING_THRESH_MODE_MANUAL:        modea = AR_LABELING_THRESH_MODE_AUTO_MEDIAN; break;
                case AR_LABELING_THRESH_MODE_AUTO_MEDIAN:   modea = AR_LABELING_THRESH_MODE_AUTO_OTSU; break;
                case AR_LABELING_THRESH_MODE_AUTO_OTSU:     modea = AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE; break;
                case AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE: modea = AR_LABELING_THRESH_MODE_AUTO_BRACKETING; break;
                case AR_LABELING_THRESH_MODE_AUTO_BRACKETING:
                default: modea = AR_LABELING_THRESH_MODE_MANUAL; break;
            }
            arSetLabelingThreshMode(gARHandle, modea);
			break;
		case '-':
			threshChange = -5;
			break;
		case '+':
		case '=':
			threshChange = +5;
			break;
		case 'D':
		case 'd':
			arGetDebugMode(gARHandle, &mode);
			arSetDebugMode(gARHandle, !mode);
			break;
        case 's':
        case 'S':
            if (!gARTImageSavePlease) gARTImageSavePlease = TRUE;
            break;
		case '?':
		case '/':
            gShowHelp++;
            if (gShowHelp > 1) gShowHelp = 0;
			break;
        case 'm':
        case 'M':
            gShowMode = !gShowMode;
            break;
		default:
			break;
	}
	if (threshChange) {
		int threshhold;
		arGetLabelingThresh(gARHandle, &threshhold);
		threshhold += threshChange;
		if (threshhold < 0) threshhold = 0;
		if (threshhold > 255) threshhold = 255;
		arSetLabelingThresh(gARHandle, threshhold);
	}
	
}