Measuring the diameter pictures of holes in metal parts, photographed with telecentric, monochrome camera with opencv

asked 2019-07-31 14:11:59 -0500

Setup:
Camera: Blackfly S Mono 20.0 MP
Lens: Opto telecentric lens TC23080
Lights: 16 green LEDS
Python: 3.7.3
openCV: 4.0+

Image sample:
image description

Case: There will be metal parts with different shapes from 5x5 to 10x10 size(cm). Inside these metal parts there are plenty of circular holes from 2 to 10~ that have to be detected very accurately. The actual size of holes are unknown, as there are huge variety of possible parts. The goal is to write generic algorithm with openCV, that could work with any metal parts and detect circular holes.

What we have tried: We have tried to detect the holes with HoughCircles algorithm with little to no success. The algorithm is either too sensitive, or it does not detect the holes at all. We have experimented with different param1 and param2 values with no success. We have also tried blurring the image and passing it through Canny before using HoughCircles, but such an approach did not produce better results. The very same algorithm works significantly better with lower resolution pictures. However, resolution cannot be sacrificed as accuracy is extremely important in this project.

image description

The above circles were detected with the following parameters: minradius=0 maxradius=0 dp=1 param1=100 param2=21 By playing around with the above parameters, we can get better results. The problem arises when we use the same parameters with different pictures.

The end result we want to get is the diameter of a given circle with great accuracy, and we want the same algorithm to be usable on different part pictures such as this one:

image description

What makes this problem different from the other ones posted is that we do not know the approximate radius of a given circle (so we cannot manipulate minradius and maxradius values).

The preferred language of the algorithm is python. Thank you in advance.

edit retag flag offensive close merge delete