My team has a white ring light up at the shop, but no green one. This is the first year that we are trying to get vision targeting working, so I was planning on just using the 2013 vision sample program and tweaking as little as possible. If we are using a white ring light, would changing the value of VALUE (HSV) so that it is a very high number, say 240-250, work to track the white rectangle that we will get? As I understood the vision processing paper, white is simply a very high value number.
I have also done some extensive testing on Microsoft Word with colored squares to see what range of values will return a “white” square. 240 - 250 is all pretty white.
Or, would we be better off getting some green LEDs and using those?
HSL is a 3D color space as is RGB. RGB are generally viewed as a cube with a red, a blue, and a green axis. That puts black in the 0,0,0 corner and white in the 255,255,255 corner.
HSL has one circular component and two linear components, so it is pretty naturally thought of as a cylinder. But, the issue is that not all of those HSL values are really unique. If L is zero, the color is black, it doesn’t matter what hue is, and saturation means nothing if there is nothing to blend with but black. So another visual that is more compact is to think of it as a snow cone with another paper cone put on top. This is really just taking all of the similar colors and shrinking them inwards so that the cylinder has been deformed to have a peaked top and bottom.
Anyway, when L is at an extreme, the other values really don’t matter. Thus white light can have any hue, is by definition going to have a very low saturation, and will have an L that is almost 255. So, it is possible to use HSL to threshold, but since you really only care about L, it is generally faster and clearer to extract the L plane and do a monochrome threshold. It is even faster to ask the camera to simply give you a monochrome image, and you may have luck with that.
As for whether this is better than a green light, I’d say that it isn’t better, but it may be good enough. If you have the time, I’d encourage you to experiment with both.
In the code, there is something about the threshhold, in this line (This is what we changed it to to get a white light working):
Threshold threshold(0, 255, 0, 255, 240, 255);
Those numbers are MinHue, MaxHue, MinSaturation, MaxSaturation, MinLuminosity, MaxLuminosity. So just make the Hue and Sat. from 0-255, and the Lightness from 240-255.
How i went about solving this problem is first converting the image to gray scale, so HSV has no importance. With OpenCV, the computer vision library I use, the part involving HSV can add to processing time, which is unfortunate for our frisbee tracker. When it is converted to gray scale, you can apply a threshold, and it will be a 1 channel deep threshold since gray scale is a 1 channel array, unlike hsv or rbg (which has 3 channels of arrays). You are correct in saying that the square will have a high value, but it will also have a high pixel value in gray scale, and would reduce the amount of memory needed since hue and saturation will not be needed. This process is also the same with using IR, and any other colour, just a matter of thresholding. Best of luck from team 1706.
If you cannot get the camera to send a grayscale/monochrome image, then converting it to grayscale is the equivalent thing. This is the same as computing the V but not bothering with the H and S conversions. If you have enough contrast to find the shape, this is a good approach. The vast majority of industrial machine cameras are still monochrome.