I am sure that many of you have tried installing OpenCV with python support on Linux but found no success as executing a program gives you no module found error. I recently figured out on how to do it and fix all the errrors.
Btw, My other programs in OpenCV will be posted here
In this post I explain on how to install OpenCV on Ubuntu with python and ffmpeg support on
Follow the steps and your problem will be solved.
Or you can just execute the following script (which does same as the above):
Btw, My other programs in OpenCV will be posted here
In this post I explain on how to install OpenCV on Ubuntu with python and ffmpeg support on
Follow the steps and your problem will be solved.
- First install python-dev package (with $sudo apt-get install python-dev )
- Then install ffmpeg required files with $sudo apt-get install libavformat-dev libavcodec-dev libavfilter-dev libswscale-dev
- Also in some systems, there might be a pre-requsite that you have to install gtk, etc. For those, execute the following: $ sudo apt-get install libavformat-dev libgtk2.0-dev pkg-config cmake libswscale-dev bzip2
- Then, download the tar ball from the here. Also instead of this, you can run a svn checkout against latest version of opencv trunk.
- save the above file in a folder.
- Open Terminal and browse to above folder.
- Give the command $tar xvjf OpenCV-2.3.0.tar.bz2
- The files in tar ball will be extracted in a folder named OpenCV.... in the present folder.
- browse to the extracted folder, create a folder named release by giving the following command and change the present directory to release folder. $ cd OpenCV-2.3.0; mkdir release; cd release
- Now we need to create configuration files using CMAKE (if cmake isn't installed install it by giving the command $sudo apt-get install cmake) using the following command: $cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
- Give the following command to compile the source: $make
- Give the following command to install the libraries: $sudo make install
- Then we need to make the OS know that OpenCV is installed in a particular folder: so edit the LD_LIBRARY_PATH variable by giving the following command: $export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
- Then give the following command to update the ld paths: $sudo ldconfig.
- Now we need to move cv.so file in site-packages folder to dist-packages folder $sudo mv /usr/local/lib/python2.6/site-packages/cv.so /usr/local/lib/python2.6/dist-packages/cv.so
- and we're done!! :-)
- And yeah! In order to compile use the following: $g++ `pkg-config opencv --cflags --libs` -g input.cpp -o output
- I usually use this alias in Ubuntu which makes my life easier: alias opencvcc="g++ `pkg-config opencv --cflags --libs` -g". Now I can just compile using the following command: $opencvcc input.cpp -o output
Or you can just execute the following script (which does same as the above):
Now you are ready to run the first program in python, click here a simple 14 line code in python.
Cheers.
No comments:
Post a Comment