Vision is a major idea this year, however it may be wise to wait until next year. I’m not saying that it’s impossible, especially if you have a large and powerful programming team, but it may be smarter to spend your time on getting encoders perfected than trying to create a sort-of-working vision program, however, if you are interested in attempting, the best way to do it is to acquire a powerful processing board. The one thing you should never do is use the RoboRio for processing. FIRST added support for OpenCV, the vision processing library, on the RIO, but the RIO is far too slow for it to work, in fact the Raspberry Pi has proven almost too slow for vision tracking. However, as you gain power you lose ease of use. A NVidia graphics chip will carry vision processing to an unnecessary level, but it is a pain to program and communicate with the RIO, and even worse to power on the robot.
The first thing you are going to want to do is choose your board. Consider the languages that OpenCV is available for. The most support is clearly for C++, it’s native language, followed by Python. Java is new, and lacks support, however the library is similar across languages, so it may be possible, but copy-paste solutions become impossible. Once you choose a board, a programming language will be apparent. If it is viable to use C++, but if not you can make Python or Java work. Finally you need to install OpenCV onto your board. Installation depends on the board you choose.
Note: You need to use an LED mounted very close or around the camera for the use of the retro-reflective tape.
Now you have to start programming. Research HSV and thresholding. Once you understand that create a simple vision program that uses sliders to change HSV Values to get the optimal color reading. Now create your program based on the Sample Code in the OpenCV library. I cannot give you all of the code, as that’s pretty anti-FIRST, but I will tell you the program flow you need.
Pull Image-> Filter to HSV -> Filter out to Threshold -> FindContours -> Convert to Rectangles using lots of fun stuff (Polygons are important), -> Assign polygons to an array for pulling of corners -> Do math using those corners to get the information you need -> Send that information back to the RIO over PyNetworkTables.
All of this took me 3 months to figure out and get working, so I hope this gives you a head start, and I hope to see you at comp
-Max DeVos
KING TeC 2169