View Single Post
  #1   Spotlight this post!  
Unread 12-02-2009, 20:01
ellisk ellisk is offline
Registered User
FRC #1540
 
Join Date: Dec 2008
Location: Vancouver, WA
Posts: 41
ellisk is on a distinguished road
Image tracking code: colors off? (Lighting)

Hi all,
I'm writing code to lock onto targets, based off of the example two-color tracking code which used servos (but our robot uses a turret instead). It is very intermittent in finding the two colors, except when someone shines a bright light on it. Has anyone had any similar troubles/have any proposed solutions? Here's a bit of our code which I think is relevant:
Code:
	// Initialize particle analysis report
	memset(&par, 0, sizeof(par));
	
	// Image data for tracking - override default parameters if needed:
	// Make PINK the first color because GREEN is more susceptible to
	// hue variations due to lighting so may result in false positives
	
	// PINK
	sprintf(td1.name, "PINK");
	td1.hue.minValue = 220;
	td1.hue.maxValue = 255;
	td1.saturation.minValue = 75;
	td1.saturation.maxValue = 255;
	td1.luminance.minValue = 85;
	td1.luminance.maxValue = 255;
	
	// GREEN
	sprintf(td2.name, "GREEN");
	td2.hue.minValue = 55;
	td2.hue.maxValue = 125;
	td2.saturation.minValue = 58;
	td2.saturation.maxValue = 255;
	td2.luminance.minValue = 92;
	td2.luminance.maxValue = 255;
	
	// Set up debug output: 
	// DEBUG_OFF, DEBUG_MOSTLY_OFF, DEBUG_SCREEN_ONLY, DEBUG_FILE_ONLY, DEBUG_SCREEN_AND_FILE
	SetDebugFlag(DEBUG_SCREEN_ONLY);
	
	// Start the CameraTask
	// Possible values for resolution: k640x480, k320x240, k160x120
	if(StartCameraTask(framesPerSecond, 0, k160x120, ROT_0) == -1)
	{
		printf("Failed to spawn camera task; exiting. Error code %s", 
				GetVisionErrorText(GetLastVisionError()));
	}