Installing
OpenCV 2.4.1 in Ubuntu 12.04 LTS

这是转载国外一篇文章  移植PC上的OPENCV 

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
apt-get install quota

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 ~
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:

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

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.

If you zoom in enough, you can see the RGB (or intensity) values for each pixel.

Now let’s build some samples included in OpenCV:

1 cd ~/OpenCV-2.4.1/samples/c
2 chmod +x
build_all.sh
3 ./build_all.sh

Now we are ready to run the examples:

1 ./facedetect
--cascade=
"/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml"--scale=1.5
lena.jpg

1 ./facedetect
--cascade=
"/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml"--nested-cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml" --scale=1.5
lena.jpg

1 ~/OpenCV-2.4.1/build/bin/grabcut
~/OpenCV-2.4.1/samples/cpp/lena.jpg

1 ~/OpenCV-2.4.1/build/bin/calibration_artificial

1 python
~/OpenCV-2.4.1/samples/python2/turing.py

-----------------------------------------------------------------------------------------------人生过隙,忽然而已!

ubuntu OPENCV移植的更多相关文章

  1. opencv 移植

    1.ubunut系统搭建opencv+python开发环境 1.1.ubuntu系统安装pip3工具 sudo apt-get install python3-pip //安装python模块安装工具 ...

  2. 【opencv】ubuntu opencv imshow()报错

    错误提示: ubuntu opencv imshow() 报错 windows.cpp报错 the function is not implemented If you are on Ubuntu o ...

  3. Ubuntu下移植OpenCv

    通过近一周的时候终于成功交叉编译opencv成功了,真心不容易.有一句话乃真理也,凡事贵在坚持.过程总是痛苦的,因为不懂得很多问题但是又需要面对很多问题,最大的收获就是耐心解决所有问题后就懂得这些了. ...

  4. opencv移植到ubuntu

    原创博文,转载请标明出处--周学伟http://www.cnblogs.com/zxouxuewei/ OpenCV 2.2以后版本需要使用Cmake生成makefile文件,因此需要先安装cmake ...

  5. zedboard OPENCV移植

    1:系统环境搭建 要准备好交叉编译环境 见http://blog.csdn.net/xiabodan/article/details/22717175 2:下载cmake CMake是一个跨平台的安装 ...

  6. opencv移植(二)

    原文:https://blog.csdn.net/Guet_Kite/article/details/78667175?utm_source=copy 版权声明:本文为博主原创文章,转载请附上博文链接 ...

  7. 【转】OpenCV 移植学习--EMCV

    在Opencv论坛有好些这方面的帖子,主要看了一下几个牛人的帖子,比如论坛管理员于博士Shiqi Yu:(EMCV:可在DSP上运行的OpenCV)http://www.opencv.org.cn/f ...

  8. Android平台下OpenCV移植与使用---基于C/C++

    在<Android Studio增加NDK代码编译支持--Mac环境>和<Mac平台下Opencv开发环境搭建>两篇文章中,介绍了如何使用NDK环境和Opencv环境搭建与测试 ...

  9. opencv移植(一)cmake安装

    原文:https://blog.csdn.net/Guet_Kite/article/details/78667175?utm_source=copy 版权声明:本文为博主原创文章,转载请附上博文链接 ...

随机推荐

  1. c++ 设计模式1

    从面向对象谈起 1) 底层思维:向下,如何把握及其底层,从微观理解对象构造 (语言构造.编译转换.内存模型.运行时机制) 抽象思维: 向上,如何将我们的周围世界抽象为程序代码   (面向对象.组件封装 ...

  2. Json.Net学习(1) 实现简单的序列化和反序列化

    Attributes 可以用来控制Json.Net如何序列化和反序列化.Net对象. >JsonObjectAttribute--标记在类上,用于控制该类如何被序列化为一个Json对象(JSON ...

  3. Java_Web使用简单的批处理操作

    之前进行Web开发的时候使用的是myeclipse,但只用过的人都知道,由于其插件太多,而且有很多插件的功能根本就接触不到.所以导致一旦工程稍微大一点就会很卡,虽然之前也对其进行优化过,但还是觉得不太 ...

  4. Android 拍照 代码实例

    ------- 源自梦想.永远是你IT事业的好友.只是勇敢地说出我学到! ---------- 这是我做的一个简单的利用Android手机的摄像头进行拍照的实例. 在这里我实现了基本的拍照.照片的存储 ...

  5. oracle优化辅助SQL语句

    --查询正在执行的SQL语句 select a.program, b.spid, c.sql_text,c.SQL_FULLTEXT,c.SQL_ID from v$session a, v$proc ...

  6. Javascript -- Math.round()、Math.ceil()、Math.floor()、parseInt去小数取整总结

    一.Math.round() 作用:四舍五入返回整数.(返回参数+0.5后,向下取整) Math.round(5.57) //返回6 Math.round(2.4) //返回2 Math.round( ...

  7. About TI CC3000 Wifi

    http://forums.adafruit.com/viewtopic.php?f=22&t=44384http://learn.adafruit.com/adafruit-cc3000-w ...

  8. WGS84坐标系下,经纬度如何换算成米

    参考博客:显示瓦片地图  http://www.cnblogs.com/rhinoxy/p/4995731.html 注意:这里的计算方法精度相差比较大,不满足精确计算的需要. 需要理解的GIS概念: ...

  9. 写过的HTML标签(一)

    HTML >   标题显示字体大小为<h1>. HTML 段落是通过标签 <p> 来定义的. HTML 链接是通过标签 <a> 来定义的.  实例: < ...

  10. AngularJS尝鲜一

    第一个小例子,体验一下: <!DOCTYPE html> <html> <head> <title>Index</title> </h ...