void FaceOff::update() { #ifdef QUICKTIME_ENABLED if (MOVIE_MODE) { if (!mMovie) { fs::path moviePath = getAssetPath(MOVIE_PATH); try { // load up the movie, set it to loop, and begin playing mMovie = qtime::MovieSurface::create(moviePath); mMovie->setLoop(); mMovie->play(); mOfflineFaceTex.reset(); } catch (ci::Exception &exc) { console() << "Exception caught trying to load the movie from path: " << MOVIE_PATH << ", what: " << exc.what() << std::endl; mMovie.reset(); } } else { if (mMovie->checkNewFrame()) { auto surface = mMovie->getSurface(); if (!mOfflineFaceTex) { mOfflineFaceTex = gl::Texture2d::create(*surface, gl::Texture::Format().loadTopDown()); } else { mOfflineFaceTex->update(*surface); } } } } else { mMovie.reset(); mOfflineFaceTex = mPhotoTex; } #endif if (mDeviceId != DEVICE_ID) { mDeviceId = DEVICE_ID; mCapture.setup(CAM_W, CAM_H, mDevices[DEVICE_ID]); mDoesCaptureNeedsInit = true; } if (mCapture.isBackCamera) mCapture.flip = false; else mCapture.flip = CAM_FLIP; }
void MotionTrackingTestApp::draw() { // gl::setViewport( getWindowBounds() ); // clear out the window with black gl::clear( Color( 1, 1, 1 ) ); // if( mSurface ){ // if( mTexture ){ // mTexture->update( mSurface ); // } else { // mTexture = gl::Texture::create( mSurface ); // } // gl::draw( mTexture, mTexture->getBounds(), getWindowBounds() ); // } if( mSurfaceDepth ){ if( mTextureDepth ){ mTextureDepth->update( Channel32f( mSurfaceDepth ) ); } else { mTextureDepth = gl::Texture::create( Channel32f( mSurfaceDepth ) ); } gl::color( Color::white() ); gl::draw( mTextureDepth, mTextureDepth->getBounds() ); } gl::pushMatrices(); gl::translate( Vec2f( 320, 0 ) ); if( mSurfaceBlur ){ if( mTextureDepth ){ mTextureDepth->update( Channel32f( mSurfaceBlur ) ); } else { mTextureDepth = gl::Texture::create( Channel32f( mSurfaceBlur ) ); } gl::draw( mTextureDepth, mTextureDepth->getBounds() ); } gl::translate( Vec2f( 0, 240 ) ); if( mSurfaceSubtract ){ if( mTextureDepth ){ mTextureDepth->update( Channel32f( mSurfaceSubtract ) ); } else { mTextureDepth = gl::Texture::create( Channel32f( mSurfaceSubtract ) ); } gl::draw( mTextureDepth, mTextureDepth->getBounds() ); } gl::translate( Vec2f( -320, 0 ) ); for( ContourVector::iterator iter = mContours.begin(); iter != mContours.end(); ++iter ){ glBegin( GL_LINE_LOOP ); for( vector< cv::Point >::iterator pt = iter->begin(); pt != iter->end(); ++pt ){ gl::color( Color( 1.0f, 0.0f, 0.0f ) ); gl::vertex( fromOcv( *pt ) ); } glEnd(); } gl::translate( Vec2f( 0, 240 ) ); for( int i=0; i<mTrackedShapes.size(); i++){ glBegin( GL_POINTS ); for( int j=0; j<mTrackedShapes[i].hull.size(); j++ ){ gl::color( Color( 1.0f, 0.0f, 0.0f ) ); gl::vertex( fromOcv( mTrackedShapes[i].hull[j] ) ); } glEnd(); } gl::popMatrices(); mParams->draw(); }
void PointCloudApp::draw() { gl::viewport( getWindowSize() ); gl::clear(); gl::setMatrices( mCamUi.getCamera() ); gl::enableAlphaBlending(); gl::enableDepthRead(); gl::enableDepthWrite(); if ( mSurfaceColor ) { if ( mTextureColor ) { mTextureColor->update( *mSurfaceColor ); } else { mTextureColor = gl::Texture::create( *mSurfaceColor ); } mTextureColor->bind( 0 ); } if ( mChannelDepth ) { if ( mTextureDepth ) { gl::ScopedTextureBind scopeTextureBind( mTextureDepth->getTarget(), mTextureDepth->getId() ); glTexSubImage2D( mTextureDepth->getTarget(), 0, 0, 0, mTextureDepth->getWidth(), mTextureDepth->getHeight(), GL_RED_INTEGER, GL_UNSIGNED_SHORT, mChannelDepth->getData() ); } else { mTextureDepth = gl::Texture::create( mChannelDepth->getWidth(), mChannelDepth->getHeight(), gl::Texture::Format().dataType( GL_UNSIGNED_SHORT ).internalFormat( GL_R16UI ) ); } mTextureDepth->bind( 1 ); } if ( mSurfaceDepthToCameraTable && !mTextureDepthToCameraTable ) { mTextureDepthToCameraTable = gl::Texture::create( *mSurfaceDepthToCameraTable ); mTextureDepthToCameraTable->bind( 2 ); } if ( mSurfaceDepthToColorTable ) { if ( mTextureDepthToColorTable ) { mTextureDepthToColorTable->update( *mSurfaceDepthToColorTable ); } else { mTextureDepthToColorTable = gl::Texture::create( *mSurfaceDepthToColorTable, gl::Texture::Format().dataType( GL_FLOAT ) ); } mTextureDepthToColorTable->bind( 3 ); } gl::ScopedGlslProg scopeGlsl( mGlslProg ); gl::setDefaultShaderVars(); mGlslProg->uniform( "uTextureColor", 0 ); mGlslProg->uniform( "uTextureDepth", 1 ); mGlslProg->uniform( "uTextureDepthToCameraTable", 2 ); mGlslProg->uniform( "uTextureDepthToColorTable", 3 ); gl::draw( mVboMesh ); if ( mTextureColor ) { mTextureColor->unbind(); } if ( mTextureDepth ) { mTextureDepth->unbind(); } if ( mTextureDepthToCameraTable ) { mTextureDepthToCameraTable->unbind(); } if ( mTextureDepthToColorTable ) { mTextureDepthToColorTable->unbind(); } mParams->draw(); }