void HexagonMirrorApp::setup()
{
	// initialize camera
	CameraPersp	cam;
	cam.setEyePoint( Vec3f(90, 70, 90) );
	cam.setCenterOfInterestPoint( Vec3f(90, 70, 0) );
	cam.setFov( 60.0f );
	mCamera.setCurrentCam( cam );

	// load shader
	try { mShaderInstanced = gl::GlslProg( loadAsset("phong_vert.glsl"), loadAsset("phong_frag.glsl") ); }
	catch( const std::exception &e ) { console() << "Could not load and compile shader: " << e.what() << std::endl; }

	// create a vertex array object, which allows us to efficiently position each instance
	initializeBuffer();

	// load hexagon mesh
	loadMesh();

	// connect to a webcam
	try { 
		mCapture = Capture::create( 160, 120 ); 
		mCapture->start();
	}
	catch( const std::exception &e ) { 
		console() << "Could not connect to webcam: " << e.what() << std::endl;

		try { mCaptureTexture = loadImage( loadAsset("placeholder.png") ); }
		catch( const std::exception &e ) { }
	}
}
Exemple #2
0
void SlytherinApp::setup() {
    // setup webcam
    try {
        mCapture = Capture::create(640, 480);
        mCapture->start();
    } catch(...) {
        console() << "ERROR - failed to initialize capture" << endl;
        quit();
    }

    // setup webcam FBO
    gl::Fbo::Format format;
    format.enableColorBuffer(true);
    format.enableDepthBuffer(false);
    format.setWrap(GL_CLAMP, GL_CLAMP);

    mFBO = gl::Fbo(mCapture->getWidth(), mCapture->getHeight(), format);
    mFBO.bindFramebuffer();
        gl::setViewport(mFBO.getBounds());
        gl::clear();
    mFBO.unbindFramebuffer();

    setFrameRate(60.0f);

    mLastUpdateFrame = UINT32_MAX;
    mLinesPerFrame = 2.0f; // 1 line every 2 frames (at getFrameRate())
    mLineIndex = 0;
}
void WayFinderApp::setup()
{
    println("WayFinderApp started.");

    // Load destinations from config file.
    destinations = Destination::getDestinations();
    if(destinations.size() == 0) {
        println("No destinations found, check the config file.");
        exit(EXIT_FAILURE);
    }
    println("Destinations loaded.");

    // Initialized state.
    spotlightRadius = (float)getWindowWidth() / 16.0f;
    arrowLength = (float)min(getWindowWidth(), getWindowHeight()) / 2.0f;
    spotlightCenter2D = Vec2f((float)getWindowWidth() / 2.0f, (float)getWindowHeight() / 2.0f);
    spotlightCenter3D = Vec3f((float)getWindowWidth() / 2.0f, (float)getWindowHeight() / 2.0f, 0.0f);
    detected = false;

    //capture = Capture::create(WayFinderApp::WIDTH, WayFinderApp::HEIGHT);
    capture = Capture::create(getWindowWidth(), getWindowHeight());
    capture->start();

    //bg.set("bShadowDetection", false);
    bg.set("nmixtures", 3);
    bg.setBool("detectShadows", true);

    debugView = false;
}
void projections_balletApp::keyDown( KeyEvent event )
{
  if( event.getChar() == 'f' )
    setFullScreen( ! isFullScreen() );
  else if( event.getChar() == ' ' )
    ( mCapture && mCapture->isCapturing() ) ? mCapture->stop() : mCapture->start();
  else if(event.getChar() == 'c'){
    mode = CONFIG;
    window_coords.clear();
  }
}
void camerasApp::setup()
{

	glEnable( GL_CULL_FACE );
	glFrontFace( GL_CW ); // the default camera inverts to a clockwise front-facing direction

	mDrawVerbose = true;
	mUseConstraintAxis = false;
	mCurrentMouseDown = mInitialMouseDown = Vec2i( 200, 200 );
    
    mCapture = Capture::create( 320,240 );
    mCapture->start();

}
void projections_balletApp::setup(){
  
  // print the devices
  for( auto device = Capture::getDevices().begin(); device != Capture::getDevices().end(); ++device ) {
    console() << "Device: " << (*device)->getName() << " " << std::endl;
    
    try {
      mCapture = Capture::create( 640, 480 );
      mCapture->start();
    }
    catch( ... ) {
      console() << "Failed to initialize capture" << std::endl;
    }
  }
  
}
void CinderVideoStreamServerApp::setup()
{
	// list out the devices
    //setFrameRate(30);
	try {
		mCapture = Capture::create( WIDTH, HEIGHT );
		mCapture->start();
	}
	catch( ci::Exception &exc ) {
		console() << "Failed to initialize capture, what: " << exc.what() << std::endl;
	}

    queueToServer = new ph::ConcurrentQueue<uint8_t*>();
    mServerThreadRef = std::shared_ptr<std::thread>(new std::thread(std::bind(&CinderVideoStreamServerApp::threadLoop, this)));
    mServerThreadRef->detach();
    if (!running) running = true;
    
    totalStreamSize = 0.0;
    mQuality = 0.1f;
}
void CinderCalibrationApp::setup()
{
	mState			= STATE_DETECT;
	mImages			= 0;
	showDistorted	=	true;
	mAvgError		= 0;

	try {
		mCapture = Capture::create( CAPTURE_WIDTH, CAPTURE_HEIGHT );
		mCapture->start();
		console() << mCapture->getSize() << endl;;
		console() << getWindowSize() << endl;
	} catch( ... ) {
		console() << "Failed to initialize capture" << std::endl;
	}
	
	int numSquares = BOARD_CORNERS_X * BOARD_CORNERS_Y;
	for( int j = 0;j < numSquares; j++ ) {
		obj.push_back( Point3f( j / BOARD_CORNERS_X, j % BOARD_CORNERS_X, 0.0f ) );
	}
}