PyCV - A Computer Vision Package for Python Incorporating Fast Training of Face Detection

Authors: Minh-Tri Pham <>
Viet-Dung D. Hoang <>
Tat-Jen Cham <>
Latest Version:0.3.0 (devel)
Released:September 2008



PyCV is a package of C++ and Python modules implementing various algorithms that are useful in computer vision, and augments the capabilities of OpenCV. In particular, PyCV provides implementations for:

Additionally, PyCV contains many useful modules for computer vision and machine learning, specially boosting techniques, Haar-like features, and face detection.

The package is primarily developed by Minh-Tri Pham, as part of his PhD research on face detection. This research is being carried out in the Centre for Multimedia & Network Technology (CeMNet), School of Computer Engineering, Nanyang Technological University, Singapore.

Copyright 2007 Nanyang Technological University, Singapore.

Founding Contributors:

Minh-Tri Pham <> -- Primary author

Viet-Dung D. Hoang <> -- Contributing author

Tat-Jen Cham <> -- Supervising faculty


The main features of PyCV are:

  • Interface:
    • A Python interface to OpenCV (improved from Gary Bishop's version)
  • Face Detection:
    • Haar-like features and their generalized Sparse Rectangular features
    • Integral image
    • Cascade for Object detection and Multi-exit Boosted Classifier [Pham2008]
    • Face detection
    • Fast training of Haar-like weak classifier for object detection [Pham2007b]
  • Boosting:
    • Offline boosting: AdaBoost, Viola-Jones’ AdaBoost [Viola2002], AdaBoost skewness balancing [Pham2007a], and Multi-exit Asymmetric Boosting [Pham2008]
    • Online boosting: Oza-Russel’s Online Boosting [Oza2005], Asymmetric Online Boosting [Pham2007a]
    • Linear Discriminant Analysis, Stump, Naive Bayes classifier


Downloads are available at sourceforge, in the Download section:

What's New?

Thanks for interest in pycv. However, I'm sorry that at the moment pycv is not working. Basically, pycv relies on old versions numpy, scipy, and opencv. Time has passed and these packages have evolved. But pycv has not. This is because every team member of the project has left, I myself have moved to a new university. The funds for the project have run out.

I guess it's safe to say that pycv is for now inactive until I can get funds to continue its development.

// Please find the release notes in the 'CHANGES.txt' file in the package.



Like many other open-source packages, PyCV relies on some other high-quality packages to provide its functionality.

  • ctypes-opencv 0.7.1 or later

    This is a Python wrapper for OpenCV using ctypes, written by Minh-Tri Pham. The latest release is available at its home page:

    Package 'ctypes-opencv' requires OpenCV installed on your system. At the point of this release, ctypes-opencv could detect and use both OpenCV 1.0 and 1.1pre1 versions.

  • Python 2.5 or later

  • SciPy 0.6.0 or later

  • NumPy 1.2.0 or later

    It is highly recommended that you should install an optimized implementation of BLAS like ATLAS or GotoBLAS along with your NumPy. PyCV can detect, and heavily use if available, the BLAS implementation in your NumPy.

  • Gcc or MinGW for a source release

    If you install from a source release, a standard C99-compliant C++ compiler is needed. Currently, only gcc and mingw are supported. msvc and icc will be supported in the near future, when SciPy can be robustly built with them.

    PyCV always uses the default C++ compiler that SciPy uses for compiling C++ source files.

    If you install from a binary release, no C++ compiler is needed. However, the binary release was compiled using MinGW (gcc 4.2.1) with no optimized BLAS. Thus, the running speed may not be that fast for optimized C++ functions using BLAS.

Operating Systems

  • Windows (tested on XP and Vista)
  • Linux (tested on Ubuntu 8.04)
  • Support for MacOS is only partial. This is because MacOS is not well-supported by SciPy, OpenCV and CVtypes. We are still experimenting PyCV with MacOS. Our main problem is we do not have a MacOS platform to test.

PyCV uses SciPy's setuptools(distutils) to install and distribute the package. For more information of how to distribute or install a package using distutils, we refer to Python's distutils module at

For example, to install from a source release:

python install

After installing, remember to go to another folder. Just like NumPy and SciPy, PyCV is not supposed to be run directly from its source folder.


A separate package called pycv_demo can be downloaded, and run with:


If you run on Linux, you may experience a blank screen in the video demo session. This is because OpenCV for Linux uses a single thread for both processing and rendering. Hence, it does not render fast enough when cvWaitKey() is called. To avoid this from happening, try:

python –d 10

The command runs the video demo session with 10 milliseconds delay per frame. Replace 10 with a larger number if the problem persists.


PyCV has been being documented directly in the source code using docstring, the same way that a large number of packages, like NumPy and SciPy, use. We are currently converting existing docstrings to the new reStructuredText format and write them for those that currently lack docstrings. To get help of a module, type:


in your Python interpreter.

  • PyCV 0.2.2 API Documentation –- autogenerated using epydoc
  • A tutorial on using PyCV to train and run a face detector -- coming soon. We are in a process of simplifying PyV's interface so that you can use as few calls as possible to train and run a face detector. This will take a while but we hope it will be worth waiting.


There are various unit tests for different modules in the package. Unit tests for module, for instance, are located in module of the same folder. If you need examples of using the package, check these unit test modules.

At the time we released PyCV 0.3.0, the SciPy community had released NumPy 1.1.1 and SciPy 0.6.0 and was about to release NumPy 1.2.0. However, in NumPy 1.2.0, the SciPy community decided to use a package called 'nose' for a robust testing system. This has improved the way unit tests are run, but requires user to install the package to run tests. More details can be found at this link:

To cope with the future releases of SciPy/NumPy, we decided to utilize NumPy 1.2.0 and later in PyCV starting from version 0.3.0. Therefore, the commands for running PyCV's tests are slightly different from those of previous versions.

Before running a test, you need to install the nose package. You would not need to install it if you decided not to run a test.

For a simple and fast test:

python -c "import pycv; pycv.test()"

For a thorough test that can take up to an hour:

python -c "import pycv; pycv.test('full')"

The tests may give many warnings but do not panic. Most of them are harmless. If you do not observe any Error or Exception returned, then PyCV can be safely used in your platform. You do not need to run a thorough test. It is useful for developers only.


Currently, PyCV is released under the GNU General Public License version 3 as follows:

PyCV is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PyCV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyCV. If not, see <>.

In addition, some source files of PyCV require extra attributive terms regarding published results. Please read them carefully before using.

Contact us

Email your inquiries to Minh-Tri Pham at (mtpham at ntu dot edu dot sg)


[Pham2008](1, 2, 3) Minh-Tri Pham and Viet-Dung D. Hoang and Tat-Jen Cham. Detection with Asymmetric Boosting. In Proc. IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'08), Anchorage, AK, 2008.
[Pham2007b](1, 2) Minh-Tri Pham and Tat-Jen Cham. Fast Training and Selection of Haar features using Statistics in Boosting-based Face Detection. In Proc. 11th IEEE International Conference on Computer Vision (ICCV'07), Rio de Janeiro, Brazil, 2007.
[Pham2007a](1, 2, 3) Minh-Tri Pham and Tat-Jen Cham. Online Learning Asymmetric Boosted Classifiers for Object Detection. In Proc. IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'07), Minneapolis, MN, 2007.
[Oza2005]N. Oza. Online bagging and boosting. In Int. Conf. on Systems, Man and Cybernetics, volume 3, pages 2340–2345, 2005.
[Viola2002]P. Viola and M. Jones. Fast and robust classification using asymmetric adaboost and a detector cascade. In NIPS. MIT Press, Cambridge, MA, 2002.