Monday, 23 February 2015

OpenCv with Python 2.7

OpenCv is a computer vision library that is available on many platforms and languages. In this case, I have used it with Python 2.7. This provides the advantages of simple installation, and portability across other platforms.

For object detection, OpenCv can use Haar Cascade files, which are XML files which define features in terms of edges, and can be "trained" using programs which add data to the file when they are shown pictures of the object.

The Haar Cascade file that was used was one of the basic ones included with an OpenCv install. This tracks faces face on only, and has trouble detecting faces at angles, or rotated.

The code for the project is available at

To run the script you must install the following requirements :

Python 2.7 :
OpenCv 2.4 :

Instructions for installing OpenCv with Python on windows are included below. They also install numpy and mathplotlib in this guide, but this program does not require them. They are useful to have, but the links below are to outdated version anyway, so if you want them, go find the latest version.

The code itself is rather short, and I hope that the comments will be sufficient to explain the code.

No comments:

Post a Comment