How to get OpenCV 2.2 working with Python (2.6) (Ubuntu)

So I’ve been working on a Python script to detect faces in a webcam feed and then authenticate them. However I ran into issues installing OpenCV on Ubuntu 10.04. There were some guides online, however they used pre-compiled versions of OpenCV and I wanted the newest version from source. This assumes Python 2.6, but just change the 11a step to whatever Python version you have installed. So here’s how to do it:

  1. sudo apt-get install build-essential cmake ffmpeg
  2. mkdir ~/opencv
  3. cd ~/opencv/
  4. svn co https://code.ros.org/svn/opencv/trunk
  5. cd trunk/opencv
  6. mkdir release
  7. cd release
  8. cmake -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON -D CMAKE_BUILD_TYPE=RELEASE ..
  9. make
  10. sudo make install
  11. sudo apt-get install python-opencv
  12. Open up python and try to import cv. (type python, hit enter, then type import cv, hit enter). If it fails do the following step (quit python first, cntrl – d):
  13. sudo mv /usr/local/lib/python2.6/site-packages/cv.so /usr/local/lib/python2.6/dist-packages/cv.so
  14. try step 12 again. It should import!

This worked for me, but let me know if you run into issues. The problem that I encountered is when I was trying to get the external libraries to link with OpenCV. Installing python-opencv fixed this issue for me, but you could also do this manually by downloading the lib-dev packages yourself and installing them for the various image libraries.

Tags: , , ,
About Author: Christian

One thought on “How to get OpenCV 2.2 working with Python (2.6) (Ubuntu)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>