Pan tracking webcam using OpenCV and Arduino
Table of Contents
1 Overview
1.1 OpenCV
1.2 Arduino
I'm using a Philips SPC900NC webcam (from which I removed the part used to fix it on a monitor). I used adhesive tape to bind the motor support to the webcam.
The Arduino board and the motor come from the Arduino kit prepared by Sparkfun. See http://www.sparkfun.com/products/10173.
1.3 Example
A video showing how the webcam is controlled accordingly to the object to track:
(You need Javascript or a HTML5 capable browser to play the video.)
2 Source code
There are 2 programs:
- the OpenCV program which track the object from the webcam and send orders to Arduino to position the servo motor. You can download it from http://doc.tuxee.net/tracking.cc.
- the Arduino program which receive orders from the OpenCV program. You can download it from http://doc.tuxee.net/tracking-arduino.cc.
The protocol is very simple between OpenCV and Arduino: the program transmit one integer per line through the serial connection (using the USB connection or a RS232 port). Each integers gives the position (in microseconds) of the servo motor to set.
Date: 2011-04-01 15:01:01 CEST
HTML generated by org-mode 7.4 in emacs 23