Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- def draw_line_P(img, x1, y1, x2, y2, color = (255,255, 255), thickness = 3, lineType=cv2.LINE_AA):
- cv2.line(img, (x1, y1), (x2, y2), color, thickness, lineType)
- img=cv2.imread("C:\Program Files (x86)\Photos for TZ\6_2.png")
- img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- img_grayinv = cv2.bitwise_not(img_gray)
- result = img.copy()
- lines = cv2.HoughLinesP(img_grayinv, rho=1, theta=np.pi/720, threshold=230 ,minLineLength=150, maxLineGap = 15)
- for line in lines:
- x1, y1, x2, y2 = line[0]
- draw_line_P(result, x1, y1, x2, y2)
- cv2.imwrite("C:\Program Files (x86)\Photos for TZ\result", result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement