示例#1
0
void VideoViewer::videoFrameCallback(const Video::FrameBuffer* frameBuffer)
{
    double timeStamp=saveVideoTimer.peekTime();

    /* Start a new value in the input triple buffer: */
    Images::RGBImage& image=videoFrames.startNewValue();

    /* Extract an RGB image from the provided frame buffer into the new value: */
    videoExtractor->extractRGB(frameBuffer,image.modifyPixels());

    /* Finish the new value in the triple buffer and wake up the main loop: */
    videoFrames.postNewValue();
    Vrui::requestUpdate();

    if(saveVideoFrames)
    {
        /* Create a filename for the new video frame: */
        char videoFrameFileName[1024];
        snprintf(videoFrameFileName,sizeof(videoFrameFileName),saveVideoFrameNameTemplate.c_str(),saveVideoNextFrameIndex);

        /* Save the new video frame: */
        Images::writeImageFile(image,videoFrameFileName);

        std::cout<<"Saving frame "<<videoFrameFileName<<" at "<<timeStamp*1000.0<<" ms"<<std::endl;

        /* Increment the frame counter: */
        ++saveVideoNextFrameIndex;
    }
}
示例#2
0
void VideoViewer::videoFrameCallback(const Video::FrameBuffer* frameBuffer)
	{
	/* Start a new value in the input triple buffer: */
	Images::RGBImage& image=videoFrames.startNewValue();
	
	/* Extract an RGB image from the provided frame buffer into the new value: */
	videoExtractor->extractRGB(frameBuffer,image.modifyPixels());
	
	/* Finish the new value in the triple buffer and wake up the main loop: */
	videoFrames.postNewValue();
	Vrui::requestUpdate();
	}
示例#3
0
void IMUTest::sampleCallback(const IMU::CalibratedSample& sample)
	{
	/* Store the calibrated sample: */
	samples.postNewValue(sample);
	
	/* Forward the calibrated sample to the 6-DOF tracker: */
	tracker->integrateSample(sample);
	
	#if 0
	
	static IMU::Vector accel(0.0,0.0,0.0);
	static IMU::Vector mag(0.0,0.0,0.0);
	const double w=1.0/1024.0;
	accel=accel*(1.0-w)+sample.accelerometer*w;
	mag=mag*(1.0-w)+sample.magnetometer*w;
	
	std::cout<<std::fixed;
	std::cout.precision(4);
	std::cout<<'\r';
	std::cout<<std::setw(10)<<accel.mag()<<", ";
	std::cout<<std::setw(10)<<mag.mag();
	std::cout<<std::flush;
	
	#endif
	
	#if 0
	
	std::cout<<std::fixed;
	std::cout.precision(4);
	std::cout<<'\r';
	for(int i=0;i<3;++i)
		std::cout<<std::setw(10)<<sample.magnetometer[i];
	std::cout<<std::flush;
	
	#endif
	
	Vrui::requestUpdate();
	}