コード例 #1
0
ファイル: FaceVFXApp.cpp プロジェクト: OpenAVR/FaceVFX
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;
}
コード例 #2
0
void DXTencoderApp::update()
{
    
    bool hasNewFrame = false;
        
    if( mMovie && isStarted){
        
        //scaledSize.x= 196;
        scaledSize.x=mMovie->getWidth();

        
        hasNewFrame = mMovie->stepForward();
        
        
        scaledSize.y = mMovie->getSize().y * scaledSize.x / mMovie->getSize().x;

        
        correctedSize = scaledSize;
        correctedSize.y = correctedSize.y  - (correctedSize.y % 4);

        
        mDxtCreator.w = correctedSize.x;
        mDxtCreator.h = correctedSize.y;
        
        
        mSurface = mMovie->getSurface();
        if (mSurface) {

            if (currentFrame == 0) {
                movieLoadedSetParameters();
                isStarted = true;
            }
            
            if(currentFrame  < endFrame){
                                
                
                scaledSurface = ip::resizeCopy(*mSurface, Area(0, 0, mMovie->getSize().x, mMovie->getSize().y), scaledSize);
                
//                // make a copy but crop some pixels.
                correctedSurface = Surface(correctedSize.x, correctedSize.y, true);
                correctedSurface.copyFrom(scaledSurface, Area(0,0,correctedSize.x,correctedSize.y));

                mDxtCreator.writePixels(correctedSurface.getData(),currentFrame);
                currentFrame++;
            }else if(currentFrame == endFrame){
                mDxtCreator.close();
                mMovie->stop();
                isStarted = false;


            }
            
            
            
        }    }
}
コード例 #3
0
void QTimeIterApp::update()
{
	if( mMovie )
		mSurface = mMovie->getSurface();
}
コード例 #4
0
ファイル: cApp.cpp プロジェクト: stdmtb/uf_0.9.0
void cApp::update(){

    if( !bStart ) return;
    
    parts.clear();
    vbo.resetAll();
    
    if(0){
        if(!mov){
            fs::path path = mt::getAssetPath()/"sim"/"supernova"/"2d"/"mov"/"7.1_simu_5_c_linear_rect.mov";
            mov = qtime::MovieSurface::create( path );
            mov->seekToStart();
            mov->play();
        }
        mov->seekToFrame(frame);
        sur = mov->getSurface();
    }else{
        fs::path path = mt::getAssetPath()/"sim"/"supernova"/"2d"/"img"/"simu_1"/"c"/"polar"/"linear"/"simu_1_idump100_c_linear_polar.png";
        //fs::path path = mt::getAssetPath()/"sim"/"supernova"/"2d"/"img"/"test.png";
        sur = Surface8u::create( loadImage(path) );
    }
    
    if(sur){
        frame++;

        Surface8u::Iter itr = sur->getIter();
        while (itr.line()) {
            while (itr.pixel()) {
                
                vec2 pos = itr.getPos();
                pos.x -= itr.getWidth()/2;
                pos.y -= itr.getHeight()/2;

                float val = itr.r()/255.0f;
                float min = 0.4f;
                float max = 0.99999f;
                if( min < val && val < max ){
                    float gray = lmap(val, min, max, 0.3f, 1.0f);
                    Particle pt;
                    pt.pos = vec3(pos.x, pos.y, gray*200.0f) + mPln.dfBm(frame*0.0001f, pos.x*0.001f, pos.y*0.001f)*0.3f;
                    pt.dist = glm::distance(eye, pt.pos);
                    pt.val = val;
                    
                    //pt.col = Colorf(gray,gray,gray);
                    pt.col = mt::getHeatmap( gray );
                    parts.push_back(pt);
                    
                    if(0){
                        for( int k=0; k<round(pt.pos.z); k+=5){
                            vec3 pp = pt.pos;
                            pp.z = k;
                            Particle pt;
                            pt.pos = pp + mPln.dfBm(frame*0.0001f, pos.x*0.001f, pos.y*0.001f)*0.3f;
                            pt.dist = glm::distance(eye, pp);
                            pt.val = val;
                            //pt.col = Colorf(gray,gray,gray);
                            pt.col = mt::getHeatmap( gray );
                            pt.col.a = k*0.01;
                            parts.push_back(pt);
                        }
                    }
                }
            }
        }
        
        std::sort(parts.begin(), parts.end(), [](const Particle&lp, const Particle&rp){ return lp.dist > rp.dist; } );
        
        for( int i=0; i<parts.size(); i++){
            vbo.addPos(parts[i].pos);
            vbo.addCol(parts[i].col);
        }
        vbo.init(GL_POINTS);
    }
}