コード例 #1
0
void DXTencoderApp::loadMovieFile( const fs::path &moviePath )
{
    try {
        mMovie = qtime::MovieSurface::create( moviePath );
        
        console() << "Dimensions:" << mMovie->getWidth() << " x " << mMovie->getHeight() << std::endl;
        console() << "Duration:  " << mMovie->getDuration() << " seconds" << std::endl;
        console() << "Frames:    " << mMovie->getNumFrames() << std::endl;
        console() << "Framerate: " << mMovie->getFramerate() << std::endl;
        console() << "Has audio: " << mMovie->hasAudio() << " Has visuals: " << mMovie->hasVisuals() << std::endl;

        mMovie->setLoop( false );
        mMovie->seekToStart();
        //mMovie->play();
        isStarted = true;
        currentFrame = 0;

        
        std::string basePath = moviePath.parent_path().string();
        string newFilename =   moviePath.filename().string();
        strReplace(newFilename, moviePath.extension().string(), ".dxt5");
                                                  
        mDxtCreator.open(basePath + "/" + newFilename);

    }
    catch( ci::Exception &exc ) {
        console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
    }
    
    
    
}
コード例 #2
0
void QTimeIterApp::loadMovieFile( const fs::path &moviePath )
{
	try {
		mMovie = qtime::MovieSurface::create( moviePath );

		console() << "Dimensions:" << mMovie->getWidth() << " x " << mMovie->getHeight() << std::endl;
		console() << "Duration:  " << mMovie->getDuration() << " seconds" << std::endl;
		console() << "Frames:    " << mMovie->getNumFrames() << std::endl;
		console() << "Framerate: " << mMovie->getFramerate() << std::endl;
		console() << "Has audio: " << mMovie->hasAudio() << " Has visuals: " << mMovie->hasVisuals() << std::endl;
		mMovie->setLoop( true, true );
		mMovie->seekToStart();
		mMovie->play();
	}
	catch( ci::Exception &exc ) {
		console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
	}	
}
コード例 #3
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;


            }
            
            
            
        }    }
}
コード例 #4
0
void DXTencoderApp::draw()
{
    gl::clear( Color( 0, 1.0, 1.0 ) );
    gl::color(1, 1, 1, 1);

    gl::enableAlphaBlending( true );
    
    if( ( ! mMovie ) || ( ! mSurface ) || !isStarted ){

        gl::color(0, 0, 0, 1);

        gl::color(1, 1, 1, 1);
        mTextureFont->drawString("DRAG VIDEO FILE IN THIS WINDOW", getWindowCenter() - vec2(210,0));

        return;
    }
    
    if(scaledSurface.getWidth() < getWindowWidth()){
        gl::draw( gl::Texture::create( scaledSurface ),vec2(0,100) );
        gl::draw( gl::Texture::create( correctedSurface ),vec2(scaledSize.x + 10,100) );
    }else{
        gl::color(1, 1, 1, 1);
        mTextureFont->drawString("NO PREVIEW VIDEO IS TO LARGE", getWindowCenter() - vec2(210,0));

    }

    gl::color(0, 0, 0, 0.6);
    gl::drawSolidRect(Rectf(0,0,getWindowWidth(),100));

    gl::color(1, 1, 1, 1);
    mTextureFont->drawString("ENCODING FRAME: " + toString(currentFrame) + " / " + toString(endFrame), ivec2(20,35));
    
    gl::drawString("original size: " + toString(mMovie->getSize()) , ivec2(20,70));
    gl::drawString("scaled size: " + toString(scaledSize) , ivec2(20,85));
    gl::drawString("corrected %4 size: " + toString(correctedSize) , ivec2(scaledSize.x + 20,85));

    gl::color(1, 1, 1, 1);
    float width = lmap(currentFrame, 0, endFrame, 0, getWindowWidth());
    gl::drawSolidRect(Rectf(0,45,width ,60));
    

    gl::color(1, 1.0, 1.0, 1.0);

    float lineHeight = 100 + correctedSize.y;
    gl::drawLine(vec2(0,lineHeight), vec2(getWindowWidth(),lineHeight));

    gl::color(1, .4, .7, 0.8);

    gl::drawLine(vec2(0,100 + 256), vec2(getWindowWidth(),100 + 256));
    gl::drawString("screen bottom " , ivec2(scaledSize.x +correctedSize.x + 20,90 + 256 ), Color(1,0.4,0.8));
    
}
コード例 #5
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;
}
コード例 #6
0
void QTimeIterApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'f' ) {
		setFullScreen( ! isFullScreen() );
	}
	else if( event.getChar() == 'o' ) {
		fs::path moviePath = getOpenFilePath();
		if( ! moviePath.empty() )
			loadMovieFile( moviePath );
	}
	
	// these keys only make sense if there is an active movie
	if( mMovie ) {
		if( event.getCode() == KeyEvent::KEY_LEFT ) {
			mMovie->stepBackward();
		}
		if( event.getCode() == KeyEvent::KEY_RIGHT ) {
			mMovie->stepForward();
		}
		else if( event.getChar() == 's' ) {
			if( mSurface ) {
				fs::path savePath = getSaveFilePath();
				if( ! savePath.empty() ) {
					writeImage( savePath, *mSurface );
				}
			}
		}
		else if( event.getChar() == 'm' ) {
			// jump to the middle frame
			mMovie->seekToTime( mMovie->getDuration() / 2 );
		}
		else if( event.getChar() == ' ' ) {
			if( mMovie->isPlaying() )
				mMovie->stop();
			else
				mMovie->play();
		}
	}
}
コード例 #7
0
void QTimeIterApp::update()
{
	if( mMovie )
		mSurface = mMovie->getSurface();
}
コード例 #8
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);
    }
}
コード例 #9
0
void DXTencoderApp::movieLoadedSetParameters(){
    endFrame = mMovie->getNumFrames();
}