Install OpenCV 2.4.0
Install OpenCV 2.4.1
Install OpenCV 2.4.2
Install OpenCV 2.4.3
Install OpenCV 2.4.4
Install OpenCV 2.4.5
Remove any installed versions of ffmpeg and x264.
sudo apt-get remove remove ffmpeg x264 libx264-dev
Install all the dependencies.
sudo apt-get install libopencv-dev sudo apt-get install build-essential checkinstall cmake pkg-config yasm sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install libdc1394-22-dev libxine-dev sudo apt-get install libgstreamer0.10-dev sudo apt-get install libgstreamer-plugins-base0.10-dev sudo apt-get install libv4l-dev sudo apt-get install python-dev python-numpy sudo apt-get install libtbb-dev sudo apt-get install libqt4-dev libgtk2.0-dev
Download the latest version ox x264 from x264 snapshots
tar -xvf x264-snapshot-version.tar.bz2 cd x264-snapshot-version/
If you are using 32 bit Linux
./configure --enable-static
If you’re using 64 bit Linux
./configure --enable-shared --enable-pic
Install it
make sudo make install
Download the latest version of ffmpeg from ffmpeg Download.
tar -xvf ffmpeg-version.tar.bz2 cd ffmpeg-version/
If you’re using 32 bit Linux
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
If you’re using 64 bit Linux or ARM
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
Install it
make sudo make install
Download the latest image of v4l from v4l-utils
tar -xvf v4l-version.tar.bz2 cd v4l-version make sudo make install
Download OpenCV 2.4.0
Download OpenCV 2.4.1
Download OpenCV 2.4.2
Download OpenCV 2.4.3
After downloading OpenCV 2.4.* package, untar it and make.
tar -xvf OpenCV-version.tar.bz2 cd OpenCV-version/ mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE ..
Verify that the output of cmake includes the following text:
- found gstreamer-base-0.10
- GTK+ 2.x: YES
- FFMPEG: YES
- GStreamer: YES
- V4L/V4L2: Using libv4l
Build and Install OpenCV
make sudo make install
OpenCV 2.4.* is now installed. Just make sure that all the libraries are linked properly.
Go to samples directory in OpenCV package.
Change directory to C or C++.
You’ll find a script there named build_all.sh.
Execute the script. It will make all the files. select any output file and run it. If it works then you are good to go.
sudo echo "/usr/local/lib" >> /etc/ld.so.conf sudo ldconfig
Your OpenCV 2.4.* is installed and libraries are properly linked. If you don’t have much experience with OpenCV, I would suggest you to go through this post. https://jayrambhia.wordpress.com/2012/05/08/beginning-opencv/. It shows how to make a script so that you don’t need to add everything while compiling opencv codes.
P.S. My Python port of George Nebehay’s OpenTLD Version is almost ready.
Thanks for the detailed instructions. I have an installer script (https://github.com/jabbalaci/jabbatron) and I added these steps. Available via these menu points: 130 -> 12i.
Oh. Sweet. That looks great. The installation is working, isn’t it ? wow. you have got a great installation file there. All in one. 😀
Hi. The installation went fine, thanks to your great step-by-step instructions. I use my install script mainly for setting up a newly installed machine quickly.
That’s so great. I think I should start using it since every time I try to upgrade my Ubuntu, I do something foolish and everything goes nuts and I have to re-install the new OS every time.
Pingback: Get data from Mat / cv::Mat in OpenCV « Paranoid Android
Pingback: ATutz, Linux Server Tutorials | Trouble compiling OpenCV for Linux on an Optimus laptop using bumblebee - ATutz, Linux Server Tutorials
Your step-by-step tutorial works great. Now I can work with OpenCV in Ubuntu. Btw, how can you find all the dependencies to install? I mean, are there any hints to know which dependencies are necessary?
Thanks
Hey,
Thanks. Glad to hear that it helped. So, basically there’s a list of dependencies on OpenCV website and you could always find all the dependencies on blogs like this.
Pingback: Cài đặt OPENCV trên Ubuntu Linux, ai biết xin chỉ giáo
Great useful post !
Dan
hey jay,
can you explain me about how to remove/uninstall all installed opencv in ubuntu 12.04?
i used to install opencv 2.1, opencv 2.4.1, and opencv 2.4.2 and now i want to remove/uninstall all of their traces because i find it difficult to find its packages..
Hey,
If you have installed using package manager, check /usr/lib directory and remove all the opencv files or just remove it using package manager (that would be better). If you have built and installed it from the source, you need to manually remove it. check /usr/local/lib and remove all the opencv files. Also, check /usr/local/lib/python2.7/dist-packages/ and remove cv.py and cv2.so.
I think this should be sufficient.
Thank you for sharing! I had the same problem and now it’s working!
Pingback: opencv 4 android (Ubuntu 12.04, 32 bit) » Trigger
./configure –enable-static cannot work for x264. Can you help me?
Hey,
The problem here is WordPress! It converts — to a long – somehow. See this. This will work.
./configure –enable-gpl –enable-libfaac –enable-libmp3lame –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid –enable-nonfree –enable-postproc –enable-version3 –enable-x11grab
ERROR: libfaac not found…
Could you help me?
i also found the same problem can u give me the solution?plz reply as soon as possible
Well… my last problem was resolved. But the error still pops out as
Looking for ffmpeg/avformat.h
— Looking for ffmpeg/avformat.h – not found
— checking for module ‘libdc1394-2’
— found libdc1394-2, version 2.2.0
— Looking for alloca.h
— Looking for alloca.h – found
— Looking for alloca
— Looking for alloca – not found
— Looking for unistd.h
— Looking for unistd.h – found
— Looking for pthread.h
— Looking for pthread.h – found
— checking for module ‘libxine’
— found libxine, version 1.1.20
— checking for module ‘libv4l1’
— found libv4l1, version 0.8.9
— Looking for linux/videodev.h
— Looking for linux/videodev.h – not found
— Looking for linux/videodev2.h
— Looking for linux/videodev2.h – found
— Found PythonInterp: /usr/bin/python (found suitable version “2.7.3”, required is “2.0”)
— Found PythonLibs: /usr/lib/libpython2.7.so (Required is at least version “2.7.3”)
— Found Sphinx 1.1.3: /usr/bin/sphinx-build
— Looking for Q_WS_X11
— Looking for Q_WS_X11 – found
— Looking for Q_WS_WIN
— Looking for Q_WS_WIN – not found.
— Looking for Q_WS_QWS
— Looking for Q_WS_QWS – not found.
— Looking for Q_WS_MAC
— Looking for Q_WS_MAC – not found.
Thanks for helping!
Thank you for the 2.4.3 install script for 12.04. I have been banging my head against the wall for three days. Everything was working with OpenCV 2.4.3 except video from my webcam. I ran your script, it fixed the problem. Great work.
Great scripts, thanks a lot for sharing. Have bookmarked and will be back.
Out of interest, do you know if this process has to be repeated each OpenCV version or is there an easier way?
Hey, thanks. You don’t need to install everything all over again. You can just install OpenCV and follow the rest.
Cheers!
Also, you may want to add “-y” to your “sudo apt-get install” lines to save you having to confirm each installation. Not sure if anything else needs confirmation (such as “make install”) before it will complete.
Pingback: xbox 360
Pingback: Tutorials - Setup OpenCV for Android, iOS, Linux, and Windows
Hello.
Thanks for the script. I followed it and I’m stuck at this point: When I type:
tar -xvf OpenCV-version.tar.bz2
cd OpenCV-version/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE ..
I get:
CMake Error: The source directory “/home/uni/src/OpenCV-2.4.5” does not appear to contain CMakeLists.txt.
I’m using Ubuntu 12.10 and my architecture is x86_64.
Any suggestions?
Thanks
it doesn’t contain CMakeLists. You need to get a copy of it from somewhere. or download the source again.
Thanks for the reply. I did re-install and everything works fine. Up until when I find “build_all.sh”.
Since I am a beginner, could you tell me how to execute it so that I can run sample files?
Thanks
“tar -xvf v4l-version.tar.bz2
cd v4l-version
make
sudo make install”
i’ve downloaded v4l-utils-0.9.4.tar.bz2
but when i try make there is some thing like that :
“zeeshan@ubuntu:~/Desktop/opencv_build/OpenCV$ ls
ffmpeg-0.11.1 OpenCV-2.4.2.tar.bz2 v4l-utils-0.9.4 x264-snapshot-20120528-2245-stable
ffmpeg-0.11.1.tar.bz2 v4l-utils-0.8.8 v4l-utils-0.9.4.tar.bz2 x264-snapshot-20120528-2245-stable.tar.bz2
OpenCV-2.4.2 v4l-utils-0.8.8.tar.bz2 v4l-utils-0.9.5
zeeshan@ubuntu:~/Desktop/opencv_build/OpenCV$ cd v4l-utils-0.9.4
zeeshan@ubuntu:~/Desktop/opencv_build/OpenCV/v4l-utils-0.9.4$ make
make: *** No targets specified and no makefile found. Stop.
Try this script https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_5.sh . This should install it.
plz tell me how can I configure OpenCV 2.4.5 for Eclipse in Ubuntu 12.04?
I installed OpenCV 2.4.5 with your code in
jayrambhia.wordpress.com/2012/06/20/install-opencv-2-4-in-ubuntu-12-04-precise-pangolin/
thanks for the scripts!! worked well for me!!
fantastic scripts! 2.4.5 install script worked flawlessly on mint 15 (Ubuntu 13.04)
Hello,
I have a problem.
cmake -D CMAKE_BUILD_TYPE=RELEASE .. works fine. But when I command make some files build and results in error.
i got this error :
Linking CXX shared library ../../lib/libopencv_highgui.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32 against `.rodata.str1.1′ can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_highgui.so.2.4.6] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
What should I do?? Please Help..
To install OpenCV using the terminal on Ubuntu:
$ su –
# apt-get update
# apt-get install build-essential
# apt-get install libavformat-dev
# apt-get install x264 v4l-utils ffmpeg
# apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev
http://namhuy.net/1205/how-to-install-opencv-on-ubuntu.html
tar -xvf v4l-version.tar.bz2
cd v4l-version
make
sudo make install
This is missing the ./configure after the changing of the folder , should be
tar -xvf v4l-version.tar.bz2
cd v4l-version
./configure
make
sudo make install
Hey, I installed opencv 2.4.5 recently, suing your script. Need to upgrade to 2.4.8 now. Could you please provide script for that?
How do I uninstall OpenCV 2.4.5 and install 2.4.8 instead? I used your script only to install 2.4.5 earlier. Thanks!
HI , i have installed open cv on raspberry pi board , but the camera is not working it says capture from CAM 0 didnt work , could you please look into this
Hey,
i am currently trying to install Opencv on UB 12.04 LTS and had trouble while make at the step to install x264. it was saying Minimum Version yasm 1.2.0 and since i have UB precise i have yasm 1.1.something. can you please help me with it?
Also i am then trying to install with following link:http://www.ozbotz.org/opencv-installation/
However, with this link again i am facing error while installing v4l-utils video for Opencv.
Please provide some guidance.
Thanks.
In the configuration line for ffmpeg, what is to replace “version3”? 2.3.2 Is not working as a replacement!
Pingback: Instalasi OpenCV 2.3.1a dan ffmpeg 0.8.15 di Ubuntu 12.04 dengan Kompilasi Manual | RESTAVA
Hello, Jay. Thank you so much for this article. The pingback from restava above was from my blog. I have installed OpenCV + ffmpeg successfully on Ubuntu based on your tutorial. Thank you again.
Malsasa
#ubuntu-indonesia @ freenode
Pingback: Ubuntu:Does the version of Opencv shipped with 12.04 support v4l2? – Ubuntu Linux Questions
Pingback: Unix/Linux:Unable to install open CV in Ubuntu 12.04 – Unix Questions
Pingback: Does the version of Opencv shipped with 12.04 support v4l2? - Boot Panic