当前位置:网站首页>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 .
边栏推荐
- China's peripheral catheter market trend report, technological innovation and market forecast
- 【练习-7】Crossword Answers
- [exercise-6] (UVA 725) division = = violence
- TCP's three handshakes and four waves
- HDU - 6024 Building Shops(女生赛)
- 信息安全-威胁检测引擎-常见规则引擎底座性能比较
- b站 实时弹幕和历史弹幕 Protobuf 格式解析
- MySQL授予用户指定内容的操作权限
- F - birthday cake (Shandong race)
- Opencv learning log 15 count the number of solder joints and output
猜你喜欢
1010 things that college students majoring in it must do before graduation
STM32 how to use stlink download program: light LED running light (Library version)
[exercise-5] (UVA 839) not so mobile (balance)
B - 代码派对(女生赛)
X-Forwarded-For详解、如何获取到客户端IP
Essai de pénétration (1) - - outils nécessaires, navigation
Penetration test (4) -- detailed explanation of meterpreter command
Ball Dropping
b站 實時彈幕和曆史彈幕 Protobuf 格式解析
Information security - threat detection - detailed design of NAT log access threat detection platform
随机推荐
Opencv learning log 18 Canny operator
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
B - Code Party (girls' competition)
Penetration test (4) -- detailed explanation of meterpreter command
Ball Dropping
Shell脚本编程
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
The most complete programming language online API document
[exercise-7] crossover answers
渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
CS zero foundation introductory learning record
HDU - 6024 building shops (girls' competition)
树莓派CSI/USB摄像头使用mjpg实现网页摄像头监控
渗透测试 ( 5 ) --- 扫描之王 nmap、渗透测试工具实战技巧合集
nodejs爬虫
Common configuration files of SSM framework
F - Birthday Cake(山东省赛)
Opencv learning log 19 skin grinding
Alice and Bob (2021牛客暑期多校训练营1)
【练习-5】(Uva 839)Not so Mobile(天平)