ubuntu12.04安装opencv-2.4.9
2014-10-29 11:50
274 查看
The latest Long Term Support version of Ubuntu(12.04 LTS) is out and a new version of OpenCV was released as well. This means that now is a great opportunity to update my OpenCV installation guide to the latest versions, Ubuntu 12.04 LTS and OpenCV 2.4.9.
We are going to setup OpenCV to use the new Qt highgui interface, which is much better than the simple highgui interface. Also, we will install OpenCV with support for OpenGL, as well as reading and writing videos, access to a webcam, Python, C and C++ interfaces,
and Intel Threading Building Blocks (TBB).
OK, so the first step is to make sure that everything in the system is updated and upgraded:
Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very
easy, you only need to write the following command in the Terminal:
Time to get the OpenCV 2.4.9 source code
Now
we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python, TBB, OpenGL, Qt, work with videos, etc, here is where we need to set that. Just execute the following line at the
terminal to create the appropriate Makefile. Note that there are two dots at the end of the line, it is an argument for the cmake program and it means the parent directory (because we are inside the build directory, and we want to refer to the OpenCV directory,
which is its parent).
Check that the above command produces no error and that in particular it reports FFMPEG as YES. If this is not the case you will not be able to read or write videos. Also, check that Python, TBB, OpenGL, V4L, OpenGL and Qt are detected.
If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again. You should see something similar to this:
Now, you are ready to compile and install OpenCV 2.4.9:
the following code to configure the library:
these two lines at the end of the file and save it:
Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you
do this.
Now you have OpenCV 2.4.9 installed in your computer with Python, TBB, OpenGL, video, and Qt support.
We are going to setup OpenCV to use the new Qt highgui interface, which is much better than the simple highgui interface. Also, we will install OpenCV with support for OpenGL, as well as reading and writing videos, access to a webcam, Python, C and C++ interfaces,
and Intel Threading Building Blocks (TBB).
OK, so the first step is to make sure that everything in the system is updated and upgraded:
sudo apt-get update sudo apt-get upgrade
Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very
easy, you only need to write the following command in the Terminal:
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpypython-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
Time to get the OpenCV 2.4.9 source code
Now
we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python, TBB, OpenGL, Qt, work with videos, etc, here is where we need to set that. Just execute the following line at the
terminal to create the appropriate Makefile. Note that there are two dots at the end of the line, it is an argument for the cmake program and it means the parent directory (because we are inside the build directory, and we want to refer to the OpenCV directory,
which is its parent).
mkdir build cd build cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
Check that the above command produces no error and that in particular it reports FFMPEG as YES. If this is not the case you will not be able to read or write videos. Also, check that Python, TBB, OpenGL, V4L, OpenGL and Qt are detected.
If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again. You should see something similar to this:
Now, you are ready to compile and install OpenCV 2.4.9:
make sudo make installNow you have to configure OpenCV. First, open the opencv.conf file with the following code:
sudo gedit /etc/ld.so.conf.d/opencv.confAdd the following line at the end of the file(it may be an empty file, that is ok) and then save it:
/usr/local/libRun
the following code to configure the library:
sudo ldconfigNow you have to open another file:
sudo gedit /etc/bash.bashrcAdd
these two lines at the end of the file and save it:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you
do this.
Now you have OpenCV 2.4.9 installed in your computer with Python, TBB, OpenGL, video, and Qt support.
相关文章推荐
- ubuntu12.04下opencv2.4.9的安装和使用
- Ubuntu12.04下OpenCV2.4.9源码编译安装
- ubuntu12.04 安装opencv
- Ubuntu12.04 安装eclipse 并配置OpenCV (C/C++项目)
- Ubuntu12.04LTS 上安装 opencv 2.4.2+ffmpeg0.11.1
- 安装OpenCV:OpenCV 2.4.8或2.4.9 +VS 开发环境配置
- ubuntu12.04 安装 opencv 2.4.8(非源码编译)
- ubuntu12.04下的opencv2.3.1安装(更新)
- OpenCV2.4.9的安装
- 【OpenCV入门教程之一】 安装OpenCV:OpenCV 3.0、OpenCV 2.4.8、OpenCV 2.4.9 +VS 开发环境配置
- ubuntu12.04安装openCV2.4.2
- Opencv编程->Ubuntu12.04上OpenCV2.4.9配置
- Ubuntu12.04安装openCV
- ubuntu12.04安装openCV2.3.1/opencv2.4.2
- ubuntu12.04安装openCV2.4.2
- ubuntu12.04安装openCV2.4.2
- ubuntu12.04安装opencv-1.0.0的问题(希望大家进来讨论一下)
- ubuntu12.04安装openCV2.4.6.1
- ubuntu12.04下的opencv2.3.1安装
- Ubuntu12.04 32位下安装OpenCV