Using the vision library to detect colored objects
Now that you have access to the OpenCV library, let's see what it can do.
Prepare for lift off
OpenCV and your webcam can track objects. This might be useful if you are building a system that needs to track and follow a colored ball. OpenCV makes this amazingly simple by providing some high-level libraries that can help you with this task. I'm going to do this in Python, as I find it much easier to work with than C. If you feel more comfortable in C, these instructions should be fairly easy to translate. Also, performance will be better if implemented in C, so you might create the initial capability in Python, and then finalize the code in C.
Engage thrusters
If you'd like, create a directory to hold your image-based work. From your home directory, create a directory named imageplay
by typing mkdir imageplay
. Then change directory to imageplay
by typing cd imageplay
.
Once there, let's bring over your camera.py
file as a starting point by typing...