Ejemplo n.º 1
0
void Tracker :: update ()
{
	if( ofGetFrameNum() == 2 )		// automatically set background after a delay.
	{
		updateBackground();
	}
	
	updateVideoGrabber();
	updateVideoPlayer();
	updateTracking();
	
	int blobsFound;
	blobsFound = updateContours();
	
	if( blobsFound > 0 )
	{
		blobUtil.downSampleBlobs( contourFinder.blobs, blobs, 40 );
		blobUtil.scaleBlobs( blobs, renderArea.width / (float)videoSmlRect.width, renderArea.height / (float)videoSmlRect.height );
//		blobUtil.translateBlobs( peeps, renderArea.x, renderArea.y );
	}
	else
	{
		blobs.clear();
	}
}
Ejemplo n.º 2
0
// -------------- update
void StencilWaves::update(){
    updateContours();
    updateWaveParameters();
    updateWaves();
    updateMeshes();
    updateFbos();
    updateMasks();
    updateRefract();
}
Ejemplo n.º 3
0
//--------------------------------------------------------------
void testApp::update()
{
	if( tileSaver.bGoTiling )
		return;
	
	if( bPause )
		return;
	
	updateCamera();
	
	if( cameraNewFrame )
	{
		if( bUseCamera )
		{
			updateCv( camera.getPixels() );
		}
		else
		{
			updateCv( video.getPixels() );
		}
	
		opticalField.update( cameraGrayImage.getPixels() );
		
		if( ofGetFrameNum() % 1 == 0 )
		{
			int blobs;
			blobs = updateContours();
			
			if( blobs > 0 )
			{
				clearShapes();
				parseShapes();
				scaleShapes();
		
				addCirclesToBox2d();
				
//				updateTriangles();
//				addTrianglesToBox2d();
			}
		}
	}
	
//	updateTriangleShapes();
	updateCirclePacker();
	updateCircles();
	
	box2d.update();
}
Ejemplo n.º 4
0
void testApp :: updateBlobs ()
{
	//-- remove old blobs.

	contourBlobs.clear();
	contourBlobsScaled.clear();
	contourBlobsSimplified.clear();
	
	//-- copy blobs and scale.
	
	float scale;
	scale = largeRect.width / (float)noiseRect.width;
	
	float xoff;
	xoff = largeRect.x;
	
	float yoff;
	yoff = largeRect.y;

	for( int i=0; i<noiseBandsTotal; i++ )
	{
		ofxCvGrayscaleImage& image = noiseBands[ i ];
		
		int numOfBlobs;
		numOfBlobs = updateContours( image );
		
		if( numOfBlobs == 0 )
			continue;
		
		ofColor c0 = colorPicker0.getColor();
		ofColor c1 = colorPicker1.getColor();
		ofColor c2 = interpolateColor( c0, c1, noiseBandCutoffs[ i ] );
		
		for( int j=0; j<numOfBlobs; j++ )
		{
			ofxCvBlob& blob = contourFinder.blobs[ j ];
			
			contourBlobs.push_back( Blob() );
			contourBlobsScaled.push_back( Blob() );
			contourBlobsSimplified.push_back( Blob() );
			
			copyBlob( blob, contourBlobs.back() );
			copyBlob( blob, contourBlobsScaled.back(), xoff, yoff, scale );
			copyBlob( blob, contourBlobsSimplified.back(), xoff, yoff, scale );
			
			contourBlobs.back().color			= c2;
			contourBlobsScaled.back().color		= c2;
			contourBlobsSimplified.back().color	= c2;

			if( contourSmoothScale > 0 )
			{
				contourUtil.smooth( contourBlobsSimplified.back().pts, contourSmoothScale, 1.0 );
			}

			if( contourSimplifyScale > 0 )
			{
				contourUtil.simplify( contourBlobsSimplified.back().pts, contourSimplifyScale );
			}
			
			if( contourSimplifyTolerance > 0 )
			{
				float tolerance = contourSimplifyTolerance;
				tolerance *= ( 1 / (float)contourBlobsSimplified.back().pts.size() );
				tolerance *= 100;
				
				vector<ofPoint> ptsOut;
				contourSimplify.simplify( contourBlobsSimplified.back().pts, ptsOut, tolerance );
				contourBlobsSimplified.back().pts = ptsOut;
			}
		}
	}
}