How to find contour of black regions in white background ?
I have image like this, I want to find contours of black regions. How can I do it ?
I use following code
im = cv2.imread(img) plt.imshow(im) print(type(im)) gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) blurred = cv2.GaussianBlur(gray, (5, 5), 0) thresh = cv2.threshold(im, 60, 255, cv2.THRESH_BINARY_INV) cnts = cv2.findContours(thresh, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
How ever it gives an error like "TypeError: Expected Ptr<cv::umat> for argument 'image' ". Can you help me solve it ? Thnaks