1 | initial version |
please take a look at the docs, cv2.threshold
returns a ret, image
tuple, you have to use it like:
value, thresh = cv2.threshold(im, 60, 255, cv2.THRESH_BINARY_INV)
2 | No.2 Revision |
please take a look at the docs, cv2.threshold
returns a ret, image
tuple, you have to use it like:
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
value, thresh = cv2.threshold(im, cv2.threshold(blurred, 60, 255, cv2.THRESH_BINARY_INV)
# opencv 4.x:
cnts, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
# opencv 3.x:
# im2, cnts, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)