示例#1
0
/**
 * Compute only curve from selection data (averages,histograms buffer and selection buffer)
 * @param clipSrc	source of the plugin
 * @param time	current time
 * @param renderScale	current renderScale
 */
void OverlayData::computeCurveFromSelectionData( OFX::Clip* clipSrc, const OfxTime time, const OfxPointD& renderScale)
{
	_isComputing = true;

	resetCurvesFromSelectionData();
	
	if( ! clipSrc->isConnected() )
	{	
		_isComputing = false;
		return;
	}
	boost::scoped_ptr<OFX::Image> src( clipSrc->fetchImage(_currentTime, clipSrc->getCanonicalRod(_currentTime)) );	//scoped pointer of current source clip

	// Compatibility tests
	if( !src.get() ) // source isn't accessible
	{
		_isComputing = false;
		std::cout << "src is not accessible" << std::endl;
		return;
	}

	if( src->getRowBytes() == 0 )//if source is wrong
	{
		BOOST_THROW_EXCEPTION( exception::WrongRowBytes() );
	}
	OfxRectI srcPixelRod = clipSrc->getPixelRod( _currentTime, renderScale ); //get current RoD
	if( (clipSrc->getPixelDepth() != OFX::eBitDepthFloat) ||
		(!clipSrc->getPixelComponents()) )
	{
		BOOST_THROW_EXCEPTION( exception::Unsupported()	<< exception::user() + "Can't compute histogram data with the actual input clip format." );
        return;
	}

	if( srcPixelRod != src->getBounds() )
	{
		// the host does bad things !
		// remove overlay... but do not crash.
		TUTTLE_COUT_WARNING( "Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")." );
		return;
	}
	
	// Compute if source is OK
	SView srcView = tuttle::plugin::getView<SView>( src.get(), srcPixelRod );	// get current view from source clip
	
	OfxPointI imgSize;
	imgSize.x = srcView.width();
	imgSize.y = srcView.height();
	
	if( isImageSizeModified( imgSize ) )
	{
		clearAll( imgSize );
	}
	//Compute histogram buffer
	Pixel_compute_histograms funct( _imgBool,_curveFromSelection, true);			//functor declaration
	terry::algorithm::transform_pixels( srcView, funct );		//(USED functor reference)
	
	this->correctHistogramBufferData(_curveFromSelection);				//correct Histogram data to make up for discretization (average)
}
示例#2
0
/*
 * Copy RGB channels of the clip source into a buffer
 */
int CloudPointData::generateAllPointsVBOData(SView srcView)
{
	//compute buffer size
	int size = (int)(srcView.height()*srcView.width());	//return size : full image here

	//copy full image into buffer
	Pixel_copy funct( _imgCopy );						//functor declaration	
	//treatment
	terry::algorithm::transform_pixels( srcView, funct );		//transform pixel did with functor reference
	return size;
}
示例#3
0
/*
 * Copy discretization RGB channels of the clip source into a buffer
 */
int CloudPointData::generateDiscretizedVBOData(SView srcView, const int& discretizationStep )
{
	//compute buffer size
	int size = (int)(srcView.height()*srcView.width());						//return size : full image here

	//Create and use functor to get discretize data  (functor with template)
	Pixel_copy_discretization<SPixel> funct(_imgCopy,discretizationStep);	//functor declaration	
	terry::algorithm::transform_pixels( srcView, funct);							//with functor reference
	funct.convertSetDataToVectorData();										//copy functor data to _imgCopy data
	size = _imgCopy.size();													//change size
	return size;
}
示例#4
0
/**
 * Update selection areas buffer to selection histograms overlay
 * @param args needed to have current time
 */
void OverlayData::computeHistogramBufferData( HistogramBufferData& data, SView& srcView, const OfxTime time, const bool isSelection)
{
	data._step = _vNbStep;					//prepare HistogramBuffer structure
	
	BOOST_ASSERT( _imgBool.shape()[0] == _size.y );
	BOOST_ASSERT( _imgBool.shape()[1] == _size.x );
	BOOST_ASSERT( srcView.width() == _size.x );
	BOOST_ASSERT( srcView.height() == _size.y );
	
	Pixel_compute_histograms funct( _imgBool, data, isSelection );			//functor declaration
	
	terry::algorithm::transform_pixels( srcView, funct );		//(USED functor reference)
	//boost::gil::for_each_pixel(srcView, funct);		(NOT USED)
	
	this->correctHistogramBufferData(data);				//correct Histogram data to make up for discretization (average)
}
示例#5
0
/**
 * Compute full data (averages,histograms buffer and selection buffer)
 * @param clipSrc	source of the plugin
 * @param time	current time
 * @param renderScale	current renderScale
 */
void OverlayData::computeFullData( OFX::Clip* clipSrc, const OfxTime time, const OfxPointD& renderScale, const bool selectionOnly )
{
	_isComputing = true;
	resetHistogramData();
	resetHistogramSelectionData();
	
	if( ! clipSrc->isConnected() )
	{	
		_isComputing = false;
		return;
	}
	
	//TUTTLE_TCOUT_INFOS;
	//TUTTLE_TCOUT_VAR( "computeHistogramBufferData - fetchImage " << time );
	boost::scoped_ptr<OFX::Image> src( clipSrc->fetchImage(time, clipSrc->getCanonicalRod(time)) );	//scoped pointer of current source clip
	//TUTTLE_TCOUT_INFOS;
	
	//TUTTLE_TCOUT_VAR( clipSrc->getPixelRod(time, renderScale) );
	//TUTTLE_TCOUT_VAR( clipSrc->getCanonicalRod(time, renderScale) );
	
	// Compatibility tests
	if( !src.get() ) // source isn't accessible
	{
		_isComputing = false;
		std::cout << "src is not accessible" << std::endl;
		return;
	}
	
//	TUTTLE_TCOUT_VAR( src->getBounds() );
//	TUTTLE_TCOUT_VAR( src->getRegionOfDefinition() );

	if( src->getRowBytes() == 0 )//if source is wrong
	{
		BOOST_THROW_EXCEPTION( exception::WrongRowBytes() );
	}
	OfxRectI srcPixelRod = clipSrc->getPixelRod( time, renderScale ); //get current RoD
	if( (clipSrc->getPixelDepth() != OFX::eBitDepthFloat) ||
		(!clipSrc->getPixelComponents()) )
	{
		BOOST_THROW_EXCEPTION( exception::Unsupported()	<< exception::user() + "Can't compute histogram data with the actual input clip format." );
        return;
	}
	
//	TUTTLE_TCOUT_INFOS;
//	BOOST_ASSERT( srcPixelRod == src->getBounds() );
	if( srcPixelRod != src->getBounds() )
	{
		// the host does bad things !
		// remove overlay... but do not crash.
		TUTTLE_COUT_WARNING( "Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")." );
		return;
	}
//	BOOST_ASSERT( srcPixelRod.x1 == src->getBounds().x1 );
//	BOOST_ASSERT( srcPixelRod.y1 == src->getBounds().y1 );
//	BOOST_ASSERT( srcPixelRod.x2 == src->getBounds().x2 );
//	BOOST_ASSERT( srcPixelRod.y2 == src->getBounds().y2 );
	
	// Compute if source is OK
	SView srcView = tuttle::plugin::getView<SView>( src.get(), srcPixelRod );	// get current view from source clip
	
	OfxPointI imgSize;
	imgSize.x = srcView.width();
	imgSize.y = srcView.height();
	
//	TUTTLE_TCOUT_INFOS;
	if( isImageSizeModified( imgSize ) )
	{
		//TUTTLE_TCOUT_INFOS;
		clearAll( imgSize );
	}
	
	//TUTTLE_TCOUT_INFOS;
	//Compute histogram buffer
	this->computeHistogramBufferData( _data, srcView, time);
	
	//TUTTLE_TCOUT_INFOS;
	//Compute selection histogram buffer
	this->computeHistogramBufferData( _selectionData, srcView, time, true );
	
	//TUTTLE_TCOUT_INFOS;
	//Compute averages
	this->computeAverages();
	_isComputing = false;
	
	_currentTime = time;
	//TUTTLE_TCOUT_INFOS;
}