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

opencv-4.8.0编译及使用

1 编译

        opencv的编译总体来说比较简单,但必须记住一点:opencv的版本必须和opencv_contrib的版本保持一致。例如opencv使用4.8.0,opencv_contrib也必须使用4.8.0。

        进入opencv和opencv_contrib的github页面后,默认看到的是git分支,如4.x。

        如果想要下载具体的版本,需要通过tag进行查找。

        注意,一定要下载具体的tag进行编译,不要选择branch,否则编译会报错。如opencv选择4.8.0,opencv_contrib选择4.x,编译会报下面的错误:

/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1437:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint16x8, v_int16x8, epi16, _mm_srai_epi16)
^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1427:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpuvec v_shr(const _Tpuvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1437:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1432:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpsvec v_shr(const _Tpsvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1438:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint32x4, v_int32x4, epi32, _mm_srai_epi32)
^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1427:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpuvec v_shr(const _Tpuvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1438:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1432:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpsvec v_shr(const _Tpsvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1439:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint64x2, v_int64x2, epi64, v_srai_epi64)
^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1427:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpuvec v_shr(const _Tpuvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1439:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1432:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpsvec v_shr(const _Tpsvec& a) \^
/Users/Github/opencv_contrib-4.x/modules/xphoto/src/grayworld_white_balance.cpp:290:21: error: no matching function for call to 'v_shr'v_sR2 = v_shr(v_mul_wrap(v_sR2, v_gainR), 8);^~~~~
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1437:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint16x8, v_int16x8, epi16, _mm_srai_epi16)
^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1427:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpuvec v_shr(const _Tpuvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1437:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1432:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpsvec v_shr(const _Tpsvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1438:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint32x4, v_int32x4, epi32, _mm_srai_epi32)
^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1427:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpuvec v_shr(const _Tpuvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1438:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1432:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpsvec v_shr(const _Tpsvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1439:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint64x2, v_int64x2, epi64, v_srai_epi64)
^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1427:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpuvec v_shr(const _Tpuvec& a) \^
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1439:1: note: candidate function template not viable: requires single argument 'a', but 2 arguments were provided
/Users/Github/opencv-4.8.0/modules/core/include/opencv2/core/hal/intrin_sse.hpp:1432:16: note: expanded from macro 'OPENCV_HAL_IMPL_SSE_SHIFT_OP'
inline _Tpsvec v_shr(const _Tpsvec& a) \^
/Users/Github/opencv_contrib-4.x/modules/xphoto/src/grayworld_white_balance.cpp:328:21: error: no matching function for call to 'v_shr'v_sB1 = v_shr(v_mul(v_sB1, v_gainB), 16);

        编译脚本如下(make -j8,使用并发编译,编译速度会快些):

make build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=/Users/opencv-4.8.0 -DBUILD_SHARED_LIBS=OFF -DOPENCV_EXTRA_MODULES_PATH=/Users/Github/opencv_contrib-4.8.0/modules
make -j8
make install

2 使用

        编写cmake时,强烈建议使用find_package引用头文件和lib库,尤其是lib库,千万不要手动逐个引入lib库。opencv的lib库引用关系表复杂,手动引用会出现各种符号未定义。大量的符号未定义会让人忙到怀疑人生。

        完整的cmake如下所示:

#
#cmake for first_opencv
#
cmake_minimum_required(VERSION 3.28)
set(target "first_opencv")
project(${target})
set(CMAKE_CXX_STANDARD 17)
set(project_path "${CMAKE_CURRENT_SOURCE_DIR}")
file(GLOB srcs "${project_path}/src/*.cpp" "${project_path}/src/*.c")
file(GLOB incs "${project_path}/src/*.hpp" "${project_path}/src/*.h")
source_group(source ${srcs})
source_group(include ${incs})find_package(Iconv)
set(OpenCV_DIR "/Users/libs/opencv-4.8.0/lib/cmake/opencv4")
find_package(OpenCV REQUIRED)
include_directories(${incs} ${OpenCV_INCLUDE_DIRS})add_executable(${target} ${srcs} ${incs})target_link_libraries(${target} ${OpenCV_LIBS})

         注意:

  • set(OpenCV_DIR "/Users/libs/opencv-4.8.0/lib/cmake/opencv4")中/Users/libs/opencv-4.8.0/lib/cmake/opencv4为OpenCVConfig.cmake所在的目录,如果不设置OpenCV_DIR,会报下面错误:
CMake Error at CMakeLists.txt:16 (find_package):By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project hasasked CMake to find a package configuration file provided by "OpenCV", butCMake did not find one.Could not find a package configuration file provided by "OpenCV" with anyof the following names:OpenCVConfig.cmakeopencv-config.cmakeAdd the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set"OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"provides a separate development package or SDK, be sure it has beeninstalled.
  • find_package(Iconv)必须添加,否则会报下面的错误:
CMake Error at /Users/libs/opencv-4.8.0/lib/cmake/opencv4/OpenCVModules.cmake:371 (set_target_properties):The link interface of target "opencv_wechat_qrcode" contains:Iconv::Iconvbut the target was not found.  Possible reasons include:* There is a typo in the target name.* A find_package call is missing for an IMPORTED target.* An ALIAS target is missing.Call Stack (most recent call first):/Users/libs/opencv-4.8.0/lib/cmake/opencv4/OpenCVConfig.cmake:133 (include)CMakeLists.txt:16 (find_package)

相关文章:

opencv-4.8.0编译及使用

1 编译 opencv的编译总体来说比较简单,但必须记住一点:opencv的版本必须和opencv_contrib的版本保持一致。例如opencv使用4.8.0,opencv_contrib也必须使用4.8.0。 进入opencv和opencv_contrib的github页面后,默认看到的是git分支&…...

Jmeter 性能-监控服务器

Jmeter监控Linux需要三个文件 JMeterPlugins-Extras.jar (包:JMeterPlugins-Extras-1.4.0.zip) JMeterPlugins-Standard.jar (包:JMeterPlugins-Standard-1.4.0.zip) ServerAgent-2.2.3.zip 1、Jemter 安装插件 在插件管理中心的搜索Servers Perform…...

Excel学习

文章目录 学习链接Excel1. Excel的两种形式2. 常见excel操作工具3.POI1. POI的概述2. POI的应用场景3. 使用1.使用POI创建excel2.创建单元格写入内容3.单元格样式处理4.插入图片5.读取excel并解析图解POI 4. 基于模板输出POI报表5. 自定义POI导出工具类ExcelAttributeExcelExpo…...

【技能---labelme软件的安装及其使用--ubuntu】

文章目录 概要Labelme 是什么?Labelme 能干啥? Ubuntu20.04安装Labelme1.Anaconda的安装2.Labelme的安装3.Labelme的使用 概要 图像检测需要自己的数据集,为此需要对一些数据进行数据标注,这里提供了一种图像的常用标注工具——la…...

回归预测 | Matlab实现SSA-CNN-LSTM-Attention麻雀优化卷积长短期记忆神经网络注意力机制多变量回归预测(SE注意力机制)

回归预测 | Matlab实现SSA-CNN-LSTM-Attention麻雀优化卷积长短期记忆神经网络注意力机制多变量回归预测(SE注意力机制) 目录 回归预测 | Matlab实现SSA-CNN-LSTM-Attention麻雀优化卷积长短期记忆神经网络注意力机制多变量回归预测(SE注意力…...

css垂直水平居中的几种实现方式

垂直水平居中的几种实现方式 一、固定宽高: 1、定位 margin-top margin-left .box-container{position: relative;width: 300px;height: 300px;}.box-container .box {width: 200px; height: 100px;position: absolute; left: 50%; top: 50%;margin-top: -50px;…...

OpenHarmony之hdc

OpenHarmony之hdc 简介 hdc(OpenHarmony Device Connector)是 OpenHarmony 为开发人员提供的用于调试的命令行工具,通过该工具可以在Windows/Linux/MacOS等系统上与开发机或者模拟器进行交互。 类似于Android的adb,和adb类似&a…...

【爬虫实战】-爬取微博之夜盛典评论,爬取了1.7w条数据

前言: TaoTao之前在前几期推文中发布了一个篇weibo评论的爬虫。主要就是采集评论区的数据,包括评论、评论者ip、评论id、评论者等一些信息。然后有很多的小伙伴对这个代码很感兴趣。TaoTao也都给代码开源了。由于比较匆忙,所以没来得及去讲这…...

CST2024的License服务成功启动,仍报错——“The desired daemon is down...”,适用于任何版本!基础设置遗漏!

CST2024的License服务成功启动,仍报错——“The desired daemon is down…”,适用于任何版本!基础设置遗漏! CST2024的License服务成功启动后报错 若不能成功启动License服务,有可能是你的计算机名称带中文&#xff…...

matlab中any()函数用法

一、帮助文档中的介绍 B any(A) 沿着大小不等于 1 的数组 A 的第一维测试所有元素为非零数字还是逻辑值 1 (true)。实际上,any 是逻辑 OR 运算符的原生扩展。 二、解读 分两步走: ①确定维度;②确定运算规则 以下面二维数组为例 >>…...

Apache ECharts | 一个数据可视化图表库

文章目录 1、简介1.1、主要特点1.2、使用场景 2、安装方式一:从下载的源代码或编译产物安装方法二:从 npm 安装方法三:⭐定制安装echarts.js 3、使用 官网: 英语:https://echarts.apache.org/en/index.html 中文&a…...

m1 + swoole(hyperf) + yasd + phpstorm 安装和debug

参考文档 Mac M1安装报错 checking for boost... configure: error: lib boost not found. Try: install boost library Issue #89 swoole/yasd GitHub 1.安装boost库 brew install boostbrew link boost 2.下载yasd git clone https://github.com/swoole/yasd.git 3.编…...

group by 查询慢的话,如何优化?

1、说明 根据一定的规则,进行分组。 group by可能会慢在哪里?因为它既用到临时表,又默认用到排序。有时候还可能用到磁盘临时表。 如果执行过程中,会发现内存临时表大小到达了上限(控制这个上限的参数就是tmp_table…...

【重学C语言】一、C语言简介

【重学C语言】一、C语言简介 什么是编程语言?编程语言 C语言发展史C语言标准变迁开发软件CLion安装步骤 VIsual Studio安装步骤 Clion 和 VS2022 绑定 电脑常识 什么是编程语言? 人类语言:语言就是人类进行沟通交流的表达方式,应…...

【MATLAB源码-第109期】基于matlab的哈里斯鹰优化算发(HHO)机器人栅格路径规划,输出做短路径图和适应度曲线。

操作环境: MATLAB 2022a 1、算法描述 哈里斯鹰优化算法(Harris Hawk Optimization, HHO)是一种受自然界捕食行为启发的优化算法。它基于哈里斯鹰的捕猎策略和行为模式,主要用于解决各种复杂的优化问题。这个算法的核心特征在于…...

NestJS 如何自定义中间件以及实际项目基于中间件提升项目开发效率

前言 NestJS 作为一个强大的 Node.js 框架,允许你通过中间件对请求和响应进行处理。中间件的概念在其他许多框架中也存在,它们在请求处理流程的早期执行,因此非常适合执行如日志记录、请求验证、设置响应头等任务。 在这篇教程中&#xff0…...

CMake入门教程【核心篇】设置和使用缓存变量

😈「CSDN主页」:传送门 😈「Bilibil首页」:传送门 😈「动动你的小手」:点赞👍收藏⭐️评论📝 文章目录 概述设置缓存变量使用缓存变量更改缓存变量完整代码示例实战使用技巧注意事项总结与分析...

MinIO (五) .net core实现分片上传

开发环境 Win11 vs2022 appsettings.json添加配置项 //minIO配置"MinIO": {//服务器IP"Endpoint": "192.168.xx.xx:9090",//账号"AccessKey": "3xR7i4zs1vLnxxxxxxxx",//密码"SecretKey": "P6bAnyzJm47Ub…...

如何有效提高矢量网络分析仪的动态范围

动态范围是网络分析仪(VNA)接收机的最大输入功率与最小可测量功率(本底噪声)之间的差值,如图所示,要使测量有效,输入信号必须在这些边界内。 如果需要测量信号幅度非常大的变化,例如…...

Python 安卓开发:Kivy、BeeWare、Flet、Flutter

kivy:https://github.com/kivy python-for-android :https://python-for-android.readthedocs.io/en/latest/ BeeWare:https://docs.beeware.org/en/latest/ Flet:https://github.com/flet-dev/flet 把 PySide6 移植到安卓上去&a…...

【HarmonyOS 5.0】DevEco Testing:鸿蒙应用质量保障的终极武器

——全方位测试解决方案与代码实战 一、工具定位与核心能力 DevEco Testing是HarmonyOS官方推出的​​一体化测试平台​​,覆盖应用全生命周期测试需求,主要提供五大核心能力: ​​测试类型​​​​检测目标​​​​关键指标​​功能体验基…...

为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?

在建筑行业,项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升,传统的管理模式已经难以满足现代工程的需求。过去,许多企业依赖手工记录、口头沟通和分散的信息管理,导致效率低下、成本失控、风险频发。例如&#…...

LeetCode - 394. 字符串解码

题目 394. 字符串解码 - 力扣(LeetCode) 思路 使用两个栈:一个存储重复次数,一个存储字符串 遍历输入字符串: 数字处理:遇到数字时,累积计算重复次数左括号处理:保存当前状态&a…...

关于iview组件中使用 table , 绑定序号分页后序号从1开始的解决方案

问题描述:iview使用table 中type: "index",分页之后 ,索引还是从1开始,试过绑定后台返回数据的id, 这种方法可行,就是后台返回数据的每个页面id都不完全是按照从1开始的升序,因此百度了下,找到了…...

服务器硬防的应用场景都有哪些?

服务器硬防是指一种通过硬件设备层面的安全措施来防御服务器系统受到网络攻击的方式,避免服务器受到各种恶意攻击和网络威胁,那么,服务器硬防通常都会应用在哪些场景当中呢? 硬防服务器中一般会配备入侵检测系统和预防系统&#x…...

el-switch文字内置

el-switch文字内置 效果 vue <div style"color:#ffffff;font-size:14px;float:left;margin-bottom:5px;margin-right:5px;">自动加载</div> <el-switch v-model"value" active-color"#3E99FB" inactive-color"#DCDFE6"…...

【决胜公务员考试】求职OMG——见面课测验1

2025最新版&#xff01;&#xff01;&#xff01;6.8截至答题&#xff0c;大家注意呀&#xff01; 博主码字不易点个关注吧,祝期末顺利~~ 1.单选题(2分) 下列说法错误的是:&#xff08; B &#xff09; A.选调生属于公务员系统 B.公务员属于事业编 C.选调生有基层锻炼的要求 D…...

04-初识css

一、css样式引入 1.1.内部样式 <div style"width: 100px;"></div>1.2.外部样式 1.2.1.外部样式1 <style>.aa {width: 100px;} </style> <div class"aa"></div>1.2.2.外部样式2 <!-- rel内表面引入的是style样…...

鸿蒙中用HarmonyOS SDK应用服务 HarmonyOS5开发一个生活电费的缴纳和查询小程序

一、项目初始化与配置 1. 创建项目 ohpm init harmony/utility-payment-app 2. 配置权限 // module.json5 {"requestPermissions": [{"name": "ohos.permission.INTERNET"},{"name": "ohos.permission.GET_NETWORK_INFO"…...

管理学院权限管理系统开发总结

文章目录 &#x1f393; 管理学院权限管理系统开发总结 - 现代化Web应用实践之路&#x1f4dd; 项目概述&#x1f3d7;️ 技术架构设计后端技术栈前端技术栈 &#x1f4a1; 核心功能特性1. 用户管理模块2. 权限管理系统3. 统计报表功能4. 用户体验优化 &#x1f5c4;️ 数据库设…...