XRDS

Crossroads The ACM Magazine for Students

Sign In

Association for Computing Machinery

Magazine: Hello world Real-time detection with webcam

Real-time detection with webcam

By ,

Full text also available in the ACM Digital Library as PDF | HTML | Digital Edition

Tags: Computer vision, Image manipulation, Image processing

back to top 

OpenCV is an open-source, cross-platform library for real-time computer vision. Originally developed by Intel, the library will use Intel's Integrated Performance Primitives, if it is found on the system. It is very well-documented with a full reference manual, many examples and tutorials, and a book [which is also a good introduction to computer vision]. Interfaces for C, C++, and Python are also available in OpenCV.

Example applications of the OpenCV library include human-computer interaction; object identification, segmentation and recognition; face recognition; gesture recognition; motion tracking, ego motion, motion understanding; structure from motion [SFM]; stereo and multi-camera calibration and depth computation; and mobile robotics.

In this tutorial, we will learn how to do real-time face detection using a webcam. We will utilize a machine-learning object detection algorithm known as the Viola-Jones detector. It's a fast classification mechanism using Haar-like wavelet features. OpenCV ships with a very good "classifier file" for faces, but one can also train the classifier to recognize any kind of objects.

back to top  Instructions

First, download the latest OpenCV release for your platform from http://opencv.willowgarage.com and install it.


"In this tutorial, we will learn how to do real-time face detection using a webcam. We will utilize a machine-learning object detection algorithm known as the Viola-Jones detector."


Next, copy the attached program to a file named facedetect.py. You can also download it from http://XRDS.acm.org.

In the downloaded source archive, locate the classifier file data/haarcascades/haarcascade_frontalface_alt_tree.xml and replace the placeholder in the code with this original location.

Make sure that the Python interpreter knows the location for the OpenCV Python bindings. In Linux, it should be set automatically. In Windows, set the environment variable

set pythonpath = <opencvdir>\Python2.6\Lib\site-package.

Now, connect your webcam and run the program: python facedetect.py

To exit, press Esc. Have fun!

back to top  Improvements

Once an object is detected, we can start tracking it. OpenCV has an implementation for CamShift tracking algorithm. [See the example on http://XRDS.acm.org.]

Add detection of the eyes, mouth, and so on. [OpenCV ships with corresponding classifiers.] You can recognize emotions! See the video: www.youtube.com/watch?v=V7UdYzCMKvw.

If you replace the face classifier with hands classifier, and add tracking, you can now recognize gestures!
        —Dmitry Batenkov

back to top  Resources

Object identification links
Viola-Jones algorithm
http://www.face-rec.org/algorithms/Boosting-Ensemble/16981346.pdf

Haar training tutorial
http://note.sonots.com/SciSoftware/haartraining.html

Haar cascades repository
http://alereimondo.no-ip.org/OpenCV/34

back to top  HCI Projects Using OpenCV Handvu

Gesture recognition
www.movesinstitute.org/~kolsch/HandVu/HandVu.html

EHCI Head tracking
http://code.google.com/p/ehci

PyEyes Eyes tracking
http://eclecti.cc/olpc/pyeyes-xeyes-inpython-with-face-tracking

CCV/touchlib Multi-touch library
http://nuigroup.com

back to top  Other HCI/CV Toolkits

TUIO Common API for tangible multitouch surfaces
www.tuio.org/?software (list of implementations)

Trackmate Do-it-yourself tangible tracking system
http://trackmate.media.mit.edu

Sphinx Speech recognition toolkit
www.speech.cs.cmu.edu/sphinx/tutorial.html

VXL versatile computer vision libraries
http://vxl.sourceforge.net

Integrating Vision Toolkit
http://ivt.sourceforge.net

back to top  Footnotes

DOI: http://doi.acm.org/10.1145/1764848.1764861

back to top  Figures

UF1Figure.

back to top 

©2010 ACM  1528-4972/10/0600  $10.00

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee.

The Digital Library is published by the Association for Computing Machinery. Copyright © 2010 ACM, Inc.

Comments

Wed, 08 Dec 2010 21:15:31 UTC

Post by Thomas Blood

You also need to install numpy.

 

To comment you must create or log in with your ACM account.

Pointers

Code: Real-Time Detection with Webcam

Code available here