import cv2
import numpy as np
img = cv2.imread('lane.jpg')
# img = cv2.imread('pic2.PNG')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 200, apertureSize=3)
minlinelength = 200
maxlinegap = 20
lines = cv2.HoughLinesP(edges, 1, np.pi/180, 100, minlinelength, maxlinegap)
for line in lines:
for x1, y1, x2, y2 in line:
cv2.line(img, (x1, y1), (x2, y2), (0, 0, 255), 6)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Python 21.opencv 霍夫直线变换
猜你喜欢
转载自blog.csdn.net/qq_36071362/article/details/104215972
今日推荐
周排行