View Single Post
  #1   Spotlight this post!  
Unread 25-01-2009, 15:28
NinJA999's Avatar
NinJA999 NinJA999 is offline
Chipmunk NinJA
AKA: Nick Aldwin
FRC #0811 (Team 811)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Windham, NH
Posts: 45
NinJA999 will become famous soon enough
Send a message via AIM to NinJA999
Camera Tracking not working?

Hi,

We've been working on getting our camera to work for tracking the colored fabrics. We have tried code from several different threads, the manual, and the two color tracking demo. Our current Autonomous code is this:
Code:
void Autonomous(void)
	{
		Dashboard &dashboard = m_ds->GetDashboardPacker();

		Wait(2.0);
		PCVideoServer pc;
		while(IsAutonomous())
		{
			TrackingThreshold tdata;
			tdata.hue.minValue=220;//229
			tdata.hue.maxValue=255;
			tdata.saturation.minValue=75;//121
			tdata.saturation.maxValue=255;//182
			tdata.luminance.minValue=85;//95
			tdata.luminance.maxValue=255;//141
			ParticleAnalysisReport par;
			
			if(FindColor(IMAQ_HSL, &tdata.hue, &tdata.saturation, &tdata.luminance, &par))
			{
				dashboard.Printf("color found at x=%i, y=%i\n", par.center_mass_x_normalized, par.center_mass_y_normalized);
				dashboard.Printf("color as percent of image: %f\n", par.particleToImagePercent);
			}
			else
			{
				dashboard.Printf("No color found :(\n");
			}
			UpdateDashboard();
		}
	}
Currently, we are attempting to find pink. Do you think it is a problem with our values for HSL, or is it our code itself?

[EDIT]
We figured it out. Apparently, we had two problems in our code:
1. The code was running too fast for the image processor. We added a Wait(1.0/60); to the end of the loop, so it runs at a max rate of 60 executions per second (twice our fps). That allowed us to see that we were finding the color, but it always said it was x=0, y=0. That's when we found out that...
2. There was an error in the C/C++ Programming Guide that we took some of our code from. par.center_mass_x_normalized and par.center_mass_x_normalized are doubles. "%d" is for integers. We changed the printf to say "%f" and it works perfectly.
[/EDIT]
__________________
Team 811 (Nashua, NH) - Mentor

Previously Team Lead & Programming Lead

Last edited by NinJA999 : 25-01-2009 at 17:06.
Reply With Quote