Colour-based object tracking with Raspberry Pi
This robot uses a Raspberry Pi 3 and one of our cameras to detect the colour of the objects it drives past. It’s trained to follow objects of one specific colour.

Samiya Farooquee from Integral University in Lucknow, India gleefully posted on LinkedIn that she’d just submitted her final year project. When we noticed it was Raspberry Pi-powered, we got in touch to learn more about how she built it and what she aimed to achieve with the project.
She worked with Shafat Insha and Midhat Munira to develop a smart colour-based object tracking system, using OpenCV and Raspberry Pi 3. The autonomous Smart Object Tracking Robot can detect and track objects of a specific colour in real time.
The design, development, and technical details of the project are all available on Samiya’s GitHub, but stick with us for a breezier overview.
Hardware
- Raspberry Pi 3 Model B
- Raspberry Pi Camera Module 2
- Two DC motors (one for each wheel)
- Motor driver add-on board (lets Raspberry Pi control the DC motors in charge of the wheels)
- Li-Po battery (powers the Pi and the motors)
Software
- OpenCV (computer vision library)
- VNC Viewer (for remote operation of the robot, in case you need to take over)


How does it work?
The Raspberry Pi Camera Module captures live video frames. The onboard Raspberry Pi 3 then processes these frames using OpenCV in real time as the robot drives around.
The robot’s wheel motors are controlled via the Raspberry Pi’s GPIO, and the device reacts autonomously to objects detected in the camera’s field of view. It is programmed (in Python) to follow, turn, or stop based on the position, size, and colour of the objects it detects.
For example, if the robot’s camera sees an object of the colour it is following, it will activate the motor driver board and move towards the object.
Colour tracking
For this project, the team chose to use the HSV colour space to give their robot its colour differentiation powers. HSV stands for hue, saturation, and value. It’s closer to the way humans perceive colour than the more familiar RGB and CMYK spaces, which rely on primary colours.
In this instance, the robot is trained to track and follow only yellow objects. The code can be adapted to track objects of different colours. Tracking shades of brown could be useful if your robot was an outdoor pet and you didn’t want it rolling through animal poo, for example. Or you could have it avoid the colour green if you wanted it to stick to paths through grassy areas. Not sure why I’m so focused on animal poo in grass. Let’s move on.
Aspirations and thanks
The team’s aim was to highlight the potential of robotics and computer vision in industrial applications. They’ve just graduated, but they have left the robot in their university lab to see how future students build on their ideas.

I also couldn’t turn down a heartfelt request to shout out to Mohd Zaid from Integral University, whom the team called their “guiding star and exceptional mentor”.
We hope future students will let us know if they modify the Smart Object Tracking Robot.
4 comments
Jump to the comment form
Samiya Farooquee
Thankyou for publishing my work.
Raspberry Pi Staff Helen Lynn
You’re super welcome – this is a really neat project! Good luck with whatever comes next to you and the rest of the team :)
aisha qazi
@Samiya Farooquee
That’s wonderful news! Congratulations on getting your project published! I’m so proud of your skills and hard work. Keep reaching for the stars!!
Samiya Farooquee
Thankyou so much for the support and appreciation