Is it possible to run opencv (python binding) from a virtualenv?

From opencv install guide :

By default the OpenCV build system will choose the most recent version of Python that it can find, or you can force it to use a specific version using the PYTHON_EXECUTABLE variable when you invoke cmake.)

I just installed it on my ubuntu 11.10, on virtual env --with-no-site-package, by following the instruction on the link above. you need to build whole opencv. and its python wrapper together.

EDIT 1:

  1. Create a temporary directory, which we denote as , where you want to put the generated Makefiles, project files as well the object files and output binaries.

    cd ~/opencv
    mkdir release
    cd release
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
    
  2. Enter the created temporary directory () and proceed with:

    make
    sudo make install
    

---------

after build & install add the extension modules on PYTHON_PATH

export PYTHONPATH=~/projects/opencv/release/lib:$PYTHONPATH

I found the solution was that I had to copy over cv2.so and cv.py to the directory running the virtualenv, then pip install numpy. To do this on Ubuntu 12.04 I used.

virtualenv virtopencv
cd virtopencv
cp /usr/local/lib/python2.7/dist-packages/cv* ./lib/python2.7/site-packages/
./bin/pip install numpy
source bin/activate
python
import cv