环境问题
CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file):
file DOWNLOAD HASH mismatch
for file: [/home/book/opencv/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz]
expected hash: [808b791a6eac9ed78d32a7666804320e]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [7;"Couldn't connect to server"]
CMake Error at /home/book/opencv/opencv-3.2.0/cmake/OpenCVUtils.cmake:1047 (message):
Failed to download vgg_generated_48.i. Status=7;"Couldn't connect to
server"
cmake 配置途中需要下载
ippicv_linux_20151201.tgz、protobuf-cpp-3.1.0.tar.gz 等文件,还有一堆.i文件,可能出现无法下载导致出错,中断 cmake,直接拷贝下载好的文件到相应目录,然后再继续执行上面的 cmake 命令:
一、ippicv_linux_20151201.tgz 位于
opencv-3.2.0/3rdparty/ippicv/downloads/linux-…
二、protobuf-cpp-3.1.0.tar.gz 位于
opencv_contrib-3.2.0/modules/dnn/.download/bd5e3…/v3.1.0/
三、那一堆.i 文件位于 opencv_contrib-3.2.0/modules/xfeatures2d/src/
CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):
A duplicate ELSE command was found inside an IF block.
Call Stack (most recent call first):
CMakeLists.txt:495 (include)
打开cmake/OpenCVCompilerOptions.cmake:21 ,找到21行,多了一行多余的else(),直接删除掉就好了
编译过程
一.直接命令行编译
g++ test.cpp -o test `pkg-config --cflags --libs opencv`
二.通过 Makefile 编译
拷贝一个 CMakeLists.txt,将文中三处 example 改成你的 cpp 文件名,并添加下面一行:
set(OpenCV_DIR /home/book/opencv/opencv-3.2.0/mybuild)
然后执行配置编译命令:
cmake .
make