Tracking balls in a video and find their specific locations when are leaving a specific point.

30 views (last 30 days)
Hi everyone. I need your help. It concerns a project that i need to do. Does anyone knows how i am tracking a balls in a video and find their specific location and time that left from a circle shape? I keep trying find something similar but i couldn't find something. Any help will be very appreciated. Thanks a lot.

Accepted Answer

Image Analyst
Image Analyst on 3 Jul 2016
My attached demo where I track a green Sharpie marker is similar.
  7 Comments
Image Analyst
Image Analyst on 7 Jul 2016
Read this, but better yet, just attach your code and video file with the paper clip icon. It should be simple for you to adapt it to find red instead of green - you probably just forgot to change the thresholds. If you don't change those of course, it will continue to find green.
Image Analyst
Image Analyst on 9 Jul 2016
Do you want to know when the centroid of the ball leaves the big circle, or when any part of the perimeter of the ball leaves the big circle?
Anyway, I looked at the video and it looks like my suggestion in one of your 3 other duplicate questions should work. Just use my video reading program, and then simplify it. Like make the background the average of the first 20 frame or so instead an adaptive one from the past few frames. Then subtract the frame from the background and see where the difference is more than some amount. Then find the boundaries and see where any of those points are within a radius of the center of the big circle. Not hard. I'm sure you can do it.

Sign in to comment.

More Answers (3)

ZENONAS ZENIOU
ZENONAS ZENIOU on 7 Jul 2016
Basically is the code that you send me with the green sharpie. So now basically i need to track one ball every time.

ZENONAS ZENIOU
ZENONAS ZENIOU on 8 Jul 2016
I have attached a file with the code. What basically i need to do is to saving the positions of each blob and the connect all the points and represent the path that the blob followed. Also imagine that in a video there is a circular shape where all the balls are moving through. What i need to do basically is to know where the blobs (ball) exiting that circular shape. Thanks a lot
  7 Comments
ZENONAS ZENIOU
ZENONAS ZENIOU on 8 Jul 2016
I cut a little bit of the actual video but this is the concept. What basically i need to do is to saving the positions of each blob and the connect all the points and represent the path that the blob followed. Also imagine that in a video there is a circular shape where all the balls are moving through. What i need to do basically is to know where the blobs (ball) exiting that circular shape. Thanks a lot.
Image Analyst
Image Analyst on 9 Jul 2016
Edited: Image Analyst on 9 Jul 2016
DO you want to know when the centroid of the ball leaves the big circle, or when any part of the perimeter of the ball leaves the big circle?
When I try to play the file in Windows Media Player it just shuts down immediately. So I can't see this file. Does it work with MATLAB?

Sign in to comment.


Image Analyst
Image Analyst on 9 Jul 2016
Try the attached script.
  8 Comments
Image Analyst
Image Analyst on 11 Jul 2016
No, because that should work. Perhaps something immediately clears it, like you're displaying another image? I put up outline masks over live video all the time and it's not a problem. Put a breakpoint on that plot call and then execute just that line and see if it puts up the red cross. If it does, then step through to find out what line of code makes it go away.
ZENONAS ZENIOU
ZENONAS ZENIOU on 11 Jul 2016
The red cross appears. I just want to see the coordinates where the balls exiting the circle. For the time where not balls are in the frames this is shown up: Processed frame 16 of 230 Area of frame 16 = 17. And when the blob appears this is shown: Area of frame 53 = 6986. distance from circle center for frame 53 = 4.550689e+02. What basically i need to do as a final result of this code is to plot a histogram and showing from which site of the circular shape did the balls exited the circular shape. So i thing i need to know the location of the blob when exiting the circle or at least the last position of the ball inside the circle before exiting the circle? Thanks again for your help

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!