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:


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
", par.center_mass_x_normalized, par.center_mass_y_normalized);
				dashboard.Printf("color as percent of image: %f
", par.particleToImagePercent);
			}
			else
			{
				dashboard.Printf("No color found :(
");
			}
			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]