You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
772 B

3 years ago
import sys
import cv2
import numpy as np
import matplotlib.pyplot as plt
def Houghlines(img_path, threshold, minLineLength, maxLineGap):
img = cv2.imread(img_path, 1) # 读取图片
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
linesP = cv2.HoughLinesP(gray_image, 1, np.pi / 180, threshold, None, minLineLength, maxLineGap)
for i_P in linesP:
for x1, y1, x2, y2 in i_P:
cv2.line(img, (x1, y1), (x2, y2), (0, 0, 255), 1)
cv2.imwrite('./output/HoughLinesP.jpg', img)
'''
输入一张任意某个边缘提取的结果图片threshold minLineLength, maxLineGap
输出边缘连接的结果的结果
'''
if __name__ == '__main__':
Houghlines(sys.argv[1], eval(sys.argv[2]), eval(sys.argv[3]), eval(sys.argv[4]))