Inaugural post!!
I'm a mentor for team 2338. I apologize for somewhat a lengthy post, but figure this might help teams that are having camera issues as I noted a couple of teams (including us) were on the field for camera calibration this past weekend.
After endless number of hours troubleshooting the camera code, I think we have found a potential bug in the camera software that is causing the green color detection to be flaky.
I think the issues resides in the code where it takes an RGB image and convert it to HSL for color detection. At times, the resulting HSL image will output a red/pink hue value that is in the single digits (normal red/pink hue is supposed to be from 220 to 255, but the converted HSL image will indicate some red/pink pixels are in the range of 1 to 5. This usually occurs when the target hue value is near the higher value of 255. The only conclusion that I can make is that there is a bug in the conversion code where it is not converting the red hue range properly. I believe that this bug is causing pink detection to fail at times. When pink fails, green natually also fails.
Note that this was communicated to a NI rep in the Wisconsin regional (named Chris, I believe).
Now on to camera calibration to reduce “washed out” targets.
Not to say that this will work all the time, but I think our camera was tracking much better after following this process. Note that a lot of this information was gathered here from the likes of Greg and couple of other helpful folks:
- Start the camera by setting white balance and exposure to “auto”.
- Performing a white balance calibration and set white balance to “hold current”
- This can be done by covering the lens for about 5 seconds and then placing a white sheet of paper in front of the camera after uncovering the lens. Wait for it to self adjust to the correct level and then set to “hold current”.
- Perform an exposure adjustment:
- This is where I tend to disagree with Greg on keeping auto exposure. We find it to work much better if we fix the exposure. The reason being that out camera is aimed relatively high, and it will catch some of the lamps that are used to light up the field. When and if that happens, the exposure time tends to reduce and it is those times that we obtain a correct target exposure. If the camera is aimed at an area where there is relatively low back lighting, the camera will over expose. Causing a washed out target to show up. To set the exposure, we aim the camera towards some lights to force exposure time down. While at the same time, we place a target in front of the camera to check exposure. When you can clearly see the distinctive colors in the target with lights in the background without much glare, set the exposure to “hold current”. Any additional glare can be reduced by setting a lower brightness level. The beauty of fixing the exposure is that the lighting is relatively uniform from the various angles, thus a fixed exposure will enable target detection no matter what the background lighting conditions are. Now check the HSL values for the 2 target colors and record them. Double check for proper camera exposure by aiming the camera (with a target in view) towards other areas of the field (check with and without back lighting).
After these adjustments, our camera was able to track the target properly. (Ignore the fact that we shot into our own alliance’s trailer in one of the matches…we were still troubleshooting our autonomous code

. I forgot which match, but one of our later seeding matches this past weekend we were tracking properly and scored in autonomous (into the correct trailer this time).
That should be it…hope this will help the teams having camera issues.
Best of luck!!