Esempio n. 1
0
void EnhanceApp::mouseUp( MouseEvent event )
{
    if( mCtlDown )
    {
        int frame = int ( event.getPos().x / float(getWindowWidth()) * mMovie.getNumFrames() );

        mMovie.seekToFrame(  frame );
        mCtlDown = false;
        
    } else
    if( mAltLockDown)
    {
        mScale += mScaleOffset;
        mRot   +=   mRotOffset;
        mScaleOffset = mRotOffset = 0;
        mAltLockDown = false;
    } else
    {
        mAxisDisplay += mAxisOffset;
        mAxisOffset = Vec2f::zero();
    }
    



}
void ocvOpticalFlowApp::update()
{ 
    if( !mMovie ) return; 
    if (!mMovie.getSurface() ) return; 

	Surface surface = mMovie.getSurface();
    cv::Mat currentFrame( toOcv( Channel( surface ) ) );
    mTexture = gl::Texture( surface );
//    if( mPrevFrame.data ) 
//    {
//			if( mFeatures.empty() || getElapsedFrames() % 30 == 0 ) // pick new features once every 30 frames, or the first frame
//				chooseFeatures( mPrevFrame );
//			trackFeatures( currentFrame );
//    }
//    mPrevFrame = currentFrame;
    
    findPeople(currentFrame);
    
//	if( mCapture.checkNewFrame() ) {
//		Surface surface( mCapture.getSurface() );
//		mTexture = gl::Texture( surface );
//		cv::Mat currentFrame( toOcv( Channel( surface ) ) );
//		if( mPrevFrame.data ) {
//			if( mFeatures.empty() || getElapsedFrames() % 30 == 0 ) // pick new features once every 30 frames, or the first frame
//				chooseFeatures( mPrevFrame );
//			trackFeatures( currentFrame );
//		}
//		mPrevFrame = currentFrame;
//	}
    
}
void ocvOpticalFlowApp::loadMovieFile( const fs::path &moviePath )
{
	try {
		// load up the movie, set it to loop, and begin playing
    	mMovie = qtime::MovieSurface( moviePath );    
		mMovie.setLoop();
		mMovie.play();
		
		// create a texture for showing some info about the movie
		TextLayout infoText;
		infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
		infoText.setColor( Color::white() );
		infoText.addCenteredLine( moviePath.filename().string() );
		infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" );
		infoText.addLine( toString( mMovie.getDuration() ) + " seconds" );
		infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" );
		infoText.addLine( toString( mMovie.getFramerate() ) + " fps" );
		infoText.setBorder( 4, 2 );
		mInfoTexture = gl::Texture( infoText.render( true ) );
	}
	catch( ... ) {
		console() << "Unable to load the movie." << std::endl;
		mMovie.reset();
		mInfoTexture.reset();
	}
    
	mFrameTexture.reset();
}
void PostProcessingApp::update()
{
	// update movie texture if necessary
	if(mMovie) { 
		// get movie surface
		Surface surf = mMovie.getSurface();

		// copy surface into texture
		if(surf)
			mImage = gl::Texture( surf );

		// play next movie in directory when done
		if( mMovie.isDone() ) 
			playNext();
	}
}
Esempio n. 5
0
void EnhanceApp::update()
{
	if( mMovie ){
        mSurface = mMovie.getSurface();
        //cv::Mat input( toOcv( mSurface ) );

    }

}
Esempio n. 6
0
void EnhanceApp::mouseDrag( MouseEvent event )
{
    //Vec2f offset =  event.getPos() - mClickDown;
    
    Vec2f offset = ( mClickDown - event.getPos()) * .5;
    if( mCtlDown )
    {
        int frame = int ( event.getPos().x / float(getWindowWidth()) * mMovie.getNumFrames() );

        mMovie.seekToFrame(  frame );

    } else
    if( mAltLockDown)
    {
        mScaleOffset = offset.y / getWindowHeight();
        mRotOffset = offset.x;
    } else
    {
        mAxisOffset = offset;
    }
}
void PostProcessingApp::play( const fs::path &path ) 
{
	try {
		// try loading QuickTime movie
		mMovie = qtime::MovieSurface( path );
		mMovie.play();
	}
	catch(...) {}

	// keep track of file
	mFile = path;
}
Esempio n. 8
0
void EnhanceApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'f' ) {
		setFullScreen( ! isFullScreen() );
	}
	else if( event.getChar() == 'o' ) {
		string 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 ) {
				string 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();
		}
	}
}
Esempio n. 9
0
void EnhanceApp::loadMovieFile( const string &moviePath )
{
	try {
		mMovie = qtime::MovieSurface( 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() << "Alpha channel: " << mMovie.hasAlpha() << std::endl;		
		console() << "Has audio: " << mMovie.hasAudio() << " Has visuals: " << mMovie.hasVisuals() << std::endl;
		mMovie.setLoop( true, true );
        mMovie.setVolume(0);
		mMovie.seekToStart();
		mMovie.play();
	}
	catch( ... ) {
		console() << "Unable to load the movie." << std::endl;
	}	
}