Making an arrow point at an object using OpenCV and Arduino

Table of Contents

1 Overview

This small program show how to update the position of a servo motor to point at an object detected by OpenCV.

That's a very simple project. Nothing fancy.

1.1 Hardware

  • A Philips SPC900NC webcam was used, but any webcam should works.
  • The Arduino board and the motor come from the Arduino kit prepared by Sparkfun. See http://www.sparkfun.com/products/10173.

1.2 Example

(You need Javascript or a HTML5 capable browser to play the video.)

2 Source code

There are 2 programs:

  1. the OpenCV program which track the object and send a position for the servo motor to Arduino. You can download it from http://doc.tuxee.net/arrow.cc.
  2. the Arduino program which receive the position and update the servo motor accordingly. You can download it from http://doc.tuxee.net/arrow-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 the range 0-640) of the ball.

Date: 2012-04-15 18:15:52 CEST

Author: Frédéric Jolliton

doc@frederic.jolliton.com

Org version 7.8.03 with Emacs version 24

Validate XHTML 1.0