Ask Your Question

Revision history [back]

import cv2

img = cv2.imread(r'C:\2.png', 0)

vis = img.copy()

mser = cv2.MSER_create()

regions = mser.detectRegions(img)

hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions[0]]

cv2.polylines(vis, hulls, 1, (0, 255, 0))

cv2.imshow('img', vis)

cv2.waitKey(0)

cv2.destroyAllWindows()