当前位置: 首页 > 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…...

50天精通Golang(第16天)

beego框架介绍和流程分析 beego官方文档:https://beego.me/ 一、beego框架介绍 1.1 beego框架介绍–beego简介 1.1.1 什么是beego beego是一个使用Go语言来开发WEB引用的GoWeb框架,该框架起始于2012年,由一位中国的程序员编写并进行公开…...

imx6ull基于yocto工程的l汇编点亮ed

通过汇编点亮led 在裸机状态下通过汇编点亮led,即没有操作系统,(uboot kernel rootfs 都不需要实现)。 led点亮原理 1.GPIO复用 根据原理图,找到led对应的引脚(pin),复用为GPIO(只有GPIO才能…...

vue 前端等比例压缩图片(再转换成文件后上传后端)

前端压缩图片总的来说还是转base64 然后等比例放小宽和高 这个是上次压缩图片的一个扩展 压缩完之后 再将base64 转成blob再转成文件然后再上传 一生要强的前端崽子(后端不支持base64上传) 自己改吧改吧 // 图片上传async changePic(e) {this.isshang…...

解决在eclipse2021中,用mysql-connector-java-8.0.18.jar不兼容,导致无法访问数据库问题

1.环境场景 组件版本mysql5.7.44mysql-connector-java80.18 2. 问题描述 报mysql-connector-java 驱动连不上mysql数据库。 3. 可能的原因分析 查看数据库连接句柄是否对 如果数据库连接句柄中没有 useSSLfalse 的话可能会导致这样的问题。 就像下面这样: jdb…...

5 微信小程序

功能开发 5 功能开发概要今日详细1.发布1.1 发布流程的问题1.2 组件:进度条1.3 修改data中的局部数据1.4 发布示例效果前端后端 1.5 闭包 2.获取前10条新闻(动态/心情,无需分页)3.复杂版4.文章详细页面 各位小伙伴想要博客相关资料…...

百度面经整理(2024最新)

百度 面经1 shiro的组件分布式一致性算法zookeeper那些能参与投票,leader能投票吗?netty零拷贝实现volatile,如何感知到变量变化的redis高可用http如何跨域?tcp如何长链接。http如何操作浏览器缓存。用过消息队列吗?…...

c++的构造函数

目录 构造函数 1.构造函数: 2.构造函数的特点: 默认构造函数 -- 没有参数的构造函数 1. 合成(自动)的默认构造函数(一般不常用) 1) 介绍,以及为什么不使用 2)可以使用合成默认构造函数的情况 2. 自定义的默认…...

基于ZU19EG的100G-UDP解决方案

概述 本文档介绍ZU19EG与Mellanox CX6 100G网卡通信解决方案。 环境配置 FPGA硬件:519-ZU19EG的4路100G光纤PCIe加上计算卡 电脑:国产国鑫主板(双PCU):Gooxi G2DA-B CPU:Intel Xeon Silver 2.2GHz 内存&#xff1…...

行为型设计模式——备忘录模式

备忘录模式 备忘录模式提供了一种状态恢复的实现机制,使得用户可以方便地回到一个特定的历史步骤,当新的状态无效或者存在问题时,可以使用暂时存储起来的备忘录将状态复原,很多软件都提供了撤销(Undo)操作…...

自定义HBase负载均衡器MyCustomBalancer实现步骤与代码解析

目录 1.HBase默认负载均衡策略 1.1 负载均衡总体流程 1.2 不能触发负载均衡的情况 1.3 负载均衡算法 2.自定义的 HBase 负载均衡器的步骤 3.MyCustomBalancer的代码细节 3.1 balanceCluster 方法的作用 3.2balanceCluster 对数据的影响 3.3监控HBase的性能指标 3.3.…...