HoughLinesP(image, rho, theta, threshold, lines=None, minLineLength=None, maxLineGap=None)
# coding=utf-8
import cv2
import numpy as np
img = cv2.imread('02.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gaus = cv2.GaussianBlur(gray,(3,3),0)
edges = cv2.Canny(gaus, 50, 150, apertureSize=3)
minLineLength = 100
maxLineGap = 10
lines = cv2.HoughLinesP(edges, 1, np.pi / 180, 100, minLineLength, maxLineGap)
for x1, y1, x2, y2 in lines[0]:
cv2.line(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.imshow("houghline",img)
cv2.waitKey()
cv2.destroyAllWindows()
到此這篇關(guān)于python opencv檢測直線 cv2.HoughLinesP的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)opencv檢測直線cv2.HoughLinesP內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!