How to recognise an object with camera

Hello, Im new to FRC java development but with a fewer years with Java Development…
Me and my team build a simple robot (tank drive), and every thing work great, we also connect the Microsoft Lifecam to the RoboRio, and we can see image on the smart dashboard from the camera…

I want to start learning how to recognise an objects at the front of the robot (for example a yellow big box, and to stop at front of him, but if the box is coloured blue so it will keep driving straight…)

How can I do that?

We’ve used the OpenCV library in the past. It has a number of utilities to do vision processing and identify/localize features. I was not involved in the programming, so I do not know any of the details. Here’s the link to our github repository we used in 2013 and 2014 to find goals; we had implemented it on a raspberry pi, as in 2012 our goal finder bogged the cRIO down too much between network traffic and CPU time. I understand that the latest raspberry pi offerings start at $5, and are more powerful than the ones we used in 2013 and 2014. You can connect the USB camera directly to the pi, and only send back the coordinates and key attributes of the goal/object over the network.

If you want an image to help drive, you can also so some vision processing to reduce the package being sent back. I had good luck with the “Canny Edge Detector” algorithm in ImageMagick when I played around with it last year; it sent back a useful schematic image in a very small number of kilobytes. I see that OpenCV does have the Canny algorithm as well.

I believe all three languages come with example vision programs, so you can check out the code there. The ScreenStepsLive documentation from 2014 also has some explanation: http://wpilib.screenstepslive.com/s/3120/m/8731

If your team still has the license code for RoboRealm that was given out in the KoP last year, I would highly recommend downloading it. At the very least, it’s a great way to rapidly experiment with a bunch of different vision algorithms to give you a sense of when each is useful. You can use RoboRealm as the final vision solution, or you can convert the algorithm to something else (like NI Vision or OpenCV).