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服务,有可能是你的计算机名称带中文ÿ…...

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 框架,允许你通过中间件对请求和响应进行处理。中间件的概念在其他许多框架中也存在,它们在请求处理流程的早期执行,因此非常适合执行如日志记录、请求验证、设置响应头等任务。 在这篇教程中࿰…...

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…...
【Java学习笔记】Arrays类
Arrays 类 1. 导入包:import java.util.Arrays 2. 常用方法一览表 方法描述Arrays.toString()返回数组的字符串形式Arrays.sort()排序(自然排序和定制排序)Arrays.binarySearch()通过二分搜索法进行查找(前提:数组是…...
spring:实例工厂方法获取bean
spring处理使用静态工厂方法获取bean实例,也可以通过实例工厂方法获取bean实例。 实例工厂方法步骤如下: 定义实例工厂类(Java代码),定义实例工厂(xml),定义调用实例工厂ÿ…...
unix/linux,sudo,其发展历程详细时间线、由来、历史背景
sudo 的诞生和演化,本身就是一部 Unix/Linux 系统管理哲学变迁的微缩史。来,让我们拨开时间的迷雾,一同探寻 sudo 那波澜壮阔(也颇为实用主义)的发展历程。 历史背景:su的时代与困境 ( 20 世纪 70 年代 - 80 年代初) 在 sudo 出现之前,Unix 系统管理员和需要特权操作的…...

JUC笔记(上)-复习 涉及死锁 volatile synchronized CAS 原子操作
一、上下文切换 即使单核CPU也可以进行多线程执行代码,CPU会给每个线程分配CPU时间片来实现这个机制。时间片非常短,所以CPU会不断地切换线程执行,从而让我们感觉多个线程是同时执行的。时间片一般是十几毫秒(ms)。通过时间片分配算法执行。…...
多模态图像修复系统:基于深度学习的图片修复实现
多模态图像修复系统:基于深度学习的图片修复实现 1. 系统概述 本系统使用多模态大模型(Stable Diffusion Inpainting)实现图像修复功能,结合文本描述和图片输入,对指定区域进行内容修复。系统包含完整的数据处理、模型训练、推理部署流程。 import torch import numpy …...

PHP 8.5 即将发布:管道操作符、强力调试
前不久,PHP宣布了即将在 2025 年 11 月 20 日 正式发布的 PHP 8.5!作为 PHP 语言的又一次重要迭代,PHP 8.5 承诺带来一系列旨在提升代码可读性、健壮性以及开发者效率的改进。而更令人兴奋的是,借助强大的本地开发环境 ServBay&am…...
HybridVLA——让单一LLM同时具备扩散和自回归动作预测能力:训练时既扩散也回归,但推理时则扩散
前言 如上一篇文章《dexcap升级版之DexWild》中的前言部分所说,在叠衣服的过程中,我会带着团队对比各种模型、方法、策略,毕竟针对各个场景始终寻找更优的解决方案,是我个人和我司「七月在线」的职责之一 且个人认为,…...
32单片机——基本定时器
STM32F103有众多的定时器,其中包括2个基本定时器(TIM6和TIM7)、4个通用定时器(TIM2~TIM5)、2个高级控制定时器(TIM1和TIM8),这些定时器彼此完全独立,不共享任何资源 1、定…...

基于单片机的宠物屋智能系统设计与实现(论文+源码)
本设计基于单片机的宠物屋智能系统核心是实现对宠物生活环境及状态的智能管理。系统以单片机为中枢,连接红外测温传感器,可实时精准捕捉宠物体温变化,以便及时发现健康异常;水位检测传感器时刻监测饮用水余量,防止宠物…...

Linux基础开发工具——vim工具
文章目录 vim工具什么是vimvim的多模式和使用vim的基础模式vim的三种基础模式三种模式的初步了解 常用模式的详细讲解插入模式命令模式模式转化光标的移动文本的编辑 底行模式替换模式视图模式总结 使用vim的小技巧vim的配置(了解) vim工具 本文章仍然是继续讲解Linux系统下的…...