WPILib & Camera colors & data

After countless times of me waving bright lights at the camera, I think I’ve finally got the camera to follow it. (After having it run away from lights…) However, I’m still confused when it comes to WPILib’s CameraInitializationData structure… so many members. The three that most concern me are the first six, which WPILib’s API.h labels as:

unsigned char redMin, redMax, greenMin, greenMax, blueMin, blueMax;

The WPILib website has this line from their “tracking FRC green target” sample:

{ 85,115,15,17,100,145,0,1,0,1,0,0,128,128,128,1,16,8,5,30,15,5 }

Now, I’m reading this as:
red = 85 to 115
green = 15 to 17
blue = 100 to 145
I’m assuming that the topmost range for the min/max is 255. (is this correct?) Using that, that seems to be a dark purple. Certainly not green. Taking raw pictures with the camera also seems to say the only the outer fridges of the light are green - the center is pure white (over expose?). (We haven’t taken pictures from a distance… we just got the lights wired in a way that they’re actually mobile…) The problem is that nothing I use seems to work. That array does. Why?

Also, what are all the pan and tilt values near the end of the initialization array? Should the camera be sending back pan/tilt values in the TPacket? (Are these leftovers from a previous year when the servos were plugged into the camera itself?) (I seem to get 127 or 128 (can’t remember) all the time, or 0 if there’s a connection failure.) I’m currently using mx and my to compute a servo offset.

Thanks in advance for all the help… I hope I haven’t missed something somewhere. (It took me a while to find the lens on the camera…)

The “dark purple” is what you get if you think of the values as RGB and fail to interpret them in the YCrCb color space instead. The camera picks up on the green glowing color wonderfully if it’s switched to YCrCb, which is what the provided code does.

By the way, the maximum reported color value from the camera is 240. In RGB mode, a sufficiently bright light of any color – including the green target light – saturates the camera at 240,240,240.

Didn’t think of that, and that would explain it. However, the 7th element in the array is called “YCrCb” and is set to 0 by the example code - does 0 mean use YCrCb? That’d seem a bit backwards. Does 1 mean RGB? continues to read Wikipedia article on YCbCr

Our team was trying to track a yellow Poof ball at first, as we were having trouble with the lights. Now that we have light, I suppose I’ll stick with the example, since it works. (Can’t argue with working stuff…) I’d still like to understand.

Thanks again!