void LineFollow::calibIRs(){
	static bool isInited=false;//So only init once
	if(isInited)return ;
	
	delay(1000);
	
	doCalibration(30,500);
	doCalibration(-30,800);
	doCalibration(30,500);
	
	delay(1000);
	isInited=true;
}
示例#2
0
/******************************************************************************
 * The draw function paints the textures onto the screen. It runs after update.
 *****************************************************************************/
void testApp::draw(){
	
	

	ofSetFullscreen(bFullscreen);

 //   if (bNewFrame){ //Apparently this causes flickering on some machines?

		/*********************************
		* IF CALIBRATING
		*********************************/
		if(bCalibration)
		{
			//Don't draw main interface
			bShowInterface = false;

			doCalibration();
		}
		/********************************
		* IF SHOWING MAIN INTERFACE STUFF
		********************************/
		if(bDrawVideo && bShowInterface && !bFastMode)
		{
			ofSetColor(0xFFFFFF);	
			//Draw Everything
			background.draw(0, 0);

			//Draw arrows
			ofSetColor(187, 200, 203);
			ofFill();
			ofTriangle(680, 420, 680, 460, 700, 440);
			ofTriangle(70, 420, 70, 460, 50, 440);
			ofSetColor(255, 255, 0);
//			ofNoFill();
//			ofTriangle(70, 420, 70, 460, 50, 440);
			
			ofSetColor(0xFFFFFF);

			if(bGPUMode){
				drawGLTexture(40, 30, 320, 240, gpuSourceTex);
				//subtractFilter->drawOutputTexture(85, 392, 128, 96);
				drawGLTexture(85, 392, 128, 96, gpuBGTex);
				gaussVFilter->drawOutputTexture(235, 392, 128, 96); 
				subtractFilter2->drawOutputTexture(385, 392, 128, 96); 
				threshFilter->drawOutputTexture(535, 392, 128, 96);
				gpuReadBackImageGS.draw(385, 30, 320, 240);
			}
			else{
				if(bShowPressure)
					pressureMap.draw(40, 30, 320, 240);
				else
					grayImg.draw(40, 30, 320, 240);

				grayDiff.draw(385, 30, 320, 240);
				fiLearn.draw(85, 392, 128, 96);
				subtractBg.draw(235, 392, 128, 96);
				highpassImg.draw(385, 392, 128, 96);
				ampImg.draw(535, 392, 128, 96);
			}

			ofSetColor(0x000000);
			if(bShowPressure){bigvideo.drawString("Pressure Map", 140, 20);}
			else             {bigvideo.drawString("Source Image", 140, 20);}		
							  bigvideo.drawString("Tracked Image", 475, 20);	
			//Warped Box
//			if(bWarpImg)
//			warp_box.draw( 0, 0);
		} 


		/*********************************
		* IF NOT CALIBRATING
		*********************************/
		if(!bCalibration)
		{
			//Draw main interface
			bShowInterface = true;

			//Display Application information in bottom right
			string str = "Tracker FPS:     ";
			str+= ofToString(ofGetFrameRate(), 0)+"\n\n";

			if(bcamera)
			{
				string str2 = "Camera Res:     ";
				str2+= ofToString(vidGrabber.width, 0) + " x " + ofToString(vidGrabber.height, 0)  + "\n";
				string str4 = "Camera FPS:     ";
				str4+= ofToString(fps, 0)+"\n";
				ofSetColor(0xFFFFFF);
				sidebarTXT.drawString(str + str2 + str4, 740, 410);
			}
			else
			{
				string str2 = "Video Res:       ";
				str2+= ofToString(vidPlayer.width, 0) + " x " + ofToString(vidPlayer.height, 0)  + "\n";
				string str4 = "Video FPS:       ";
				str4+= ofToString(fps, 0)+"\n";
				ofSetColor(0xFFFFFF);
				sidebarTXT.drawString(str + str2 + str4, 740, 410);
			}


			//Draw PINK CIRCLE 'ON' LIGHT
			ofSetColor(255, 0, 255);
			ofFill();		
			ofCircle(20, 10, 5);
			ofNoFill();

			if(bTUIOMode)
			{	//Draw Port and IP to screen
				ofSetColor(0xffffff);
				char buf[256];
				sprintf(buf, "Sending TUIO messages to:\nHost: %s\nPort: %i", myTUIO.localHost, myTUIO.TUIOPort);
				sidebarTXT.drawString(buf, 740, 480);

				//Draw GREEN CIRCLE 'ON' LIGHT
				ofSetColor(0x00FF00);
				ofFill();		
				ofCircle(35, 10, 5);
				ofNoFill();
			}
		}
		
		
		if(bFlowing){	
//FLOW
	//ofFill();
	//ofSetColor(0x333333);
	//ofRect(100,100,320,240);
	/*ofSetColor(0xffffff);*/
		ofSetColor(0x00FF00);
	glPushMatrix();
		glTranslatef(385,30,0);
		opticalFlowLK.draw();
	glPopMatrix();	
ofSetColor(0xffffff);
	glPushMatrix();
		glTranslatef(45,35,0);
		opticalFlowBM.draw();
		glPopMatrix();
		}

		/*********************************
		* IF DRAWING BLOB OUTLINES
		*********************************/
		if(bShowInterface && !bFastMode)
		{
		//Find the blobs
			for(int i=0; i<contourFinder.nBlobs; i++)
			{
				//temp blob to rescale and draw on screen  
				ofxCvBlob drawBlob;
				drawBlob = contourFinder.blobs[i];

				if(bDrawOutlines)
				{
					//Get the contour (points) so they can be drawn
					for( int j=0; j<contourFinder.blobs[i].nPts; j++ )
					{
						drawBlob.pts[j].x = (320.0f/camWidth)  * (drawBlob.pts[j].x);
						drawBlob.pts[j].y = (240.0f/camHeight) * (drawBlob.pts[j].y);
					}
			
					//This adjusts the blob drawing for different cameras
					drawBlob.boundingRect.width  *= (320.0f/camWidth);
					drawBlob.boundingRect.height *= (240.0f/camHeight);
					drawBlob.boundingRect.x		 *= (320.0f/camWidth);;
					drawBlob.boundingRect.y		 *= (240.0f/camHeight);
					
					//Draw contours (outlines) on the tracked image
					//drawBlob.draw(385, 30);
					drawBlob.draw(40, 30);
				}

				//Show ID label;
				if(bShowLabels)
				{
					float xpos = drawBlob.centroid.x * (320.0f/camWidth);
					float ypos = drawBlob.centroid.y * (240.0f/camHeight);

					ofSetColor(0xCCFFCC);
					char idStr[1024];	
					sprintf(idStr, "id: %i",drawBlob.id);
					verdana.drawString(idStr, xpos + 365, ypos + drawBlob.boundingRect.height/2 + 45);			
				}
			}
			//ofSetColor(0xFFFFFF);
		}

		if(!bCalibration)
			gui->draw();
//	}

		
}