Esempio n. 1
0
bool ofxArtool5::setupPattern(ofVec2f _camSize, ofVec2f _viewportSize, ofPixelFormat pf, string pthCamParam, string pthMarker){
    
    artMode=ART_PATTERN;
    curArtMode=(ofxArtoolMode*)(new ofxArtoolModePatt());
    curArtMode->gCparamLT=gCparamLT;
    
    if(!setupCamera(pthCamParam, _camSize, _viewportSize)){
        return false;
    }
    
    return true;
    
    artMode=ART_PATTERN;
    curArtMode = (ofxArtoolMode * )(new ofxArtoolModePatt());
    curArtMode->gCparamLT = gCparamLT;
    
    bPattFound = false;
    selectedId = -1;
    
    if(!setupCamera(pthCamParam, _camSize, _viewportSize)){
        return false;
    }
    
    arUtilTimerReset();
    
    if(!setupMarker(pthMarker)){
        cleanup();
        return false;
    }
    
    return true;
}
Esempio n. 2
0
bool ARTApp::init(const char *cparamName, const char *pattName, const char *objModelFile, float pattWidth, float modelScale)
{
	if (arHandle) //has initialized
		return false;

	if (!setupCamera(cparamName, "", &cParam, &arHandle, &ar3DHandle)) {
		return false;
	}

	if (!setupMarker(pattName, &pattID, arHandle, &pattHandle)) {
		return false;
	}

	{
		objModel = glmReadOBJ((char*)objModelFile);
		if (!objModel)
		{
			ARLOGe("Unable to load obj model file.\n");
			return false;
		}
		glmUnitize(objModel);
		glmScale(objModel, pattWidth*modelScale);
	}
	this->pattWidth = pattWidth;

	return true;
}
Esempio n. 3
0
int main(int argc, char** argv)
{
	char glutGamemode[32];
	char cparam_name[] = "Data/camera_para.dat";
	char vconf[] = "";
	char patt_name[]  = "Data/patt.hiro";
    
    char movieFileName[] = "Data/sample.mov";
    char *movieURI;
	
    //
	// Library inits.
	//

	glutInit(&argc, argv);

	//
	// Video setup.
	//

	if (!setupCamera(cparam_name, vconf, &gCparamLT, &gARHandle, &gAR3DHandle)) {
		ARLOGe("main(): Unable to set up AR camera.\n");
		exit(-1);
	}

	//
	// Graphics setup.
	//

	// Set up GL context(s) for OpenGL to draw into.
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	if (!windowed) {
		if (windowRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", windowWidth, windowHeight, windowDepth, windowRefresh);
		else sprintf(glutGamemode, "%ix%i:%i", windowWidth, windowHeight, windowDepth);
		glutGameModeString(glutGamemode);
		glutEnterGameMode();
	} else {
		glutInitWindowSize(windowWidth, windowHeight);
		glutCreateWindow(argv[0]);
	}

	// Setup ARgsub_lite library for current OpenGL context.
	if ((gArglSettings = arglSetupForCurrentContext(&(gCparamLT->param), arVideoGetPixelFormat())) == NULL) {
		ARLOGe("main(): arglSetupForCurrentContext() returned error.\n");
		cleanup();
		exit(-1);
	}
    arglSetupDebugMode(gArglSettings, gARHandle);
	arUtilTimerReset();
		
	// Load marker(s).
	if (!setupMarker(patt_name, &gPatt_id, gARHandle, &gARPattHandle)) {
		ARLOGe("main(): Unable to set up AR marker.\n");
		cleanup();
		exit(-1);
	}
	
    //
    // Movie loading.
    //

    // In this example, we load a movie via a file URI, but other URIs allowed
    // by the QuickTime module would also be fine.

    // Movie relative path is in "movieFileName". Get a file:// URI for it.
    movieURI = arUtilGetFileURI(movieFileName);
    if (!movieURI) {
        ARLOGe("Error: Unable to construct URI for movie file '%s'.\n", movieFileName);
		cleanup();
		exit(-1);
    }
    
    // Now open the movie.
    if (!setupMovie(movieURI)) {
        ARLOGe("Error: Unable to open movie at URI '%s'.\n", movieURI);
        free(movieURI);
		cleanup();
		exit(-1);
    }
    
    free(movieURI); // We're finished with movieURI, so free it.

	// Register GLUT event-handling callbacks.
	// NB: mainLoop() is registered by Visibility.
	glutDisplayFunc(Display);
	glutReshapeFunc(Reshape);
	glutVisibilityFunc(Visibility);
	glutKeyboardFunc(Keyboard);
	
	glutMainLoop();

	return (0);
}
Esempio n. 4
0
int main(int argc, char** argv)
{
    char glutGamemode[32];
    char *cparam_name = "Data/camera_para.dat";
    char *vconf = "";
    char *patt_name  = "Data/patt.hiro";

    // ----------------------------------------------------------------------------
    // Library inits.
    //

    glutInit(&argc, argv);

    // ----------------------------------------------------------------------------
    // Hardware setup.
    //

    if (!setupCamera(cparam_name, vconf, &gARTCparam)) {
        fprintf(stderr, "main(): Unable to set up AR camera.\n");
        exit(-1);
    }

    // ----------------------------------------------------------------------------
    // Library setup.
    //

    // Set up GL context(s) for OpenGL to draw into.
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    if (!prefWindowed) {
        if (prefRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh);
        else sprintf(glutGamemode, "%ix%i:%i", prefWidth, prefHeight, prefDepth);
        glutGameModeString(glutGamemode);
        glutEnterGameMode();
    } else {
        glutInitWindowSize(prefWidth, prefHeight);
        glutCreateWindow(argv[0]);
    }

    //	// Setup ARgsub_lite library for current OpenGL context.
    //	if ((gArglSettings = arglSetupForCurrentContext()) == NULL) {
    //		fprintf(stderr, "main(): arglSetupForCurrentContext() returned error.\n");
    //		cleanup();
    //		exit(-1);
    //	}
    //	debugReportMode(gArglSettings);
    glEnable(GL_DEPTH_TEST);
    arUtilTimerReset();

    // Load marker(s).
    if (!setupMarker(patt_name, &gPatt_id)) {
        fprintf(stderr, "main(): Unable to set up AR marker.\n");
        cleanup();
        exit(-1);
    }

    //	// Register GLUT event-handling callbacks.
    //	// NB: mainLoop() is registered by Visibility.
    //	glutDisplayFunc(Display);
    //	glutReshapeFunc(Reshape);
    //	glutVisibilityFunc(Visibility);
    //	glutKeyboardFunc(Keyboard);

    //	glutMainLoop();

    return (0);
}
Esempio n. 5
0
/* the main function */
int main(int argc, char *argv[])
{

    AppState state;

    char *vconf = "";

    if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
        fprintf(stderr,"SDL error %s\n",SDL_GetError());
        return 1;
    }

    SDL_RendererInfo displayRendererInfo;


    SDL_CreateWindowAndRenderer(640, 480, SDL_WINDOW_OPENGL, &state.window, &state.renderer);
    SDL_GetRendererInfo(state.renderer, &displayRendererInfo);


    fprintf(stdout,"SDL Renderer accelerated %d\n",displayRendererInfo.flags & SDL_RENDERER_ACCELERATED);
    fprintf(stdout,"SDL Renderer target texture %d\n",displayRendererInfo.flags & SDL_RENDERER_TARGETTEXTURE);



    /* check support */
    if ((displayRendererInfo.flags & SDL_RENDERER_ACCELERATED) == 0 ||
            (displayRendererInfo.flags & SDL_RENDERER_TARGETTEXTURE) == 0)
    {
        fprintf(stderr,"SDL not fully supported\n");
        return -1;
    }

    if (state.window == 0L){
        fprintf(stderr,"SDL error %s\n",SDL_GetError());
        return 1;
    }


    // turn on double buffering set the depth buffer to 24 bits
    // you may need to change this to 16 or 32 for your system
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);

    state.context = SDL_GL_CreateContext(state.window);
    if (state.context == 0L){
        fprintf(stderr,"SDL error %s\n",SDL_GetError());
        return 1;
    }

    if (!setupCamera(cparam_name, vconf, &gARTCparam)) {
        fprintf(stderr, "main(): Unable to set up AR camera.\n");
        return -1;
    }

    // Load marker(s).
    if (!setupMarker(patt_name, &gPatt_id)) {
        fprintf(stderr, "main(): Unable to set up AR marker.\n");
        return -1;
    }

    // Poll for events, and handle the ones we care about.
    SDL_Event event;
    int running = 1;

    SDL_SetRenderDrawColor(state.renderer, 10, 30, 255, 255);

     glEnable(GL_DEPTH_TEST);

    createBackgroundImage(&state,gsARTImageWidth,gsARTImageHeight);

    while (running) {


        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_KEYDOWN:
                break;
            case SDL_KEYUP:
                // If escape is pressed, return (and thus, quit)
                if (event.key.keysym.sym == SDLK_ESCAPE)
                    return 0;
                break;
            case SDL_QUIT:
                goto cleanup;
            }
        }

        update(&state);

        SDL_GL_SwapWindow(state.window);

    }

cleanup:

    SDL_DestroyTexture(state.background);
    //    SDL_DestroyTexture(state.scene);

    SDL_GL_DeleteContext(state.context);

    SDL_DestroyRenderer(state.renderer);
    SDL_DestroyWindow(state.window);

    return 0;
}
Esempio n. 6
0
int main(int argc, char** argv)
{
	char glutGamemode[32];
	char cparam_name[] = "Data/camera_para.dat";
	char vconf[] = "";
	char patt_name[]  = "Data/patt.hiro";
	
    //
	// Library inits.
	//

	glutInit(&argc, argv);

	//
	// Video setup.
	//

	if (!setupCamera(cparam_name, vconf, &gCparamLT, &gARHandle, &gAR3DHandle)) {
		ARLOGe("main(): Unable to set up AR camera.\n");
		exit(-1);
	}

	//
	// Graphics setup.
	//

	// Set up GL context(s) for OpenGL to draw into.
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	if (!windowed) {
		if (windowRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", windowWidth, windowHeight, windowDepth, windowRefresh);
		else sprintf(glutGamemode, "%ix%i:%i", windowWidth, windowHeight, windowDepth);
		glutGameModeString(glutGamemode);
		glutEnterGameMode();
	} else {
		glutInitWindowSize(windowWidth, windowHeight);
		glutCreateWindow(argv[0]);
	}

	// Setup ARgsub_lite library for current OpenGL context.
	if ((gArglSettings = arglSetupForCurrentContext(&(gCparamLT->param), arVideoGetPixelFormat())) == NULL) {
		ARLOGe("main(): arglSetupForCurrentContext() returned error.\n");
		cleanup();
		exit(-1);
	}
    arglSetupDebugMode(gArglSettings, gARHandle);
	arUtilTimerReset();
		
	// Load marker(s).
	if (!setupMarker(patt_name, &gPatt_id, gARHandle, &gARPattHandle)) {
		ARLOGe("main(): Unable to set up AR marker.\n");
		cleanup();
		exit(-1);
	}
	
	// Register GLUT event-handling callbacks.
	// NB: mainLoop() is registered by Visibility.
	glutDisplayFunc(Display);
	glutReshapeFunc(Reshape);
	glutVisibilityFunc(Visibility);
	glutKeyboardFunc(Keyboard);
	
	glutMainLoop();

	return (0);
}
Esempio n. 7
0
int main(int argc, char** argv)
{
	char glutGamemode[32];
	const char *cparam_name = "Data/camera_para.dat";
	//
	// Camera configuration.
	//
	char *vconf = "v4l2src device=/dev/video0 ! ffmpegcolorspace ! capsfilter caps=video/x-raw-rgb,bpp=24,width=320,height=240 ! identity name=artoolkit ! fakesink";
	const char *patt_name  = "Data/patt.kanji";
	
	// ----------------------------------------------------------------------------
	// Library inits.
	//

	glutInit(&argc, argv);

	// ----------------------------------------------------------------------------
	// Hardware setup.
	//

	if (!setupCamera(cparam_name, vconf, &gARTCparam)) {
		fprintf(stderr, "main(): Unable to set up AR camera.\n");
		exit(-1);
	}

	//Read in ply file
	parse();

	// ----------------------------------------------------------------------------
	// Library setup.
	//

	// Set up GL context(s) for OpenGL to draw into.
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	if (!prefWindowed) {
		if (prefRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh);
		else sprintf(glutGamemode, "%ix%i:%i", prefWidth, prefHeight, prefDepth);
		glutGameModeString(glutGamemode);
		glutEnterGameMode();
	} else {
		glutInitWindowSize(prefWidth, prefHeight);
		glutCreateWindow(argv[0]);
	}

	// Setup argl library for current context.
	if ((gArglSettings = arglSetupForCurrentContext()) == NULL) {
		fprintf(stderr, "main(): arglSetupForCurrentContext() returned error.\n");
		exit(-1);
	}
	debugReportMode(gArglSettings);
	glEnable(GL_DEPTH_TEST);
	arUtilTimerReset();
		
	if (!setupMarker(patt_name, &gPatt_id)) {
		fprintf(stderr, "main(): Unable to set up AR marker.\n");
		Quit();
	}
	
	// Register GLUT event-handling callbacks.
	// NB: Idle() is registered by Visibility.
	glutDisplayFunc(Display);
	glutReshapeFunc(Reshape);
	glutVisibilityFunc(Visibility);
	glutKeyboardFunc(Keyboard);
	
	glutMainLoop();

	return (0);
}