-
文末附件安装包及其所有依赖包
-
安装依赖:
sudo apt-get install build-essential sudo apt-get install libopenblas-dev sudo apt-get install git pkg-config libavcodec-dev libavformat-dev libswscale-dev # 处理图像所需的包 sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff5-dev libdc1394-22-dev sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev # 处理视频所需的包 sudo apt-get install libxvidcore-dev libx264-dev # 优化opencv功能 sudo apt-get install libatlas-base-dev gfortran sudo apt-get install ffmpeg
-
编译opencv
首先将opencv_contrib-3.2.0文件夹移动到opencv-3.2.0里边
-
/home/sensiz/WorkingSpace/opencv-3.2.0 改为自己对应位置
cd opencv-3.2.0 mkdir build cd build //编译contrib 用该条cmake cmake -D CMAKE_BUILD_TYPE=Release OPENCV_ENABLE_NONFREE=ON \ -D ENABLE_PRECOMPILED_HEADERS=OFF -D OPENCV_GENERATE_PKGCONFIG=YES \ -D OPENCV_EXTRA_MODULES_PATH=/home/sensiz/WorkingSpace/opencv-3.2.0/opencv_contrib-3.2.0/modules \ -D CMAKE_EXE_LINKER_FLAGS=-lcblas \ -D CMAKE_INSTALL_PREFIX=/usr/local/ .. make -j8 sudo make install
cmake中出现的问题(替换对应文件路径):
-
ippicv_linux_20151201.tgz路径( Error:3party hash 不匹配),更换以下路径中的对应文件。
opencv-3.2.0/3rdparty/ippicv/downloads/linux-808.../ippicv.cmake
-
protobuf 3.1 路径( Error: 卡在这里:Downloading v3.1.0/protobuf-cpp-3.1.0.tar.gz...),此处需要科学上网才能下载,文末已经下载好了,替换下面路径对应文件。
opencv_contrib-3.2.0/modules/dnn/.download/bd5e3eed635a8d32e2b99658633815ef/v3.1.0/
注意: 得先再次运行cmake才会生成.download文件路径(快捷键:ctrl+H打开隐藏文件)
-
.i文件路径(特殊48.i处理)( Error:
Download: Local copy of vgg_generated_48.i has invalid MD5 hash
Downloading vgg_generated_48.i...),同样的,需要科学上网才能下载,文末已经下载好了,替换下面路径对应文件,如果其他.i文件也有报错,一并替换即可。
opencv_contrib-3.2.0/modules/xfeatures2d/cmake/.download/
make中出现的错误:
-
Error: 对‘cblas_sgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const, int, float const, int, float, float, int)’未定义的引用*
(可以直接在第一次cmake中就加入
-D CMAKE_EXE_LINKER_FLAGS=-lcblas
)opencv3.3.0安装过程报错 undefined reference to `cblas_zgemm‘解决方案
sudo apt-get install libopenblas-dev cmake -D CMAKE_EXE_LINKER_FLAGS=-lcblas ...
说明:cmake过程中加入-D CMAKE_EXE_LINKER_FLAGS=-lcblas
-
Error: fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h: 没有那个文件或目录
#include "LAPACKE_H_PATH-NOTFOUND/lapacke.h"
-
Error: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope
Ubuntu 安装opencv320 报错 error: 'CODEC_FLAG_GLOBAL_HEADER' was not declared in this scope
-
-
环境配置
# 设置opencv环境变量,首先将OpenCV的库添加到路径,从而可以让系统找到 # 执行此命令后打开的可能是一个空白的文件,不用管它,只需要在文件末尾添加 sudo gedit /etc/ld.so.conf.d/opencv.conf # 添加如下内容: /usr/local/lib # 或者如下命令(同上效果) sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' # 执行保存文件后,要运行如下命令使得刚才的配置路径生效 sudo ldconfig # 添加OpenCV环境变量到.bashrc文件 ,在bashrc中添加 sudo gedit /etc/bash.bashrc # 添加如下内容 PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH # 保存,执行如下命令使得配置文件生效 source /etc/bash.bashrc
-
验证环境
pkg-config --cflags opencv # 输出的是编译时需要的头文件路径: -I/usr/local/include/opencv -I/usr/local/include pkg-config --libs opencv # 输出的是编译时需要的链接库: -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dpm -lopencv_freetype -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_plot -lopencv_dnn -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
github下载安装包及其非常重要的依赖包:
链接: https://pan.baidu.com/s/1SSGtiMurr5iFGcMy0nzGPQ 提取码: 0323