Пример #1
0
void CubeMap::setupCapture()
{
    vector<Capture::DeviceRef> devices( Capture::getDevices() );
	for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
		Capture::DeviceRef device = *deviceIt;
		console() << "Found Device " << device->getName() << " ID: " << device->getUniqueId() << std::endl;
		try {
			if( device->checkAvailable() ) {
				mCaptures.push_back( Capture::create( mWidth, mHeight, device ) );
				mCaptures.back()->start();                
			}
			else
				console() << "device is NOT available" << std::endl;
		}
		catch( CaptureExc & ) {
			console() << "Unable to initialize device: " << device->getName() << endl;
		}
	}

    
    
//    vector<Capture::DeviceRef> devices( Capture::getDevices() );
//    for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt )
//    {
//        Capture::DeviceRef device = *deviceIt;
//        console() << "Found Device " << device->getName() << " ID: " << device->getUniqueId() << std::endl;
//        try
//        {
//            if( device->checkAvailable() )
//            {
//                mCapture =Capture::create( texWidth, texHeight, device );
//                mCapture->start();
//                
//                // placeholder text
//                //                    mTextures.push_back( gl::TextureRef() );
//                mVideoTexture =gl::TextureRef();
//
//            }
//            else
//                console() << "device is NOT available" << std::endl;
//        }
//        catch( CaptureExc & )
//        {
//            console() << "Unable to initialize device: " << device->getName() << endl;
//        }
//    }
    
}
Пример #2
0
void PhotoBoothApp::setup()
{
    // Start cameara.
    try{
        
        vector<Capture::DeviceRef> devices( Capture::getDevices() );
        
        // Look for a camera called "Front Camera"
        for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
            Capture::DeviceRef device = *deviceIt;
            
            if(device->getName() == "Front Camera"){
                mCapture = Capture( CAM_WIDTH, CAM_HEIGHT, device );
                mCapture.start();
            }
        }
	}
	catch( ... ) {
		console() << "Failed to initialize camera" << std::endl;
	}
    
    // Load textures
    mConfirmMessage         = loadImage( loadResource("assets/confirm_message.png"));
    mSaveTexture            = loadImage( loadResource("assets/save.png"));
    mDiscardTexture         = loadImage( loadResource("assets/discard.png"));
    mCameraButtonTexture    = loadImage( loadResource("assets/camera.png"));
    mIntroTexture           = loadImage( loadResource("assets/attract.png" ));
    mLightBg                = loadImage( loadResource("assets/bkg_light.png" ));
    mDarkBg                 = loadImage( loadResource("assets/bkg_dark.png" ));
    mNumberBg               = loadImage( loadResource("assets/countdown_bkg.png") );
    mNumberProgress         = loadImage( loadResource("assets/countdown_progress.png") );
    
    mNumberTextures.push_back( loadImage( loadResource("assets/countdown_5.png")));
    mNumberTextures.push_back( loadImage( loadResource("assets/countdown_4.png")));
    mNumberTextures.push_back( loadImage( loadResource("assets/countdown_3.png")));
    mNumberTextures.push_back( loadImage( loadResource("assets/countdown_2.png")));
    mNumberTextures.push_back( loadImage( loadResource("assets/countdown_1.png")));

    width               = getWindowWidth() / DISPLAY_SCALE;
	height              = getWindowHeight() / DISPLAY_SCALE;
    
    mCurrentState       = STATE_PREVIEW;
    
    mDiscardPos         = Vec2f(100, height + 100 );
    mSavePos            = Vec2f(width - 700, height + 100);
    mCameraButtonPos    = Vec2f(width/2 - mCameraButtonTexture.getWidth() / 2, 650 - mCameraButtonTexture.getHeight() / 2);
}
Пример #3
0
void ArtkpApp::setupCapture()
{
	// list out the capture devices
	vector< Capture::DeviceRef > devices( Capture::getDevices() );
	vector< string > deviceNames;

	for ( vector< Capture::DeviceRef >::const_iterator deviceIt = devices.begin();
			deviceIt != devices.end(); ++deviceIt )
	{
		Capture::DeviceRef device = *deviceIt;
		string deviceName = device->getName();

		try
		{
			if ( device->checkAvailable() )
			{
				mCaptures.push_back( Capture( CAPTURE_WIDTH, CAPTURE_HEIGHT,
							device ) );
				deviceNames.push_back( deviceName );
			}
			else
			{
				mCaptures.push_back( Capture() );
				deviceNames.push_back( deviceName + " not available" );
			}
		}
		catch ( CaptureExc & )
		{
			console() << "Unable to initialize device: " << device->getName() <<
				endl;
		}
	}

	if ( deviceNames.empty() )
	{
		deviceNames.push_back( "Camera not available" );
		mCaptures.push_back( Capture() );
	}

	mCurrentCapture = 0;
	mParams.addParam( "Capture", deviceNames, &mCurrentCapture );
}
Пример #4
0
void CaptureApp::setup()
{	
	// list out the devices
	vector<Capture::DeviceRef> devices( Capture::getDevices() );
	for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
		Capture::DeviceRef device = *deviceIt;
		console() << "Found Device " << device->getName() << " ID: " << device->getUniqueId() << std::endl;
		try {
			if( device->checkAvailable() ) {
				mCaptures.push_back( Capture::create( WIDTH, HEIGHT, device ) );
				mCaptures.back()->start();
			
				// placeholder text
				mTextures.push_back( gl::TextureRef() );

				// render the name as a texture
				TextLayout layout;
				layout.setFont( Font( "Arial", 24 ) );
				layout.setColor( Color( 1, 1, 1 ) );
				layout.addLine( device->getName() );
				mNameTextures.push_back( gl::Texture::create( layout.render( true ) ) );
			}
			else
				console() << "device is NOT available" << std::endl;
		}
		catch( CaptureExc & ) {
			console() << "Unable to initialize device: " << device->getName() << endl;
		}
	}
}
CaptureImplDirectShow::CaptureImplDirectShow( int32_t width, int32_t height, const Capture::DeviceRef device )
	: mWidth( width ), mHeight( height ), mCurrentFrame( width, height, false, SurfaceChannelOrder::BGR ), mDeviceID( 0 )
{
	mDevice = device;
	if( mDevice ) {
		mDeviceID = device->getUniqueId();
	}
	if( ! CaptureMgr::instanceVI()->setupDevice( mDeviceID, mWidth, mHeight ) )
		throw CaptureExcInitFail();
	mWidth = CaptureMgr::instanceVI()->getWidth( mDeviceID );
	mHeight = CaptureMgr::instanceVI()->getHeight( mDeviceID );
	mIsCapturing = true;
	mSurfaceCache = std::shared_ptr<SurfaceCache>( new SurfaceCache( mWidth, mHeight, SurfaceChannelOrder::BGR, 4 ) );

	mMgrPtr = CaptureMgr::instance();
}
Пример #6
0
C_IMPL int getCaptureDevices( CaptureDeviceInfo* result, int forceRefresh )
{
    vector<Capture::DeviceRef> devices( Capture::getDevices( forceRefresh ) );
    int i = 0;
    for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); 
            deviceIt != devices.end(); ++deviceIt ) 
    {
        Capture::DeviceRef device = *deviceIt;

        CaptureDeviceInfo *dev = &result[i];

        memcpy(dev->name, device->getName().c_str(), device->getName().size());
        dev->name_size = device->getName().size();
        dev->available = (int)device->checkAvailable();
        dev->connected = (int)device->isConnected();

        ++i;
    }

    return i;
}
Пример #7
0
void reflection_animationApp::setup()
{
    
	// STRUCTURE
	
	m_shapeDims = Vec3f(50, 75, 50);
	m_numlevels = 12;
    m_incr = 2;
	
    m_shapeType = PYRAMID;
    
    initShape();
	cout << m_structure.m_shapes.size() << endl;
    
    // DISPLAY
    
    m_showInterface = true;
    m_recording = false;
    
    m_path = getHomeDirectory() / "Desktop/"; 
    
	m_showColour = true;
    m_renderMode = ALPHA;
    
    m_contrast = 4.0f;
    m_alpha = .45f;
    
    m_face1Display = ACTIVE;
    m_face2Display = DICHROIC1;
    m_face3Display = GLASS;
    m_face4Display = NONE;
    
    m_dichroic1Colour = Color(0.3f, 0.8f, 1.0f);
    m_dichroic2Colour = Color(1.0f, 0.8f, 0.3f);
	
    // ANIMATION
    
    m_aniMode = VIDEO;
    
    // radar
    m_interval = 360;
    m_frontarea = 1.5f;
    m_backarea  = 6.0f;
    
	// GUI
    
	m_params = params::InterfaceGl( "Geometry/Animation Parameters [press TAB to hide]", Vec2i( 400, 600 ) );
	
    // render
    m_params.addText( "render", "label=`Render`" );
	m_params.addSeparator();
    vector<string> rstrs; rstrs.push_back("ALPHA"); rstrs.push_back("ADDITIVE"); rstrs.push_back("MULTIPLY");
    m_params.addParam( "Render Mode", rstrs, (int*)&m_renderMode );
    m_params.addParam( "Use Colour", &m_showColour );
    m_params.addParam( "Alpha", &m_alpha, "min=0.001 max=2.0 step=0.1" );
	m_params.addParam( "Contrast", &m_contrast, "min=0.001 max=5.0 step=0.1" );
	m_params.addParam( "Dichroic Colour 1", &m_dichroic1Colour );
	m_params.addParam( "Dichroic Colour 2", &m_dichroic2Colour );
    m_params.addText( "emptyline1", "label=` `" );
    
    // structure
	m_params.addText( "structure", "label=`Structure`" );
	m_params.addSeparator();
    vector<string> dstrs; dstrs.push_back("ACTIVE"); dstrs.push_back("DICHROIC1"); dstrs.push_back("DICHROIC2"); dstrs.push_back("GLASS"); dstrs.push_back("NONE");
	m_params.addParam( "Face 1 Display mode", dstrs, (int*)&m_face1Display );
    m_params.addParam( "Face 2 Display mode", dstrs, (int*)&m_face2Display );
    m_params.addParam( "Face 3 Display mode", dstrs, (int*)&m_face3Display );
    m_params.addParam( "Face 4 Display mode", dstrs, (int*)&m_face4Display );
    m_params.addText( "emptyline2", "label=` `" );
    
    // generate shape
    m_params.addText( "generate", "label=`Generate`" );
	m_params.addSeparator();
    vector<string> sstrs; sstrs.push_back("PYRAMID"); sstrs.push_back("TETRAHEDRON"); sstrs.push_back("HOLLOW PYRAMID");
	m_params.addParam( "Shape", sstrs, (int*)&m_shapeType );
    m_params.addParam( "Number Of Levels", &m_numlevels );
    m_params.addParam( "Vertical Interval", &m_incr );
    m_params.addParam( "Shape Dimensions", &m_shapeDims );
    m_params.addButton( "Recreate Shape", std::bind( &reflection_animationApp::initShape, this ) );
    m_params.addText( "emptyline3", "label=` `" );
    
    // animation
    m_params.addText( "animation", "label=`Animation`" );
	m_params.addSeparator();
    vector<string> astrs; astrs.push_back("STATIC"); astrs.push_back("RADAR"); astrs.push_back("VIDEO"); astrs.push_back("VIDEO_RADAR");
	m_params.addParam( "Animation Mode", astrs, (int*)&m_aniMode );
    m_params.addParam( "Interval", &m_interval );
    m_params.addParam( "Size (front)", &m_frontarea );
    m_params.addParam( "Size (tail)", &m_backarea );
    
    m_params.addButton( "Recreate Shape", std::bind( &reflection_animationApp::initShape, this ) );
    
	
	// CAMERA/PERSPECTIVE (not updated anymore -> mayacam)

	m_cameraDistance = 800.0f;
    
    m_eye        = Vec3f( 0.0f, 0.0f, m_cameraDistance );
	m_center     = Vec3f::zero();
	m_up         = Vec3f::yAxis();
    
    CameraPersp cam;
    
    cam.setEyePoint(m_eye);
    cam.setCenterOfInterestPoint(m_center);
    cam.setWorldUp(m_up);
    cam.setPerspective(60.0, getWindowAspectRatio(), 5.0, 5000.0);
    m_mayaCam.setCurrentCam( cam );
    
	
	// CAPTURE/VIDEO/INPUT
    
    m_surface = Surface8u(600, 400, true);
    
	vector<Capture::DeviceRef> devices( Capture::getDevices() );
	for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
		Capture::DeviceRef device = *deviceIt;
		console() << "Found Device " << device->getName() << " ID: " << device->getUniqueId() << std::endl;
		try {
			if( device->checkAvailable() ) {

				m_capture.push_back( Capture( 600, 400, device ) );
				m_capture.back().start();
				
				// placeholder texture
				m_textures.push_back( gl::Texture() );
			}
			else
				console() << "device is NOT available" << std::endl;
		}
		catch( CaptureExc & ) {
			console() << "Unable to initialize device: " << device->getName() << endl;
		}
	}
	
    // these should actually only be updated on change --> pointers to parameters
    
    DisplayMode* faceModesArr[] = {
        &m_face1Display, &m_face2Display, &m_face3Display, &m_face4Display
    };
    vector<DisplayMode*> p_faceModes(faceModesArr, faceModesArr+4);
    
    m_structure.setMaterialSettings( p_faceModes, &m_showColour, &m_alpha, &m_contrast );
    m_structure.setAnimationSettings( &m_aniMode );
    m_structure.setRadarSettings( &m_interval, &m_frontarea, &m_backarea);
    
    
}