当前位置:网站首页>Opencv learning log 24 -- Hough transform 2 (maximum interval and minimum length can be limited)
Opencv learning log 24 -- Hough transform 2 (maximum interval and minimum length can be limited)
2022-07-06 16:07:00 【@Spring sauce】
Preface
This article focuses on opencv Use of Hough transform in .
One 、 Hough transform 2
// Third question Hough dash ( Maximum interval can be limited , The shortest length )
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
cv::Mat dst;
cv::Mat src = imread("C://Users//john//Desktop//1.jpg", 0);
std::vector<cv::Vec4i>lines;
Canny(src, dst, 75, 80, 3, false);
//cv::imshow("src", src);
//cv::imshow("dstMat", dst);
cv::HoughLinesP(dst, lines, 5, CV_PI / 180, 90, 20, 35);
std::vector<cv::Vec4i>::iterator it = lines.begin();
for (int i = 0; it != lines.end(); it++, i++)
{
//float rho = (*it)[0], theta = (*it)[1];
//cv::Point pt1, pt2;
//double a = cos(theta);
//double b = sin(theta);
//double x0 = a*rho;
//double y0 = b*rho;
//pt1.x = cv::saturate_cast<int>(x0 + 1000 * (-b));
//pt1.y = cv::saturate_cast<int>(y0 + 1000 * (a));
//pt2.x = cv::saturate_cast<int>(x0 - 1000 * (-b));
//pt2.y = cv::saturate_cast<int>(y0 - 1000 * (a));
cv::Point pt1, pt2;
pt1.x = lines[i][0];
pt1.y = lines[i][1];
pt2.x = lines[i][2];
pt2.y = lines[i][3];
//float k = (pt2.y - pt1.y) / (pt2.x - pt1.x);
//float b = pt1.y - pt1.x*k;
//pt1.x = 1000;
//pt1.y = k*pt1.x + b;
cv::line(src, pt1, pt2, cv::Scalar(255, 255, 255), 1, CV_AA);
}
cv::imshow("src", src);
waitKey(0);
}
summary
1. The code can run directly , If you don't understand, please leave a message .
边栏推荐
- [exercise-6] (UVA 725) division = = violence
- 【高老师UML软件建模基础】20级云班课习题答案合集
- Basic Q & A of introductory C language
- 【练习-8】(Uva 246)10-20-30==模拟
- The concept of C language array
- Web based photo digital printing website
- HDU - 6024 building shops (girls' competition)
- JS调用摄像头
- 渗透测试 ( 1 ) --- 必备 工具、导航
- Understand what is a programming language in a popular way
猜你喜欢
信息安全-史诗级漏洞Log4j的漏洞机理和防范措施
Optimization method of path problem before dynamic planning
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
C language must memorize code Encyclopedia
Gartner:关于零信任网络访问最佳实践的五个建议
Frida hook so layer, protobuf data analysis
Borg maze (bfs+ minimum spanning tree) (problem solving report)
渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
D - function (HDU - 6546) girls' competition
STM32 how to use stlink download program: light LED running light (Library version)
随机推荐
信息安全-威胁检测-flink广播流BroadcastState双流合并应用在过滤安全日志
Truck History
Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
Understand what is a programming language in a popular way
Penetration test (3) -- Metasploit framework (MSF)
B - Code Party (girls' competition)
渗透测试 ( 7 ) --- 漏洞扫描工具 Nessus
快速转 TypeScript 指南
【练习-6】(Uva 725)Division(除法)== 暴力
7-1 understand everything (20 points)
7-1 懂的都懂 (20 分)
1010 things that college students majoring in it must do before graduation
Write web games in C language
Find 3-friendly Integers
[exercise-9] Zombie's Treasury test
[exercise 4-1] cake distribution
Auto.js入门
【练习-4】(Uva 11988)Broken Keyboard(破损的键盘) ==(链表)
[exercise-5] (UVA 839) not so mobile (balance)
SSM框架常用配置文件