Вот мой код
Код: Выделить всё
def findHolds(img,detector = None):
img = cv2.GaussianBlur(img, (3, 5), 0)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
otsu, _ = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
edges = cv2.Canny(img,otsu, otsu * 2, L2gradient = True)
contours, _ = cv2.findContours(edges,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)
hulls = map(cv2.convexHull,contours)
mask = np.zeros(edges.shape,np.uint8)
cv2.drawContours(mask, list(hulls),-1, 255, -1)
if detector == None:
# Set up the detector with default parameters.
detector = buildDetector()
keypoints = detector.detect(mask)
return keypoints, hulls
Подробнее здесь: https://stackoverflow.com/questions/798 ... pencv-code