MSR Hackathon project
In this project, Python, ROS, and OpenCV were used to program a servo-controlled pan-tilt camera system that can track target objects.
To track a blue ball with a camera mounted on 2 servos that are commanded to move such that the ball stays in the center of the camera frame.
The ROS camera driver used to get a live video feed is supported by the usb_cam package. Once a feed is obtained, each image is converted to the HSV color space for better color segmentation using OpenCV. The centroid of the largest contour in each filtered image is determined and is passed along to the servo node.
With the centroid information passed to this node, the servos can be controlled such that the centroid is always in the center of the camera frame. The servos are mounted on a pan-tilt mechanism and are controlled through the Pololu Micro Maestro servo controller.
Subscribed Topic: /camera_driver/image_raw
Published Topic: /center_position
Subscribed Topic: /center_position
Click below to see a test in action. A blue ball is detected from the system.