转载
ubuntu12.04安装openCV2.4.2(2012-08-08 16:54:06
参考http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/更新软件列表,升级sudo apt-get updatesudo apt-get upgrade安装依赖包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下载opencv安装包cd ~因为sourceforge被伟大的墙挡住了,所以原文中的网址打不开wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2好在有备份的ftp,换成以下地址(参考http://lgn21st.iteye.com/blog/212204 关于如何解决上SourceForge.net的办法):wget ftp://sourceforge.nchc.org.tw/o/op/opencvlibrary/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2解压tar -xvf OpenCV-2.4.2.tar.bz2cd OpenCV-2.4.2创建编译目录mkdir buildcd buildcmake生成make文件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 ..检查输出:不能有error;FFMPEG : YES;Python, TBB, OpenGL, V4L, OpenGL and Qt are detected。如果有问题要重新安装对应的包再cmake编译(需要很长时间)make安装sudo make install配置sudo gedit /etc/ld.so.conf.d/opencv.conf打开一个空文件,添加以下一行内容/usr/local/lib保存推出执行配置sudo ldconfig环境变量sudo gedit /etc/bash.bashrc添加以下两行并保存PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfigexport PKG_CONFIG_PATH注销或重启测试:编译例程cd ~/OpenCV-2.4.1/samples/cchmod +x build_all.sh./build_all.sh执行程序,如果正常的话应该在lena的脸上画一个蓝色的圈./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
本文引用地址: 此文来自科学网于博博客,转载请注明出处。