As an honor’s project for my Embedded System class, I was tasked with using an Arduino to track an object/line with a camera sensor. I worked for a while trying to achieve this goal, but found the Arduino to be very lacking when it comes to image processing. Instead I was able to use a USB camera and OpenCV to detect an object and then transmit enough information for the Arduino to follow the object. I haven’t made a video of the project in operation, but here are two images to show you what I’ve done.
The first image shows the camera view with an overlay of the object’s center position. The second image is the first image with an HSV threshold applied. To get the object’s center position, I used some built-in functions dealing with image moments. The center position is processed and the computer determines the direction the robot must move and then sends this to the Arduino through the serial port. The Arduino then controls the motors in response to these messages.
The robot follows the object fairly well and responds as if it is a curious animal that is afraid of the object getting too close. This project has taught me that image processing is much more complex and should never be attempted on the Arduino.