What if your robot could “see” the world around it?
One of the most “eye-opening” things you can do with your robot project is to add vision. This is commonly called computer vision, and has recently been made affordable by the dropping cost of digital cameras (thanks to the massive amounts of smartphones being cranked out!).
Even if buying a camera for your Pi is now pretty cheap, integrating it into your software has always been intimidating. Sure, you can take pictures, bu can your robot figure out what they mean?
Raspberry Pi Computer Vision
OpenCV, or Open Source Computer Vision, is an open-source library of programming functions that handle computer vision. Translation: this software analyzes computer pictures and extracts data.
For example, let’s say you had a robotic arm (such as a APL Picker!) trying to watch different bouncing balls, and grab a particular color (yellow, for example). How does OpenCV give the Raspberry Pi computer vision?
Actually, no magic. The robot has a digital camera. The robot takes pictures of the balls it is thinking about grabbing constantly. That’s easy enough and pretty straightforward. But just because you have the picture, how do you figure out where the balls are in the picture?
OpenCV is a visual analysis program that will analyze the pictures and tell you where the balls are. OpenCV is super-powerful with a lot of tools for analyzing pictures. But in our example, we’re going to try to do something pretty simple: look for the round yellow blob (which is pretty much what a tennis ball will look like). OpenCV software has libraries that find the position of the center of the ball in a picture of a particular color. If you can calibrate the picture to the robotic arm, your Raspberry Pi is grabbing yellow tennis balls!
OpenCV Tutorial for BrickPi
Woolfel, a frequent contributor to our forums, has written a tutorial for getting started with vision analysis, OpenCV, the Raspberry Pi, and the BrickPi. He has kindly documented it all on his blog, and with a contribution to our Python libraries for the BrickPi.
Woolfel’s blog walks us through installation of OpenCV, updating the Github examples, and running them. He also does a great job of breaking down what each component of the project does, and how they talk to each other.
Installing OpenCV on the Raspberry Pi can take some time, but computer vision is a pretty compelling thing to add to your robot!
You can see Woolfel’s blog post on this here.
And check out the code in the Github project here.
More Projects From the Forums
Get help, show off, and see more projects for the Raspberry Pi, the BrickPi, and LEGOs like it in the forums.