当前位置:网站首页>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-7] crossover answers
- Research Report of cylindrical grinder industry - market status analysis and development prospect forecast
- 【练习-4】(Uva 11988)Broken Keyboard(破损的键盘) ==(链表)
- Opencv learning log 14 - count the number of coins in the picture (regardless of overlap)
- Luogu P1102 A-B number pair (dichotomy, map, double pointer)
- China potato slicer market trend report, technical dynamic innovation and market forecast
- [exercise-3] (UVA 442) matrix chain multiplication
- Penetration test (3) -- Metasploit framework (MSF)
- China exterior wall cladding (EWC) market trend report, technical dynamic innovation and market forecast
- Hdu-6025-prime sequence (girls' competition)
猜你喜欢

b站 实时弹幕和历史弹幕 Protobuf 格式解析

渗透测试 ( 1 ) --- 必备 工具、导航

7-1 understand everything (20 points)

【高老师UML软件建模基础】20级云班课习题答案合集
![[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class](/img/3b/dc43564a36f82e73826b08f39c935e.png)
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
![[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class](/img/57/bc6eda91f7263acda38b9ee8732318.png)
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class

C language learning notes

Optimization method of path problem before dynamic planning
![mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’](/img/e6/f4a696179282fe1f4193410c5a493a.png)
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’

b站 實時彈幕和曆史彈幕 Protobuf 格式解析
随机推荐
Alice and Bob (2021 Niuke summer multi school training camp 1)
快速转 TypeScript 指南
Opencv learning log 18 Canny operator
[exercise-2] (UVA 712) s-trees
JS调用摄像头
If you want to apply for a programmer, your resume should be written like this [essence summary]
Luogu P1102 A-B number pair (dichotomy, map, double pointer)
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
Determine the Photo Position
Flink 使用之 CEP
C basic grammar
[exercise-7] (UVA 10976) fractions again?! (fraction split)
F - birthday cake (Shandong race)
The concept of C language array
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
[exercise-6] (PTA) divide and conquer
Opencv learning log 13 corrosion, expansion, opening and closing operations
Research Report on market supply and demand and strategy of China's earth drilling industry
b站 实时弹幕和历史弹幕 Protobuf 格式解析
【练习4-1】Cake Distribution(分配蛋糕)