17 lines
422 B
Python
17 lines
422 B
Python
import cv2
|
|
|
|
src = cv2.imread('apple.bmp', 1)
|
|
cv2.imshow('original', src)
|
|
imgray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
|
|
cv2.imshow('gray', imgray)
|
|
|
|
_, tresh = cv2.threshold(imgray, 127, 255, 0)
|
|
cv2.imshow('tresh', tresh)
|
|
|
|
contours, _ = cv2.findContours(tresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
|
|
cv2.drawContours(src, contours, -1, (0, 255, 0), 2)
|
|
cv2.imshow('eye', src)
|
|
cv2.waitKey(0)
|
|
cv2.destroyAllWindows()
|