当前位置: 首页 > news >正文

编译opencv4.6问题汇总,第三方软件包见我发的资源

win10系统 python3.8.2,cmake-3.15.5-win64-x64,opencv4.6

编译方式见:OpenCV的编译 - 知乎

本文主要总结问题。赠人玫瑰手留余香。

问题1

Problem with installing OpenCV using Visual Studio and CMake (error code: MSB3073)

解决方法

Use below steps:

  1. Navigate to your build folder
  2. Right click on ALL-BUILD.vcxproj
  3. Select properties
  4. Select Security tab
  5. Select Edit
  6. Check Full Control Box
  7. Open ALL-BUILD.vcxproj
  8. Right click on INSTALL and select Rebuild

Worked for me.

问题2

关于Cmake编译opencv中使用不了SIFT,SURF


之后在cmake中点击configure,注意这一步不要delete cache

问题3

CMake Warning (dev) at cmake/OpenCVUtils.cmake:144 (find_package):

Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules

are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use

在CMakeList.txt 文件中增加一行:

if(POLICY CMP0148) cmake_policy(SET CMP0148 OLD) endif()

问题4

Installing OpenCV 3.1.0 with CMake on Windows 7, opencv_ffmpeg.dll invalid hash

一种方法是在ffmpeg目录下方downloads文件,并放上响应的文件。但还是直接放到./cache/文件夹下面最方面

如下:

I found sub-string ffmpeg.dll in opencv\sources\3dparty\ffmpeg\ffmpeg.cmake:

set(FFMPEG_BINARIES_COMMIT "8aeefc4efe3215de89d8c7e114ae6f7a6091b8eb")

set(FFMPEG_FILE_HASH_BIN32 "89c783eee1c47bfc733f08334ec2e31c")

set(FFMPEG_FILE_HASH_BIN64 "35fe6ccdda6d7a04e9056b0d73b98e76")

set(FFMPEG_FILE_HASH_CMAKE "8606f947a780071f8fcce8cbf39ceef5")

set(FFMPEG_DOWNLOAD_URL https://raw.githubusercontent.com/Itseez/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/)ocv_download(PACKAGE ...)

Download files: https://raw.githubusercontent.com/Itseez/opencv_3rdparty/8aeefc4efe3215de89d8c7e114ae6f7a6091b8eb/ffmpeg/{opencv_ffmpeg.dll,opencv_ffmpeg_64.dll,ffmpeg_version.cmake}

and copy it to:

opencv\sources\3rdparty\ffmpeg\downloads\%HASH%\

Then cmake.exe -G "CodeBlocks - MinGW Makefiles" . and mingw32-make.exe

问题5

'cmake' will raise "OpenCVGenSetupVars.cmake" error (when configure OpenCV)

 had the same problem. The compilation was still successful after ignoring this warning. So the second time I built it, I removed the configuration option(OPENCV_GENERATE_SETUPVARS).

也就是OPENCV_GENERATE_SETUPVARS后面的√取消掉

问题6

Opencv_contrib编译

在opencv在cmake软件中configure结束后添加opencv_contrib文件夹中的modules文件到变量中。

需要使用SURF等库时在NONFREE后面打钩

之后点击configure,注意这一步不要delete cache,直接继续configure

问题7

face_landmark_model.dat,ffmpeg,ippicv等安装

下载完成之后,在\源码\.cache\文件夹下,找到源文件,复制下文件名(校验码+文件),

把下载的文件拷贝过来,修改成\.cache\目录里的名称。如下

然后重新在cmake里面configure就可以了

问题8

严重性    代码    说明    项目    文件        禁止显示状态
错误    C2059    语法错误:“)”    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    324    
警告    C4819    该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    1    
错误    C2059    语法错误:“for”    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    324    
错误    C2143    语法错误: 缺少“)”(“;”的前面)    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    324    
错误    C2065    “i”: 未声明的标识符    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    324    
错误    C2065    “i”: 未声明的标识符    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    324    
错误    C2275    “std::string”: 将此类型用作表达式非法    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    326    
错误    C2146    语法错误: 缺少“)”(在标识符“input_info”的前面)    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    326    
错误    C2065    “input_info”: 未声明的标识符    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    328    
错误    C2065    “input_info”: 未声明的标识符    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    350    
错误    C2737    “gtest_ar”: 必须初始化 const 对象    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    350    
错误    C2059    语法错误:“}”    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    435    
错误    C2143    语法错误: 缺少“;”(“}”的前面)    opencv_test_objdetect    D:\opencv\opencv\source\opencv-4.x\modules\objdetect\test\test_qrcode_encode.cpp    435    

更改文件编码格式保存

在类别找到文件,在右边命令一栏找到高级保存选项 将文字编码改为936的简体中文

移植问题

如果你是在本机使用,那么现在你就可以直接去python里对应的虚拟环境中调用cv2了。如果是准备再另一个电脑上使用,看下文

首先进入你最开始在cmake里设置的build路径 然后找到lib-python3-release-然后这里有个pyd文件 我们就要这个,拷出来

然后我们找到install-x64-vc16-bin,里面有2dll,拷出来

将这3个文件都拷贝到py程序的根目录,你就可以使用opencv了,大小确实小了点哈(尴尬)

————————————————

                       

原文链接:https://blog.csdn.net/weixin_44287933/article/details/133032558

http://www.lryc.cn/news/293387.html

相关文章:

  • Matplotlib炫酷气泡图:代码实战与参数解析【第55篇—python:Matplotlib炫酷气泡图】
  • Android学习之路(29) Gradle初探
  • python-自动化篇-运维-语音识别
  • ElasticSearch-ElasticSearch实战-仿京东商城搜索(高亮)
  • 解释 Python 中的描述符(Descriptor)是什么?如何在 Python 中实现一个简单的 ORM(对象关系映射)?
  • IP数据云识别真实IP与虚假流量案例
  • signalR+websocket:实现消息实时通讯——技能提升
  • 机器学习入门-----sklearn
  • 双非本科准备秋招(15.3)—— 力扣二叉树
  • 20240203在WIN10下使用GTX1080配置stable-diffusion-webui.git不支持float16精度出错的处理
  • 京东微前端框架MicroApp简介
  • SpringBoot 使用定时任务(SpringTask)
  • 国标GB/T 28181详解:设备视音频文件检索消息流程
  • openssl自签名CA根证书、服务端和客户端证书生成并模拟单向/双向证书验证
  • NIO Selector简介
  • 2023-12蓝桥杯STEMA考试 C++ 中高级试卷解析
  • 设计模式——2_1 命令(Command)
  • HP数组面试题
  • 机器学习5-线性回归之损失函数
  • vulhub中Adminer ElasticSearch 和 ClickHouse 错误页面SSRF漏洞复现(CVE-2021-21311)
  • 浅谈Zookeeper及windows下详细安装步骤
  • vite, vue3, vue-router, vuex, ES6学习日记
  • 25考研|660/880/1000/1800全年带刷计划
  • Mybatis基础教程及使用细节
  • 10 分钟在K8s 中部署轻量级日志系统 Loki
  • 图像处理python基础
  • 基于WordPress开发微信小程序2:决定开发一个wordpress主题
  • [Python] 什么是网格搜索以及scikit-learn中GridSearch类的介绍和使用案例?
  • Linux-正则表达式
  • Java基础学习:System类和Static方法的实际使用