# Detecting indentation on plate

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

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)

edit retag close merge delete

Sort by » oldest newest most voted

How consistent is the surface quality, and how consistent is the lighting? I might be inclined to try to isolate the the doughnut shape - the intensity seems pretty consistent. If you get that, then fitting circles to the inside and outside would be fairly straightforward.

I implemented the algorithms in this paper and I think I ended up using the MLS approach. I'm not saying this method is the best, but it worked well for my purposes. I did have to have some parameter searching loops (maybe threshold values, and I think canny parameters) to get it to work in varying lighting conditions.

I would definitely be experimenting with different (controllable) lighting arrangements. That could be a huge help

more

Official site

GitHub

Wiki

Documentation