博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Installing OpenCV 2.4.1 in Ubuntu 12.04 LTS
阅读量:6676 次
发布时间:2019-06-25

本文共 3895 字,大约阅读时间需要 12 分钟。

hot3.png

Installing OpenCV 2.4.1 in Ubuntu 12.04 LTShttp://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/

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.1.

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:

1 sudo apt-get update

2 sudo apt-get upgrade

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.1 installed in your computer with Python, TBB, OpenGL, video, and Qt support.
Check out the cool Qt interface which provides image viewing capabilities with zoom, as well as the ability to save the current image with just one click.
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:1 sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-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.1 source code:1 cd ~
2 wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2
3 tar -xvf OpenCV-2.4.1.tar.bz2
4 cd OpenCV-2.4.1
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).1 mkdir build
2 cd build
3 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.1:1 make

2 sudo make install
Now you have to configure OpenCV. First, open the opencv.conf file with the following code:1 sudo gedit /etc/ld.so.conf.d/opencv.conf
Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:
view source
print
?1 /usr/local/lib

Run the following code to configure the library:1 sudo ldconfig

Now you have to open another file:1 sudo gedit /etc/bash.bashrc
Add these two lines at the end of the file and save it:

1 PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

2 export PKG_CONFIG_PATH

转载于:https://my.oschina.net/u/559991/blog/113400

你可能感兴趣的文章
第十八天-企业应用架构模式-基本模式
查看>>
黑客图标
查看>>
【每日笔记】【Go学习笔记】2019-01-04 Codis笔记
查看>>
Dubbo Ecosystem - 从微服务框架到微服务生态
查看>>
Hexo 搭建个人博客 #05 利用 Travis CI 帮你自动部署
查看>>
NEO改进协议提案8(NEP-8)
查看>>
NODE + JWT + Mongo(简单实现权限管理)
查看>>
egg(20)--数据库中的表与表的关系
查看>>
IPv6时代已来:双十一中的IPv6大规模应用实践
查看>>
深入理解Redis系列之SpringBoot集成Redis
查看>>
关于cookie的一些说明
查看>>
SQL经典实例(一)检索记录
查看>>
借助node.js + mysql 学习基础ajax~
查看>>
程序员面试系列之Java单例模式的攻击与防御
查看>>
[LeetCode] 380. Insert Delete GetRandom O(1)
查看>>
Derek解读Bytom源码-创世区块
查看>>
Laravel教程: 3分钟实现小程序微信支付接入(上)——唤起支付
查看>>
IDEA开发工具报错----使用Tomcat启动项目报错
查看>>
MySQL学习记录: 常见问题
查看>>
leetcode-90. Subsets II
查看>>