This is my first time using OpenCV, an open source computer vision library developed by Intel Corporation. It wasn't too hard to get setup or use OpenCV in Microsoft Visual Studio 2008 Professional (I haven't tried it with the free Express version of Visual Studio). I used this link to get started with OpenCV 2.1 (I had problems configuring OpenCV2.2).
- LynxMotion pan and tilt kit with Hitec HS-422 servo motors
- Creative USB webcamera, stripped from its case
- Atmel AVR ATmega328P microcontroller programmed using AVR Studio 4, AVR GCC, and programmed with an AVRISP MKII
- A very cheap USB to serial converter (shown in the last image) bought from dealextreme.com. This actually turned out to be a USB to inverted UART converter. I inverted the signal using a transistor inverter circuit as shown on the breadboard near where the ribbon cable connects.
The basic operation goes something like this:
- Computer fetches an image frame from the USB webcam
- Program rotates the image 90 degrees (I mounted the camera sideways)
- A face recognition algorithm is applied to the image using OpenCV libraries
- When a face is found the pixel coordinates of its center are subtracted from the pixel coordinates of the center of the image. This results in x and y difference values that can be either negative, positive, or zero if equal.
- Serial commands are sent from the computer COM port to the AVR microcontroller corresponding to the direction (sign of x and y difference values) and magnitude of the x and y difference values.
- The AVR microcontroller recieves the serial commands from the computer which changes the servo position(s).
My goal is to eventually deploy this on a mobile robot with a WiFi webcam to replace the USB webcam and a Bluetooth serial link to replace the wired serial connection, but first I have to drop the cash on a WiFi webcam. Otherwise I may go down the road of using a full blown computer on the robot itself.
Code can be found at my sourceforge page under the folder Face Tracker.
Will update with a video in the near future!
*Click to enlarge
Tracks human faces using a webcamera and two servo motors to pan and tilt
- Actuators / output devices: 2 x Hitec HS-422 servo motors
- Control method: autonomous
- CPU: AVR ATmega328P, Core 2 Duo 2.66GHz
- Operating system: Windows 7 x64
- Power source: 6 x AA rechargeable batteries (regulated)
- Programming language: C (microcontroller), C++ w/ OpenCV (computer)
- Sensors / input devices: Creative USB webcam
- Target environment: Indoor or outdoor
This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/facetracker
Making it cheaper
hello i know a way you could give the entire circuitary wifi connectivity under $30
If you are interested contact me.
by the way this project was really useful to me
Nice project. Does the face
Nice project. Does the face recognition recognize different faces or just tell you “there is A face”?
Thanks for the comments, I
Thanks for the comments, I am interested in converting this to use a single board computer running linux to do the processing, eliminating the need for a wifi transmitter, and enabling the use of a USB wifi adapter if needed for remote control or something else. If you know of a cheap wifi solution for use with 8-bit microcontrollers please let me know here as it could be useful for other projects.
The OpenCV code looks for
The OpenCV code looks for “faces” and only reports “the biggest face.” For example a child next to an adult would yeild the coordinates of the adult (assume adult has a larger face). If the child moves close enough their face is “bigger” and thus the childs coordinates would be used for tracking. No recognition is implemented, but that is something I am interested in doing along with recognizing other objects.
Nice, thanks for the heads
Nice, thanks for the heads up on openWRT and the asus device which runs it nicely. Will put this on my todo list for sure!
Making it cheaper than ever
Recently i have modified the project to work on a raspberry Pi and the effective cost came under 60$ there is no need for additional PC an now it has ethernet interface hdmi output. This project has helpd me a lot thank you Rougue. My next idea i to add a Paint ball gun to the project and make a Paint ball Gun turret… but only one problem paint ball guns are not available in india…
This is a really cool project.
Awesome, I’m glad you found
Awesome, I’m glad you found the code useful! Feel free to share some details or tutorials you found useful for running opencv on your raspberry pi, I’ve been thinking about doing the same on a beagle.
raspberry pi is better and simpler and cheaper than the beagle… i will post a tutorial asap but the modifide code of this project was lost when the sd card of pi died…
now starting from scratch and bit for problems than the initial case…
Sorry to hear the SD died,
Sorry to hear the SD died, always good to back up often. I haven’t used a rasperry pi yet, mainly because of the long lead times but for a couple of other reasons. Have you used a beagleboard or beaglebone or pandaboard?
there were back up’s
i had took backups for the but when i tried to restore them to a new sd card they are making strange problems…
For windows 7
Hey Rogue i am tying to make this project agiain for my laptop but i couldnt get this work on my windows 7 x64 pc. and tiried this on virtual pc only works on win XP any ideas bout that…
Nothing comes to mind as to
Nothing comes to mind as to what is a likely problem, I’ve got it to work on both win 7 x64 and x32 machines without much trouble. I don’t know what version of open CV you are using (I used 2.1 if I remember correctly), if you have compiler errors, etc.