GKG DTH
GKG DTH

Reputation: 119

What's the best way to detect a white ball on the water surface by using opencv?

I put a small white ball on the water surface. Wind makes the white ball move in the water. I want to using the opencv to detect and track the ball.Because the background(water surface) is single color, also the ball is single color. I just use the color in hsv and set a threshold to detect the white color(ball). I think this way is easier and better than camshift, tld, Optical flow method. Now I have a problem, I detect the white color to find the ball, but sometimes the wind is strong and water wave will happen follow the ball. Just like the pic as follow

enter image description here

The wave is also have white color in hsv. So i when i use findcontours to get the edge of ball, i will get the edge including ball and wave. I have tried to use erode and dilate to remove the wave noise.But i can't get a good result. I have no idea now. Can you help and show me how can i remove the wave in a better way? I'm not sure just using color to detect ball is a best choice in my case. Maybe I should try camshift, tld, Optical flow method? Can you show your idea to me?Thanks in advance!!

Upvotes: 1

Views: 1082

Answers (1)

skm
skm

Reputation: 5679

I can't think of a perfect solution at the moment but I can suggest you a strategy which can atleast help you to mis-detect the ball.

The optical flow of the whole scene can help you to find the velocities of all pixels or selected keypoints. Once you find the velocity of your scene then, you need to set a threshold value so that you stop detecting the ball if the velocity of your scene is higher.

Waves -> water moves fast-> velocity of pixels increases (in x or y direction) -> optical flow will tell you this situation -> stop ball detection by HSV method.

In another words, apply your existing HSV method based ball detection method only if the water is not moving too fast and you can know that velocity using optical flow method.

Upvotes: 1

Related Questions