当前位置:网站首页>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 .
边栏推荐
- Research Report of cylindrical grinder industry - market status analysis and development prospect forecast
- TCP's three handshakes and four waves
- 渗透测试 ( 3 ) --- Metasploit Framework ( MSF )
- 7-1 懂的都懂 (20 分)
- Research Report of peripheral venous catheter (pivc) industry - market status analysis and development prospect prediction
- Determine the Photo Position
- [exercise-6] (PTA) divide and conquer
- Luogu P1102 A-B number pair (dichotomy, map, double pointer)
- [exercise-7] crossover answers
- 信息安全-史诗级漏洞Log4j的漏洞机理和防范措施
猜你喜欢

渗透测试 ( 3 ) --- Metasploit Framework ( MSF )

D - function (HDU - 6546) girls' competition

Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack

D - Function(HDU - 6546)女生赛

Record of force deduction and question brushing
![[exercise-5] (UVA 839) not so mobile (balance)](/img/8e/48dcf75f7347b36301df6fc129c09d.png)
[exercise-5] (UVA 839) not so mobile (balance)

Web based photo digital printing website

B - Code Party (girls' competition)

STM32 learning record: LED light flashes (register version)

Gartner: five suggestions on best practices for zero trust network access
随机推荐
SSM框架常用配置文件
China potato slicer market trend report, technical dynamic innovation and market forecast
Opencv learning log 18 Canny operator
Opencv learning log 15 count the number of solder joints and output
[exercise-5] (UVA 839) not so mobile (balance)
Perform general operations on iptables
B - 代码派对(女生赛)
【练习-7】(Uva 10976)Fractions Again?!(分数拆分)
Penetration test (4) -- detailed explanation of meterpreter command
b站 实时弹幕和历史弹幕 Protobuf 格式解析
China's peripheral catheter market trend report, technological innovation and market forecast
Research Report of cylindrical grinder industry - market status analysis and development prospect forecast
快速转 TypeScript 指南
E. Breaking the Wall
信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
Opencv learning log 30 -- histogram equalization
Record of brushing questions with force deduction -- complete knapsack problem (I)
7-1 understand everything (20 points)
MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
C language learning notes