【OpenCV】编译OpenCV时,FFmpeg或ippicv下载不成功的解决方案

在自己编译OpenCV时,因为种种原因可能会导致FFmpeg或ippicv下载不成功的问题,可以通过手动配置来解决这类问题,当然也可以直接配置之后再编译。

在进行配置之前,首先前往GitHub下载相应的库。

链接:opencv/opencv_3rdparty

这里写图片描述

链接打开之后页面内容大致如上图所示,图中圈出了ffmpeg和iipicv的不同版本,具体用哪一版就各取所需吧。明确版本之后点击相应的链接进入下载。

下载完成之后解压,位置不重要。
这里写图片描述

到此,准备完毕。

FFmpeg的配置

  1. “..\opencv_3rdparty-ffmpeg-master_20160715\ffmpeg” 目录中的 ffmpeg_version.cmakeopencv_ffmpeg.dllopencv_ffmpeg_64.dll 三项复制到 “path to your OpenCV\opencv\sources\3rdparty\ffmpeg” 目录下。
    这里写图片描述
    将上图中的三项复制到下图的目录中
    这里写图片描述

  2. 编辑 ffmpeg.cmake
    “path to your OpenCV\opencv\sources\3rdparty\ffmpeg” 中打开文件 ffmpeg.cmake ,将其内容修改为:

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

    保存内容。

到此,ffmpeg配置完毕。

ippicv的配置

  1. 在前面下载解压的目录“..\opencv_3rdparty-ippicv-master_20151201\ippicv” 中将ippicv_windows_20151201.zip 解压到当前目录。
    这里写图片描述
    “path to your OpenCV \opencv\sources\3rdparty\ippicv” 中创建文件夹unpack,将解压得到的ippicv_win 复制到新创建的unpack 中。
    这里写图片描述

  2. 编辑 downloader.cmake
    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()

保存内容。
到此,ippicv配置完毕。

开始快乐的编译OpenCV吧!

没有更多推荐了,返回首页