Ask Your Question

Detecting indentation on plate

asked 2019-03-08 03:46:19 -0500

Darustc4 gravatar image

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)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-03-08 22:57:20 -0500

swebb_denver gravatar image

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

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-03-08 03:46:19 -0500

Seen: 99 times

Last updated: Mar 08 '19