opencv3.2.0+contrib+cmake3.9.0的编译

opencv3.2.0+contrib+cmake3.9.0的编译

在编译过程中遇到很多问题,记录下来以防不测
Thanks to:http://blog.csdn.net/u012462822/article/details/49100025
http://blog.csdn.net/yiyuehuan/article/details/52951574

1.首先上github下载相对应得源码:
opencv-3.2.0:https://github.com/opencv/opencv/tree/3.2.0
opencv-3.2.0-contrib:https://github.com/opencv/opencv_contrib/tree/3.2.0
把下载的源码解压到同一个文件夹下,同时建立一个build文件夹
这里写图片描述

2.cmake
打开cmake-gui选择源码文件夹和工程目录文件夹如下:
这里写图片描述

Configure:
这里写图片描述
选择vs版本和编译方式,点击finish

tips:
这里会遇到ffmpeg和ippcv失败的问题,手动下载好ffmpeg和ippcv配置即可
下载地址:https://github.com/opencv/opencv_3rdparty/branches/all

ffmepg:把解压缩得到的opencv_ffmpeg.dll 、opencv_ffmepg_64.dll 、ffmpeg_version.cmake放到D:\opencv320\opencv-3.2.0\3rdparty\ffmpeg(对应文件夹)中
这里写图片描述
修改ffmpeg.cmake为:

message(STATUS "FFMPEG: Package successfully downloaded")
include(${CMAKE_CURRENT_LIST_DIR}/ffmpeg_version.cmake)

ippcv:在D:\opencv320\opencv-3.2.0\3rdparty\ippicv中建立unpack文件夹,把解压缩得到的ippcv文件夹放入unpack中
这里写图片描述
修改downloader.cmake为:

#
# The script downloads ICV package
#
# On return this will define:
# OPENCV_ICV_PATH - path to unpacked downloaded package
#

function(_icv_downloader)
  # Commit SHA in the opencv_3rdparty repo
  set(IPPICV_BINARIES_COMMIT "81a676001ca8075ada498583e4166079e5744668")
  # Define actual ICV versions
  if(APPLE)
    set(OPENCV_ICV_PACKAGE_NAME "ippicv_macosx_20151201.tgz")
    set(OPENCV_ICV_PACKAGE_HASH "4ff1fde9a7cfdfe7250bfcd8334e0f2f")
    set(OPENCV_ICV_PLATFORM "macosx")
    set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_osx")
  elseif(UNIX)
    if(ANDROID AND NOT (ANDROID_ABI STREQUAL x86 OR ANDROID_ABI STREQUAL x86_64))
      return()
    endif()
    set(OPENCV_ICV_PACKAGE_NAME "ippicv_linux_20151201.tgz")
    set(OPENCV_ICV_PACKAGE_HASH "808b791a6eac9ed78d32a7666804320e")
    set(OPENCV_ICV_PLATFORM "linux")
    set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_lnx")
  elseif(WIN32 AND NOT ARM)
    set(OPENCV_ICV_PACKAGE_NAME "ippicv_windows_20151201.zip")
    set(OPENCV_ICV_PACKAGE_HASH "04e81ce5d0e329c3fbc606ae32cad44d")
    set(OPENCV_ICV_PLATFORM "windows")
    set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_win")
  else()
    return() # Not supported
  endif()

  set(OPENCV_ICV_UNPACK_PATH "${CMAKE_CURRENT_LIST_DIR}/unpack")
  set(OPENCV_ICV_PATH "${OPENCV_ICV_UNPACK_PATH}${OPENCV_ICV_PACKAGE_SUBDIR}")

  message(STATUS "ICV: Package successfully downloaded")
  set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
endfunction()

_icv_downloader()

添加contrib模块:找到OPENCV_EXTRA_MOUDULE_PATH,选择contrib文件夹下的modules文件夹
这里写图片描述

generating done;
tips:
不添加contrib模块可选择BUILD_opencv_world,生成时只生成一个opencv_world_320的dll和lib文件,方便添加库文件;
添加contrib模块编译不能选择BUILD_opencv_world,否则会出错;

3.编译opencv
点击cmake的Open Project打开工程
首先在dubug模式下生成整个工程,然后单独生成CMakeTargets下的install,然后在release模式下生成整个工程,再单独生成install,完成opencv的编译;
这里写图片描述

这里写图片描述

最后生成包含所有的头文件、lib文件与dll文件的文件夹install;
这里写图片描述

编译完成,尽情享用吧。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值