OpenCV 2.4.1 and EPD 2.7.3 x86_64 on Mac OSX 10.6.8


Python is a powerful scripting language with cross platfrom installer. Python has so many modules and libraries, including several popular ones like NumPy, Matplotlib, PIL, Pandas, and so on. Since Python has many functionalities, engineers and scientists have used it to replace Matlab for data analysis and scientific computation.

EPD (Enthought Python Distribution) is one of scientific computation python package which provides easy installation and interactive interface called iPython. EPD includes several popular scientific modules, such as NumPy, SciPy, PIL, and more. EPD has various licenses suiting the needs of the user. In this tutorial, we will use EPD 7.3.2 x86_64 for Mac.  Why use the academic version of EPD? The free version of EPD compiles python for i386 computer architecture, which is not compatible with the architecture of MacBookPro7,1 (x86_64). If you have never seen or used EPD or iPython before, this video maybe useful for you.

OpenCV is a library for image processing, computer vision, and machine learning with more than 500 functions. OpenCV is open source library with cross platform installation, ranging from Android, iOS, Windows, Linux, and Mac. OpenCV has plenty tutorials and documentations in its official website. Also, my colleague and I have wrote a lot of computer vision tutorials. You can find some useful articles here.

Why I wrote this tutorial? 

Many people do image processing and computer vision in C/C++, since they need to run it real-time and sometime want to embed it in small computing platform (mobile computing). In the other side, we can use python as a tool for learning, analyzing data as MATLAB does. Merging OpenCV to EPD means we can do more image analysis. We can provide more useful environment to build image processing algorithm, for example to analyze features extraction result with machine learning techniques or to do some algebra on the resulted image processing data.

Since I used Mac operating system, the installation was quite difficult (considering the OS platform and the processor architecture) and I found no reference that teach how to run OpenCV and EPD on Mac. Therefore, I decided to try every possibilities, for more than 18 hours, to configure and run OpenCV and EPD side by side. I ever used the free EPD, Unix makefile, and command-line Cmake, but I had no result. Changing the version of EPD, using Cmake GUI, and XCode to generate (OpenCV python library that can be invoked directly from iPython console) was the best way that I can find right now.

I hope this tutorial will be useful for you, who have the same problem with me.

1. Requirements:

a. EPD 7.3.2-x86_64.dmg with academic license:
You can download it from EPD Enthought Python Distribution official website or download from
b. CMAKE GUI version 2.8-10 for Mac:
download here:
c. Sphinx module (download and install using easy_install)
d. XCode Version 3.2.6
e. OpenCV 2.4.1 source (tarball file). If you would like to download the latest one, you can clone it from

Operating system : Mac OS X 10.6.8 Snow Leopard

2. First, install EPD, CMAKE, Sphinx, and XCode.

3. Setting path in bash profile

# Setting path in ~/.bash_profile
# Setting PATH for EPD_free-7.3-2
export EPDPATH="/Library/Frameworks/EPD64.framework/Versions/Current"
export PATH="$EPDPATH/bin:${PATH}"
export PYTHONPATH="$EPDPATH/lib/python2.7/site-packages"

4. Make a folder called “build” inside OpenCV’s root folder.
This folder will be used to save build result of CMAKE.

5. Using CMAKE, configure Cmakefile of OpenCV

a. Use XCode as default compiler. Point the result to “build” folder (see step. 4). Check option grouped and advanced in CMAKE to reveal all flags and options

b. Set the following parameters in Python’s grouped setting :

Executable Path: /Library/Frameworks/EPD64.framework/Versions/Current/bin/python

Include Path:

Library Path: /Library/Frameworks/EPD64.framework/Versions/Current/lib/libpython2.7.dylib

Site-Packages: /Library/Frameworks/EPD64.framework/Versions/Current/lib/python2.7/site-packages

Numpy Path:

Sphinx-Build Path:

To point the OpenCV to EPD python installation

c. Deactivate “With CUDA” installation option

d. Make sure that BUILD_OPENCV_PYTHON is active (checked)

6. Configure and Generate Cmakefile

7. Open OpenCV.xcodeproj, and then compile all projects under OpenCV project

8. Find a file called inside folder:


9. Copy to this folder :


10. Now, open iPython and execute this command:

>>> import cv2

to test whether the installation is correct or not

— EOF —

Be Sociable, Share!
Categories: Machine Learning

Leave a Reply