This repository contains the source code for a visual object tracking project, designed to detect and track a specific object using a combination of computer vision and a physical 6 DOF robotic system.
The project is split into two main components:
- Vision System (Python): Handles object detection, tracking logic, and communication with the microcontroller.
- Robotic Control (c): Manages the motor contrl based on commands received from the vision system.
- The main Python script that uses OpenCV for video capture and image processing. It implements a PID controller to determine the motor speed and direction required to keep the target object centered. It communicates with the microcontroller over a serial port.
- The C code for a microcontroller (e.g., a PSoC or Arduino-based system). This code receives serial commands and translates them into PWM signals to drive a motor. It also provides feedback on an LCD display.
- An alternative or supplementary Python script that demonstrates object detection using a pre-trained deep learning model (MobileNet-SSD). This could be used for more advanced object tracking.
- Python 3.x
- OpenCV(cv2)
- NumPy (cumpy)
- PySerial (pyserial)
- A microcontroller with C compiler
- A motor driver and a motor
- A LCD Display (Optional)
- The Python script captures video frames from the webcam.
- It converts the frame to the HSV color space, which is better for color-based detection.
- A color mask is applied to isolate the red object.
- The script calculates the center of the detected object's contour.
- A PID controller algorithm uses the object's position relative to the center of the frame to calculate a control signal.
- This control signal is translated into a motor speed and direction.
- The speed and direction are sent as two bytes over the serial port to the microcontroller.
- The C code on the microcontroller receives these two bytes.
- Based on the received values, the C code adjusts the PWM duty cycle for the motor driver to turn the motor at the specified speed and direction.
- This creates a feedback loop, continuously adjusting the motor to keep the red object centered in the camera's view.
This project is license under the MIT License - see the LICENSE file for details.