Ball Detection with OpenCV

I need to use a low resolution image (320 x 240) in OpenCV and find a large exercise ball, blue or red. The ball is 25 inches wide and is NOT guaranteed to be completely round. I tried using HoughCircles with Canny-thresholded image. I have not had success. What am I doing wrong and what is the best way to get the size of a ball in pixels and where is it? This will allow me to calculate how far from the camera!

+3
source share
1 answer

Let me put all the other tips in one answer:

  • Use cv :: inRange () to get the correct color ( more info on this ). You might want to use something like RGB Normalization in advance to make sure you return the full ball.
  • Now you have the whole pixel that refers to the ball (and possibly some noise you need to get rid of). Retrieve the pixels that are farther to the left / right and the top / bottom in your ball (just like your connected component, which has a plausible size) to get the size of the ball. (If the ball should not be round, you probably want to take a larger value)
  • . ( "" , ;))

, , (, ), .

, .

+2

All Articles