Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Detecting indentation on plate

Hello, I need to detect the indented circle(s) in the attached image: image description.

I've tried contour detection but nor the circles or the rectangle will appear as a contour (It only shows the contour of some shadows around the corners). Relevant code here:

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (5, 5), 0)
_, binim = cv2.threshold(gray, 120, 255, 1)  # inverted threshold (light obj on dark bg)
binim = cv2.dilate(binim, None)  # fill some holes
binim = cv2.dilate(binim, None)
binim = cv2.erode(binim, None)   # dilate made our shape larger, revert that
binim = cv2.erode(binim, None)

contours, hierarchy = cv2.findContours(binim, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)