![]() |
537's Hot Goal Detection Code
537 would like to share its hot goal detection code with you. We are out of the competition now but the robot was able to pick the hot goal correctly in 13 of our 15 matches at Wisconsin this past weekend.
Instead of trying to track the vision targets, we pointed the camera at the goal itself and counted the number of yellow pixels on the screen. We did this after we drove forward, so there was no chance of mixing up left and right. All we do is a simple HSL threshold and then count the number of 1 pixels in the binary image. Check it out below: Code:
#define YELLOW_PIXEL_THRESHOLD 1500To get this code working for your team you will need to adjust your camera settings and play with the threshold values. We called the CameraInitialize method in RobotInit() so that there would be no delay in getting good images. Then we call start and stop at the beginning and end of autonomous, and IsHotGoal() throughout. This code was copied from when we were trying to detect red (that's the LED strip we had) but can pretty much be calibrated for any color. The nice thing is there isn't a whole lot of other yellow to get confused with. The white balance setting is especially important and in fact our detection was more of a green hue, but it worked. Hopefully this will help some of you! |
| All times are GMT -5. The time now is 12:12. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi