This is a simple program that displays live video from a webcam and tracks user's eye. The system tracks user's eye with a given template, which was manually selected using mouse.
When the user initially clicks the eye feature, a box is drawn around the square and the subimage within this square is cropped out of the image frame. The cropped image is used as a template to find the position of the feature in subsequent frames. The system determines the position of the feature using Sum of Square Differences (SQD) method. To reduce extensive computation, the system tracks the feature in a "search window", a small area around the position of the feature in previous frame.
Listing 1: OpenCV Eye Tracking
Notice line 117-124, you should add some code to make sure that the search window is still within the frame. If the search window exceed the frame boundaries, it will trigger errors. I will leave this as an exercise for you, dear reader.
Some features to add for the next version:
Send suggestion, bug reports or any comments about this program to me [at] nashruddin.com.
Learning OpenCV: Computer Vision with the OpenCV Library
By: Gary Bradski, Adrian Kaehler
This book is the "de facto" OpenCV User's Manual. It provides a practical, pragmatic, accessible book on computer vision, with algorithmic explanation and concrete example code snippets. Written by the creators of OpenCV, no doubt you should obtain a copy.
Risa Indah on Jan 5, 2009:
Nash on Jan 6, 2009:
vanathy on Jan 7, 2009:
Pernnie on Jan 8, 2009:
Nash on Jan 8, 2009:
Fernando(Brazil) on Jan 12, 2009:
Nash on Jan 12, 2009:
Andres on May 26, 2009:
Nash on May 27, 2009:
| Tel. | +62 31 8662872 +62 856 338 6017 |
| ICQ | 489571630 |
| Skype | dede_bl4ckheart |
| Yahoo | dede_bl4ckheart |
| nashruddin.amin |
Stephen Smith on Dec 14, 2008: