MATLAB: How to find centroid of moving object in a video

computer visionComputer Vision Toolboximage acquisitionimage processingImage Processing Toolboxobject trackingtracking

Hello, I am tryng to find velocity of a moving ball using Histogram tracking method, where I am able to track the ball successfully. Now I want to find the velocity of the moving ball, to do that first I have to find the centroids of the ball. So when I use function regionprops() it traces centroids of entire Frame, where as I only want to find the centroids of the ball which is been tracked. And after that I want to calculate the velocity of the same ball which is been tracked.
So how do I mark the centroid of only one object in entire frame?

Best Answer

You need to segment your objects in the frame first. Then call regionprops() to get the centroid of each blob. If blobs enter or exit the scene, or overlap each other, then you'll have to have special code to handle those situations. See my Image Segmentation Tutorial and attached demo.