Guest User

Untitled

a guest
Nov 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3. image = cv2.imread('pipe_photo1.jpg')
  4. blurred = cv2.pyrMeanShiftFiltering(image,41,91)
  5. gray = cv2.cvtColor(blurred,cv2.COLOR_BGR2GRAY)
  6. ret, threshold = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
  7. _, contours, _ = cv2.findContours(threshold, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
  8. print (len(contours))
  9.  
  10. cv2.drawContours(image,contours, -1,(0,0,255),6)
  11. cv2.namedWindow("Display",cv2.WINDOW_NORMAL)
  12. cv2.imshow("Display",image)
  13. cv2.waitKey()
Add Comment
Please, Sign In to add comment