OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision. It is released under a BSD license, it is free for both academic and commercial use. It has C++, C, Python and soon Java interfaces running on Windows, Linux, Android and Mac.
This is how to build and install OpenCV 2.2 on Ubuntu 10.10.
First, install the dependencies from the repositories:
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-devDownload the source code:
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.2/OpenCV-2.2.0.tar.bz2Extract, create the build directory:
tar xfv OpenCV-2.2.0.tar.bz2 rm OpenCV-2.2.0.tar.bz2 cd OpenCV-2.2.0 mkdir opencv.build cd opencv.buildConfigure, make and install:
cmake .. make sudo make installTo configure the library, edit the following file (might be empty):
sudo gedit /etc/ld.so.conf.d/opencv.confand add the line
/usr/local/libThen run:
sudo ldconfigFinally, edit the file:
sudo gedit /etc/bash.bashrcand add the following lines at the end:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATHMost of the above was find here.
Older versions? Take a look at the following links:
OpenCV 2.1 on Ubuntu 10.04 (pretty much the same as above, but with TBB)
OpenCV 2.0 on Ubuntu 9.10
For OpenCV 2.3.1 see this post.
Hi,
ReplyDeleteI find your post extremely helpful. Thank you.
I want to ask another question. I want to implement an improves version of connected component analysis. I want to implement it in header file while accessing it via cpp file. could you help me figure out how to do that ?
Thanks.
Ankit.
I'm glad you found the post helpful. I'm not sure how I can help you with your task. If your problem is writing C++ using header and implementation files then this might help you:
ReplyDeleteOrganizing Code Files in C and C++
yes i was looking for this kind of implementation. The only thing is I need to use 'make' so that i can build all my dependencies. Do you think you can help me with that ?
ReplyDeleteThanks a lot for your help.
I'm not sure how I can help you with that. Could you be more specific?
ReplyDeletemake
ReplyDeletewhen i write make command errors occurs
Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o
/home/shakir/OpenCV-2.2.0/modules/highgui/src/cap_ffmpeg.cpp: In member function ‘virtual bool CvCapture_FFMPEG::open(const char*)’:
/home/shakir/OpenCV-2.2.0/modules/highgui/src/cap_ffmpeg.cpp:469: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
can u help me
This is caused by the the file /usr/local/libavcodec/avcodec.h installed by ffmpeg is different from the file in /OpenCV2.2_source/3rdparty/include/ffmpeg_/libavcodec/avcodec.h.
ReplyDeleteSo I did the steps to slove the problem
1) uninstall ffmpeg first by typing "sudo make uninstall" in ffmpeg source directory. This will remove ffmpeg files in /usr/local/...
2) Kill configured OpenCV files and reconfigure it by CMake with "With FFMPEG" selected.
3) then "make".
OpenCV will use the /3rdparty/...ffmpeg_ instead and it is OK on my system.
The point is, you have to use ffmpeg carried by OpenCV 2.2 instead of the lastest ffmpeg you downloaded. It is because that the declaration of "CODEC_TYPE_VIDEO" and others are removed in lastest ffmpeg.
ReplyDeleteThank you for clearing that up.
ReplyDeleteAfter it reached 56% it gives me this error..
ReplyDeleteBuilding CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_v4l.o
/home/joep/Downloads/OpenCV-2.2.0/modules/highgui/src/cap_v4l.cpp:217:28: fatal error: linux/videodev.h: No such file or directory
compilation terminated.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_v4l.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
Does someone know what i should do to reach it all to the 100%? And get it worked? Or is it maybe possible that somebody can give me the builded folder?
Joep
Getting a built version will probably not work on your system. Try:
ReplyDeletesudo apt-get install libv4l-dev
and try again. Hope it works.
I tried it, honestly i don't know what it did!
ReplyDeleteBut it worked, and after a while it gives another error.. (80%)..
thanks anyway!
Those errors are usually missing libraries. Try to search online to figure out which Ubuntu package includes the files you are missing and then sudo apt-get install them.
ReplyDeleteDid you solve a problem on 80%?
ReplyDeleteI had the same problems then Joep and it's was solved.
ReplyDeletesome made some changes in the source code. visit https://code.ros.org/trac/opencv/changeset/5206
Good tutorial on Image processing
ReplyDeletenice! very useful. Help me install it easy and successfully.
DeleteMuchas Gracias por el tutorial, he instalado y sin problemas, al final cabe resaltar que par correr los ejemplos dirigirse a jevg@jevg-lenovo:~/OpenCV-2.2.0/samples/c$ teclear sh build_all.sh y luego ./facedetect.
ReplyDelete