Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import cv2
  2.  
  3. def draw_line_P(img, x1, y1, x2, y2, color = (255,255, 255), thickness = 3, lineType=cv2.LINE_AA):
  4.     cv2.line(img, (x1, y1), (x2, y2), color, thickness, lineType)
  5.  
  6. img=cv2.imread("C:\Program Files (x86)\Photos for TZ\6_2.png")
  7. img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  8. img_grayinv = cv2.bitwise_not(img_gray)
  9. result = img.copy()
  10. lines = cv2.HoughLinesP(img_grayinv, rho=1, theta=np.pi/720, threshold=230 ,minLineLength=150, maxLineGap = 15)
  11. for line in lines:
  12.     x1, y1, x2, y2 = line[0]
  13.     draw_line_P(result, x1, y1, x2, y2)
  14.  
  15. cv2.imwrite("C:\Program Files (x86)\Photos for TZ\result", result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement