2022-3-2 編譯opencv-4.5.5 win32版本


cmake的時候要把BUILD->opencv_world選上,這個是把所有的庫打包在一起,否則不會生成opencv_worldXXX.lib 

cmake編譯遇到:

問題一:下載ippicv_2020_win_ia32_20191018_general.zip失敗

手動下載:cd opencv\opencv-master\3rdparty\ippicv

打開ippicv.cmake,找到42行,手動組合下載鏈接

https://raw.staticdn.net/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_ia32_20191018_general.zip

下載完放到以上目錄並解壓縮,修改ippicv.cmake,把下載的命令注釋掉,並把確定返回狀態的注釋掉即可

32#ocv_download(FILENAME ${OPENCV_ICV_NAME}
33# HASH ${OPENCV_ICV_HASH}
# URL
# "${OPENCV_IPPICV_URL}"
# "$ENV{OPENCV_IPPICV_URL}"
# "https://raw.staticdn.net/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv"
# DESTINATION_DIR "${THE_ROOT}"
# ID IPPICV
# STATUS res
# UNPACK RELATIVE_URL)

#if(res)
set(${root_var} "${THE_ROOT}/${OPENCV_ICV_PACKAGE_SUBDIR}" PARENT_SCOPE)
#endif()

問題二:下載opencv_videoio_ffmpeg_64.dll opencv_videoio_ffmpeg.dll ffmpeg_version.cmake失敗

手動下載這幾個文件,下載地址

https://raw.githubusercontent.com/opencv/opencv_3rdparty/4d348507d156ec797a88a887cfa7f9129a35afac/ffmpeg/opencv_videoio_ffmpeg.dll
https://raw.githubusercontent.com/opencv/opencv_3rdparty/4d348507d156ec797a88a887cfa7f9129a35afac/ffmpeg/opencv_videoio_ffmpeg_64.dll
https://raw.githubusercontent.com/opencv/opencv_3rdparty/4d348507d156ec797a88a887cfa7f9129a35afac/ffmpeg/ffmpeg_version.cmake

最后一個cmake,創建一個文件命名為ffmpeg_version.cmake,我網頁的內容填進去

編輯\3rdparty\ffmpeg\ffmpeg.cmake

19#foreach(id ${ids})
20# ocv_download(FILENAME ${name_${id}}
# HASH ${FFMPEG_FILE_HASH_${id}}
# URL
# "$ENV{OPENCV_FFMPEG_URL}"
# "${OPENCV_FFMPEG_URL}"
# "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/"
# DESTINATION_DIR ${FFMPEG_DOWNLOAD_DIR}
# ID FFMPEG
# RELATIVE_URL
# STATUS res)
# if(NOT res)
# set(status FALSE)
# endif()
#endforeach()
# if(status)
set(${script_var} "${FFMPEG_DOWNLOAD_DIR}/ffmpeg_version.cmake" PARENT_SCOPE)
# endif()

問題三:CMake Error at modules/videoio/cmake/detect_ffmpeg.cmake:16 (include): include could not find load file:

把源碼中3rdparty\ffmpeg文件件拷貝到,構建目錄的3rdparty\中,參考:https://github.com/opencv/opencv_contrib/issues/2574

問題四:WeChatQRCode: Can't get detect caffemodel file for wechat qrcode.

手動下載這個文件:https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/a8b69ccc738421293254aec5ddb38bd523503252/detect.caffemodel

放到BUILD\downloads中

編輯opencv_contrib-master\modules\wechat_qrcode\CMakeList.txt,注釋這些行

34#foreach(model_name ${model_names})
# foreach(model_type ${model_types})
# ocv_download(FILENAME ${model_name}.${model_type}
# HASH ${hash_${model_name}_${model_type}}
# URL
# "${OPENCV_WECHAT_QRCODE_URL}"
# "$ENV{OPENCV_WECHAT_QRCODE_URL}"
# "https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/${wechat_qrcode_commit_hash}/"
# DESTINATION_DIR "${CMAKE_BINARY_DIR}/downloads/wechat_qrcode"
# ID "wechat_qrcode"
# RELATIVE_URL
# STATUS res)
# if(NOT res)
# message(WARNING "WeChatQRCode: Can't get ${model_name} ${model_type} file for wechat qrcode.")
# endif()
# endforeach()
#endforeach()

問題五:最后生成庫的時候失敗,編輯cmake_install.cmake,注釋掉這些行

35#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xlicensesx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/licenses" TYPE FILE RENAME "ippicv-readme.htm" FILES "F:/source_code/opencv/opencv-master/BUILD/3rdparty/ippicv/ippicv_win/icv/readme.htm")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xlicensesx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/licenses" TYPE FILE RENAME "ippicv-EULA.rtf" FILES "F:/source_code/opencv/opencv-master/BUILD/3rdparty/ippicv/ippicv_win/EULA.rtf")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xlicensesx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/licenses" TYPE FILE RENAME "ippicv-third-party-programs.txt" FILES "F:/source_code/opencv/opencv-master/BUILD/3rdparty/ippicv/ippicv_win/third-party-programs.txt")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xlicensesx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/licenses" TYPE FILE RENAME "opencl-headers-LICENSE.txt" FILES "F:/source_code/opencv/opencv-master/3rdparty/include/opencl/LICENSE.txt")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xlicensesx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/licenses" TYPE FILE RENAME "ade-LICENSE" FILES "F:/source_code/opencv/opencv-master/BUILD/3rdparty/ade/ade-0.1.1f/LICENSE")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xlicensesx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/licenses" TYPE FILE RENAME "ffmpeg-license.txt" FILES "F:/source_code/opencv/opencv-master/3rdparty/ffmpeg/license.txt")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xlicensesx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/licenses" TYPE FILE RENAME "ffmpeg-readme.txt" FILES "F:/source_code/opencv/opencv-master/3rdparty/ffmpeg/readme.txt")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xdevx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include/opencv2" TYPE FILE FILES "F:/source_code/opencv/opencv-master/BUILD/cvconfig.h")
#endif()

#if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xdevx" OR NOT CMAKE_INSTALL_COMPONENT)
# file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include/opencv2" TYPE FILE FILES "F:/source_code/opencv/opencv-master/BUILD/opencv2/opencv_modules.hpp")
#endif()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM