vscode + cmake + opencv example

nice try on macos

CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
#添加OPENCV库
#指定OpenCV版本,代码如下
#find_package(OpenCV 3.3 REQUIRED)
#如果不需要指定OpenCV版本,代码如下
find_package(OpenCV REQUIRED)#添加OpenCV头文件
include_directories(${OpenCV_INCLUDE_DIRS})#显示OpenCV_INCLUDE_DIRS的值
message(${OpenCV_INCLUDE_DIRS})# 添加一个可执行程序
# 语法:add_executable( 程序名 源代码文件 )
add_executable( main main.cpp )# 将库文件链接到可执行程序上
target_link_libraries( main  ${OpenCV_LIBS})
file(GLOB allCopyFiles  "./*.jpg")
file(COPY ${allCopyFiles} DESTINATION .) #copy any .jpg file to <build> dir# 或者
# file(GLOB allCopyFiles "${NSF_HOME}/lib/*")
# execute_process(COMMAND cp ${allCopyFiles} ${LIB})

main.cpp

    #include <iostream>#include "opencv2/imgproc.hpp"#include "opencv2/ximgproc.hpp"#include "opencv2/imgcodecs.hpp"#include "opencv2/highgui.hpp"using namespace std;using namespace cv;using namespace cv::ximgproc;int main(int argc, char **argv){string in;// 修改图片CommandLineParser parser(argc, argv, "{@input|me.jpg|input image}{help h||show help message}");if (parser.has("help")){parser.printMessage();return 0;}in = samples::findFile(parser.get<string>("@input"));Mat image = imread(in, IMREAD_GRAYSCALE);if (image.empty()){return -1;}// Create FLD detector// Param               Default value   Description// length_threshold    10            - Segments shorter than this will be discarded// distance_threshold  1.41421356    - A point placed from a hypothesis line//                                     segment farther than this will be//                                     regarded as an outlier// canny_th1           50            - First threshold for//                                     hysteresis procedure in Canny()// canny_th2           50            - Second threshold for//                                     hysteresis procedure in Canny()// canny_aperture_size 3            - Aperturesize for the sobel operator in Canny().//                                     If zero, Canny() is not applied and the input//                                     image is taken as an edge image.// do_merge            false         - If true, incremental merging of segments//                                     will be performedint length_threshold = 10;float distance_threshold = 1.41421356f;double canny_th1 = 50.0;double canny_th2 = 50.0;int canny_aperture_size = 3;bool do_merge = false;Ptr<FastLineDetector> fld = createFastLineDetector(length_threshold,distance_threshold, canny_th1, canny_th2, canny_aperture_size,do_merge);vector<Vec4f> lines;// Because of some CPU's power strategy, it seems that the first running of// an algorithm takes much longer. So here we run the algorithm 10 times// to see the algorithm's processing time with sufficiently warmed-up// CPU performance.for (int run_count = 0; run_count < 5; run_count++){double freq = getTickFrequency();lines.clear();int64 start = getTickCount();// Detect the lines with FLDfld->detect(image, lines);double duration_ms = double(getTickCount() - start) * 1000 / freq;cout << "Elapsed time for FLD " << duration_ms << " ms." << endl;}// Show found lines with FLDMat line_image_fld(image);fld->drawSegments(line_image_fld, lines);imshow("FLD result", line_image_fld);waitKey(1);Ptr<EdgeDrawing> ed = createEdgeDrawing();ed->params.EdgeDetectionOperator = EdgeDrawing::SOBEL;ed->params.GradientThresholdValue = 38;ed->params.AnchorThresholdValue = 8;vector<Vec6d> ellipses;for (int run_count = 0; run_count < 5; run_count++){double freq = getTickFrequency();lines.clear();int64 start = getTickCount();// Detect edges// you should call this before detectLines() and detectEllipses()ed->detectEdges(image);// Detect linesed->detectLines(lines);double duration_ms = double(getTickCount() - start) * 1000 / freq;cout << "Elapsed time for EdgeDrawing detectLines " << duration_ms << " ms." << endl;start = getTickCount();// Detect circles and ellipsesed->detectEllipses(ellipses);duration_ms = double(getTickCount() - start) * 1000 / freq;cout << "Elapsed time for EdgeDrawing detectEllipses " << duration_ms << " ms." << endl;}Mat edge_image_ed = Mat::zeros(image.size(), CV_8UC3);vector<vector<Point>> segments = ed->getSegments();for (size_t i = 0; i < segments.size(); i++){const Point *pts = &segments[i][0];int n = (int)segments[i].size();polylines(edge_image_ed, &pts, &n, 1, false, Scalar((rand() & 255), (rand() & 255), (rand() & 255)), 1);}imshow("EdgeDrawing detected edges", edge_image_ed);Mat line_image_ed(image);fld->drawSegments(line_image_ed, lines);// Draw circles and ellipsesfor (size_t i = 0; i < ellipses.size(); i++){Point center((int)ellipses[i][0], (int)ellipses[i][1]);Size axes((int)ellipses[i][2] + (int)ellipses[i][3], (int)ellipses[i][2] + (int)ellipses[i][4]);double angle(ellipses[i][5]);Scalar color = ellipses[i][2] == 0 ? Scalar(255, 255, 0) : Scalar(0, 255, 0);ellipse(line_image_ed, center, axes, angle, 0, 360, color, 2, LINE_AA);}imshow("EdgeDrawing result", line_image_ed);waitKey();return 0;}

提供一张名叫me.jpg的文件到build文件夹下

REF LINKS:

  • https://docs.opencv.org/3.4/d1/d9e/fld_lines_8cpp-example.html
  • https://www.cnblogs.com/JoyPoint/p/11629521.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/133946.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

智能语音和自然语言处理技术

一、定义 智能语音和自然语言处理技术是指通过计算机技术实现人机交互的一种技术。它可以让计算机和人类之间进行自然而流畅的交流&#xff0c;从而实现更高效、更便捷、更智能的信息交流和处理。 智能语音和自然语言处理技术主要包括语音识别、语音合成、自然语言理解、自然…

CRM客户管理系统究竟是什么?如何实施?

很多销售人员都不是特别喜欢使用信息化软件&#xff0c;然而从销售经理的角度看&#xff0c;信息化又的确提升了团队的管理效率和业绩。追究这些矛盾的原因&#xff0c;无外乎几点&#xff1a; 认知角度 → 销售员&#xff1a;数据没用又浪费我时间 VS 销售经理&#xff1a;数…

openssl交叉编译 (ubuntu+arm)

1.下载安装包 wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz 2.解压安装包 tar -zxvf openssl-1.1.1l.tar.gz 3.进入源码文件夹-修改编译器 CCarm-linux-gnueabihf-gcc 4.配置编译参数 ./config no-asm -shared --prefix/home/alientek/sp_test/openssl/sp…

Springboot 集成 mongodb

一、引入依赖 1.1 Maven <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> 二、yml 配置文件 data:mongodb:# 基础链接参数# 连接的库database: mongo…

单例模式读取配置文件

单例模式&#xff08;Singleton Pattern&#xff09;是一种常见的设计模式&#xff0c;它确保一个类只有一个实例&#xff0c;并提供一个全局访问点以获取该实例。当你需要在应用程序中读取配置文件时&#xff0c;使用单例模式可以确保你只创建一个配置对象&#xff0c;以避免重…

聊聊定时器 setTimeout 的时延问题

给大家推荐一个实用面试题库 1、前端面试题库 &#xff08;面试必备&#xff09; 推荐&#xff1a;★★★★★ 地址&#xff1a;web前端面试题库 全局的 setTimeout() 方法设置一个定时器&#xff0c;一旦定时器到期&#xff0c;就会执行一个函数或指定的代码片…

字符函数和字符串函数详解

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 目录 前言 1. 字符分类函数 2. 字符转换函数 3. strlen的使用和模拟实现 3.1strlen的使用&#xff1a; 3.2strlen的模拟实现&#xff1a; 4. strcpy的使用和模拟实现 4.1strc…

漏刻有时百度地图API实战开发(1)华为手机无法使用addEventListener click 的兼容解决方案

现象 漏刻有时项目开发中的调用了百度地图API&#xff0c;在PC端、IOS和安卓机型测试都没有问题。但是使用华为手机部分型号时&#xff0c;前端在监听点击事件的时候是使用 map.addEventListener(click,function(){...})&#xff0c;无法触发。或 原理 通过监听touchstart和…

FreeRTOS_低功耗Tickless模式

目录 1. STM32F4 低功耗模式 1.1 睡眠(Sleep)模式 1.2 停止(Stop)模式 1.3 待机(Standby)模式 2. Tickless 模式详解 2.1 如何降低功耗 2.2 Tickless 具体实现 2.2.1 宏 configUSE_TICKLESS_IDLE 2.2.2 宏 portSUPPRESS_TICKS_AND_SLEEP() 2.2.3 宏 configPRE_SLEEP_…

利用Caddy实现http反向代理

利用Caddy实现http反向代理 1 Caddy是什么 Caddy是一个开源的&#xff0c;使用Golang编写的&#xff0c;支持HTTP/2的Web服务端。它的一个显著特征就是默认启用HTTPS。 和nginx类似。 2 多个后端服务 假如现在有3个后端http服务&#xff1a;分别在启动在 app1 http://10…

Django初窥门径-自定义附件存储模型

前言 Django自带了一个名为FileField的字段&#xff0c;用于处理文件上传。然而&#xff0c;有时我们需要更多的控制权&#xff0c;例如定义文件的存储路径、文件名以及文件类型。在本篇文章中&#xff0c;我们将探讨如何自定义Django附件存储模型。 创建attachment应用 pyt…

Python|OpenCV-图像的添加和混合操作(8)

前言 本文是该专栏的第8篇,后面将持续分享OpenCV计算机视觉的干货知识,记得关注。 在使用OpenCV库对图像操作的时候,有时需要对图像进行运算操作,类似于加法,减法,位操作等处理。而本文,笔者将针对OpenCV对图像的添加,混合以及位操作进行详细的介绍说明和使用。 下面,…

ZKP8.1 Polynomial-IOP and Polynomial Commitment Schemes

ZKP学习笔记 ZK-Learning MOOC课程笔记 Lecture 8: FRI-based Polynomial Commitments and Fiat-Shamir (Justin Thaler) 8.1 Polynomial-IOP and Polynomial Commitment Schemes Recall: build an efficient SNARK Recall: Polynomial-IOP P’s first message in the pro…

YOLOv8轻量化模型:模型轻量化设计 | 轻量级可重参化EfficientRep| 来自YOLOv6思想

💡💡💡本文解决什么问题:在几乎不保证精度下降的前提下,轻量级模型创新设计 EfficientRep 在关键点检测任务中 | GFLOPs从9.6降低至8.5, mAP50从0.921下降至0.912,mAP50-95从0.697提升至0.779 YOLO轻量化模型专栏:http://t.csdnimg.cn/AeaEF 1.YOLOv6介绍 论文…

pandas教程:Data Transformation 数据变换、删除和替换

文章目录 7.2 Data Transformation&#xff08;数据变换&#xff09;1 删除重复值2 Transforming Data Using a Function or Mapping&#xff08;用函数和映射来转换数据&#xff09;3 Replacing Values&#xff08;替换值&#xff09;4 Renaming Axis Indexes&#xff08;重命…

API接口安全设计

简介 HTTP接口是互联网各系统之间对接的重要方式之一&#xff0c;使用HTTP接口开发和调用都很方便&#xff0c;也是被大量采用的方式&#xff0c;它可以让不同系统之间实现数据的交换和共享。 由于HTTP接口开放在互联网上&#xff0c;所以我们就需要有一定的安全措施来保证接口…

#龙迅视频转换IC LT7911D是一款高性能Type-C/DP/EDP 转MIPI®DSI/CSI/LVDS 芯片,适用于VR/显示应用。

1.说明 应用功能&#xff1a;LT7911D适用于DP1.2转MIPIDSI/MIPICSI/LVDS&#xff0c;EDP转MIPIDSI/MIPICSI/LVDS&#xff0c;TYPE-C转MIPIDSI/MIPICSI/LVDS应用方案 分辨率&#xff1a;单PORT高达4K30HZ&#xff0c;双PORT高达4K 60HZ 工作温度范围&#xff1a;−40C to 85C 产…

多比特杯武汉工程大学第六届ACM新生赛 A,L

为什么要演奏春日影&#xff01;&#xff01;&#xff01; 看到题目所说&#xff0c;若 b i b_i bi​在 i i i 之前&#xff0c;则…,那么很容易联想到拓扑排序&#xff0c;再仔细看题&#xff0c;对于每个 b i b_i bi​,我们都想其对应的 i 进行连边&#xff0c;那么我们很容…

webgoat-client side客户端问题

client side Bypass front-end restrictions 用户对 Web 应用程序的前端有很大程度的控制权。 它们可以更改 HTML 代码&#xff0c;有时也可以更改脚本。这就是为什么 需要特定输入格式的应用也应在服务器端进行验证&#xff0c;而不是只在前端做限制。 0x02 先提交请求&am…

win10虚机扩容C盘

需求&#xff1a; 在虚机管理平台上&#xff0c;将win10虚机的C盘空间扩容至200G&#xff0c;当前空间为100G 操作步骤 1.在虚机平台上&#xff0c;将硬盘1的大小增加至200G 如下图 点击保存&#xff1b; 查看win10虚机&#xff0c;发现C盘空间还是100G&#xff0c;如下图…