当前位置:网站首页>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 earthwork equipment market trend report, technical dynamic innovation and market forecast
- TCP's three handshakes and four waves
- HDU - 6024 Building Shops(女生赛)
- The concept of C language array
- SSM框架常用配置文件
- D - function (HDU - 6546) girls' competition
- [exercise -10] unread messages
- Record of brushing questions with force deduction -- complete knapsack problem (I)
- 差分(一维,二维,三维) 蓝桥杯三体攻击
- CS zero foundation introductory learning record
猜你喜欢
B - 代码派对(女生赛)
渗透测试 ( 5 ) --- 扫描之王 nmap、渗透测试工具实战技巧合集
【练习-7】Crossword Answers
X-forwarded-for details, how to get the client IP
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
D - Function(HDU - 6546)女生赛
Matlab comprehensive exercise: application in signal and system
渗透测试 ( 1 ) --- 必备 工具、导航
Determine the Photo Position
Ball Dropping
随机推荐
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class
MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
X-forwarded-for details, how to get the client IP
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
7-1 understand everything (20 points)
Penetration test (4) -- detailed explanation of meterpreter command
Opencv learning log 13 corrosion, expansion, opening and closing operations
STM32 how to use stlink download program: light LED running light (Library version)
【练习-6】(Uva 725)Division(除法)== 暴力
Common configuration files of SSM framework
Record of brushing questions with force deduction -- complete knapsack problem (I)
The concept of C language array
China exterior wall cladding (EWC) market trend report, technical dynamic innovation and market forecast
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
Luogu P1102 A-B number pair (dichotomy, map, double pointer)
C 基本语法
MySQL grants the user the operation permission of the specified content
Vs2019 initial use
Frida hook so layer, protobuf data analysis