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. http://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?
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