コード例 #1
0
void PS3EYECaptureApp::setup()
{
    using namespace ps3eye;

    // list out the devices
    std::vector<PS3EYECam::PS3EYERef> devices( PS3EYECam::getDevices() );
	console() << "found " << devices.size() << " cameras" << std::endl;

	mTimer = Timer(true);
	mCamFrameCount = 0;
	mCamFps = 0;
	mCamFpsLastSampleFrame = 0;
	mCamFpsLastSampleTime = 0;

	gui = new ciUICanvas(0,0,320, 480);
    
    float gh = 15;
    float slw = 320 - 20;

    if(devices.size())
    {   
        eye = devices.at(0);
        bool res = eye->init(640, 480, 60);
        console() << "init eye result " << res << std::endl;
        eye->start();
        
		frame_bgr = new uint8_t[eye->getWidth()*eye->getHeight()*3];
		mFrame = Surface(frame_bgr, eye->getWidth(), eye->getHeight(), eye->getWidth()*3, SurfaceChannelOrder::BGR);
		memset(frame_bgr, 0, eye->getWidth()*eye->getHeight()*3);
		        
        gui->addWidgetDown(new ciUILabel("EYE", CI_UI_FONT_MEDIUM));
        
        eyeFpsLab = new eyeFPS(CI_UI_FONT_MEDIUM);
        gui->addWidgetRight(eyeFpsLab);
        
        // controls
        gui->addWidgetDown(new ciUIToggle(gh, gh, false, "auto gain"));
        gui->addWidgetRight(new ciUIToggle(gh, gh, false, "auto white balance"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 63, eye->getGain(), "gain"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 63, eye->getSharpness(), "sharpness"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 255, eye->getExposure(), "exposure"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 255, eye->getBrightness(), "brightness"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 255, eye->getContrast(), "contrast"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 255, eye->getHue(), "hue"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 255, eye->getBlueBalance(), "blue balance"));
        gui->addWidgetDown(new ciUISlider(slw, gh, 0, 255, eye->getRedBalance(), "red balance"));
        
        gui->registerUIEvents(this, &PS3EYECaptureApp::guiEvent);
    }
}
コード例 #2
0
void PS3EyeSlowMoApp::setup()
{
    currentFrame = 0;
    mSkippedFrames = 1;
    using namespace ps3eye;
    
    mShouldQuit = false;
    
    // list out the devices
    std::vector<PS3EYECam::PS3EYERef> devices( PS3EYECam::getDevices() );
    console() << "found " << devices.size() << " cameras" << std::endl;
    
    mTimer = Timer(true);
    mCamFrameCount = 0;
    mCamFps = 0;
    mCamFpsLastSampleFrame = 0;
    mCamFpsLastSampleTime = 0;
    
    if(devices.size())
    {
        eye = devices.at(0);
        bool res = eye->init(640, 480, 60);
        console() << "init eye result " << res << std::endl;
        eye->start();

        frame_bgra = new uint8_t[eye->getWidth()*eye->getHeight()*4];
        mFrame = Surface(frame_bgra, eye->getWidth(), eye->getHeight(), eye->getWidth()*4, SurfaceChannelOrder::BGRA);
        memset(frame_bgra, 0, eye->getWidth()*eye->getHeight()*4);
        
        // create and launch the thread
        mThread = thread( bind( &PS3EyeSlowMoApp::eyeUpdateThreadFn, this ) );
    }
    
    mParams = params::InterfaceGl::create( "PS3EYE", toPixels( ivec2( 180, 150 ) ) );
    
    mParams->addParam( "Framerate", &mFrameRate, "", true );
    mParams->addParam( "Queue", &mQueueSize, "", true);
    mParams->addSeparator();
    mParams->addParam( "Skip", &mSkippedFrames).min( 1 ).step( 1 );
    mParams->addParam( "Auto gain", &isAutoGain );
    mParams->addParam( "Auto WB", &isAutoWB );

    //surfaceQueue = new ph::ConcurrentQueue<Surface*>();

    mAccumFbo = gl::Fbo::create( getWindowWidth(), getWindowHeight(),
                                gl::Fbo::Format().colorTexture( gl::Texture::Format().internalFormat( GL_RGB16F ) ).disableDepth() );
    
}