Guest User

Untitled

a guest
Sep 18th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3.  
  4. gray = cv2.imread('image.png')
  5. edges = cv2.Canny(gray,50,150,apertureSize = 3)
  6. cv2.imwrite('edges-50-150.jpg',edges)
  7. minLineLength=100
  8. lines = cv2.HoughLinesP(image=edges,rho=1,theta=np.pi/180, threshold=100,lines=np.array([]), minLineLength=minLineLength,maxLineGap=80)
  9.  
  10. a,b,c = lines.shape
  11. for i in range(a):
  12.     cv2.line(gray, (lines[i][0][0], lines[i][0][1]), (lines[i][0][2], lines[i][0][3]), (0, 0, 255), 3, cv2.LINE_AA)
  13.     cv2.imwrite('out-image.jpg',gray)
  14.     cv2.imshow('img', gray)
  15.     cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment