0

I am trying to detect each ball, count how many there are, and get their location. I am currently using Canny Edge Detection for that which works pretty well if the balls don't touch each other:

Canny Detection with balls not touching each other

The problem I have is that if the balls are touching, it is not possible to differentiate between them anymore and they are treated as one object:

Canny Detection with balls touching each other

I tried to use HoughCircles, but found that this only works well with actual circles, not distorted ones.

So how would I go about finding a solution? Is there any algorithm that fits better for this problem, or can I somehow work out the individual circles in each contour?

beaker
  • 16,331
  • 3
  • 32
  • 49
Snaw3
  • 3
  • 3
  • I think there is too much noise inside of yozr balls, but maybe you find an inspiration in my answer to this question: https://stackoverflow.com/q/34650697/2393191 – Micka Mar 06 '22 at 20:39

1 Answers1

0

What you could try is to filter the frame on red and green, so you get the contours of your balls. Then use a watershed algorithm to separate the contours.

Watershed example: https://docs.opencv.org/4.x/d2/dbd/tutorial_distance_transform.html

Epsi
  • 115
  • 7