大家好,又见面了,我是全栈君。
一:安装所须要的各种库,如GTK3.xx
安装GCC:sudo apt-get install build-essential
安装CMakesudo apt-get install cmake
sudo apt-get install python3.2-dev python-numpy libgtk-3-dev ffmpeg libavcodec-dev
libavformat-dev libswscale-dev libjpeg-dev libpng12-0 libpng12-dev libpng -dev libpng3
libtiff4-dev libjasper-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
zlib1g-dbg zlib1g zlib1g-dev libbz2-dev libxine1-ffmpeg libxine-dev libxine1-bin
libdc1394-22-dev libdc1394-22 libdc1394-utils
libv4l-0 libv4l-dev
或者不放心的话。安全点,把以下的所有安装了,一劳永逸
代码语言:javascript复制apt-get install build-essential
apt-get install cmake
apt-get install pkg-config
apt-get install libpng12-0 libpng12-dev libpng -dev libpng3
apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2
apt-get install zlib1g-dbg zlib1g zlib1g-dev
apt-get install libjasper-dev libjasper-runtime libjasper1
apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools
apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog
apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev
apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
apt-get install libxine1-ffmpeg libxine-dev libxine1-bin
apt-get install libunicap2 libunicap2-dev
apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
apt-get install swig
apt-get install libv4l-0 libv4l-dev
apt-get install python-numpy
apt-get install libpython2.6 python-dev python2.6-dev
假设运行上面的方法,安装opencv的时候遇到错误,再装以下的包吧:
代码语言:javascript复制安装Git(可选)
sudo apt-get install git
安装GTK开发版
sudo apt-get install libgtk-3-dev
安装pkg-config
sudo apt-get install pkg-config
安装Python
sudo apt-get install python3.2-dev
安装Numpy
sudo apt-get install python-numpy
安装媒体包:
sudo apt-get install ffmpeg
安装可选媒体包:
sudo apt-get install libavcodec-dev libavformat-devlibswscale-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev
二:从opencv官网下载源代码包,编译。安装
- 编译
进入opencv2.4.5所在文件夹,新建build文件夹 1 $ cd ~/opencv.2.4.8 # the directory should contain CMakeLists.txt, INSTALL etc. 2 $ mkdir build # create the output directory 3 $ cd build 4 $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON .. 这时makefile已经生成了,能够看到显示默认安装文件夹是/usr/local。 之后运行 1 $ make 2 $ sudo make install make的运行过程大概须要半个小时的时间 编译完之后,在/etc/ld.so.conf 文件中加上一行/usr/local/lib, 执行命令 1 $ sudo ldconfig 编译完成
- 測试 1 cd ~/opencv2.4.8/samples/c 2 . bash build_all.sh 3
測试: 编译例程 cd ~/OpenCV-2.4.8/samples/c chmod x build_all.sh bash ./build_all.sh
运行程序,假设正常的话应该在lena的脸上画一个蓝色的圈 ./facedetect –cascade=”/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml” –scale=1.5 lena.jpg
或者
1 $ cd ~/opencv2.4.5/samples/c 2 $ g `pkg-config --cflags opencv` -o cvtest cvtest.c `pkg-config --libs opencv` 3 4 ########################################################### 5 ########注意:g 后边那个东西是 ` ,就是ESC下边那个键########## 6 ###########################################################
在运行上述測试方法时,可能会遇到各种报错,这时能够试着运行下述命令
1 #安装libcv-dev,libcvaux-dev,libhighgui-dev包 2 $ apt-get install libcv-dev libcvaux-dev libhighgui-dev
參考资料
http://www.opencv.org.cn/index.php/Debian下安装
http://www.linuxidc.com/Linux/2010-04/25507.htm http://tech.techweb.com.cn/viewthread.php?tid=239096 http://opencv.willowgarage.com/wiki/InstallGuide_Linux
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116232.html原文链接:https://javaforall.cn