Advertisement
Guest User

Untitled

a guest
Jun 15th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import imutils
  2. import cv2
  3.  
  4. img = cv2.imread('a.jpg')
  5. img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  6. # threshold image
  7. ret, threshed_img = cv2.threshold(blurred, 200, 255, cv2.THRESH_BINARY_INV)
  8. # find contours and get the external one
  9.  
  10. #edged = imutils.auto_canny(threshed_img)
  11.  
  12. ctrz = cv2.findContours(threshed_img, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
  13. cnts = imutils.grab_contours(ctrz)
  14. (cnts, boundingBoxes) = contours.sort_contours(cnts, method="left-to-right")
  15. boundingBoxes = list(boundingBoxes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement