Finding centroid of a specific object (running dog) in an image instead of centroids for many objects in the image

2 ビュー (過去 30 日間)
dog = imread('1.jpg');
Ibw = im2bw(dog);
Ibw = imfill(Ibw,'holes');
Ilabel = bwlabel(Ibw);
stat = regionprops(Ilabel,'centroid');
imshow(dog); hold on;
for x = 1: numel(stat)
plot(stat(x).Centroid(1),stat(x).Centroid(2),'ro');end
As you can see from the above and the title of the question, I am currently working on establishing my ground truth for my tracking model but determing the position (in x and y coordinates) of my dog. To estimate it I would like to use the centroid of my desired object of tracking (i.e dog) and so I would like to find the centroid of the object in image (a frame of the video), but the as you can see I am getting hundreds of centroids and non on the actual dog. How can I specify a specific region of my image (using regionprops function) to find centroid of my desired object. Thanks

採用された回答

Image Analyst
Image Analyst 2022 年 11 月 27 日
See my attached demo where I track a green Sharpie marker in a video.

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 11 月 25 日
That's just because you're doing an intensity threshold. You'd need to do some more sophisticated segmentation. Perhaps you need to subtract old frames from the current frame, as long as your camera is not moving. Or else define something that uniquely describes the dog.
  11 件のコメント
Walter Roberson
Walter Roberson 2022 年 11 月 27 日
You have a moving camera in a situation where you have no template image. You want to be able to detect an object that will be moving from the very first frame, before it has even moved.
In order to do that, you need a considerable amount of scene intelligence, such as numerous pictures of playing fields marked up according to whether the various objects in view are movable or immovable, so that when you later present the first image of the video the program can analyze the blobs to figure out which are stationary objects, marking the ones that are not stationary.
But even if you do that, you should expect the algorithm to fail. For example, much of the time, an orange pylon at the edge of the field would be immobile, just marking the boundaries, but it is possible for the pylon to be blown by the wind or to be mounted on something that is moving. Suppose it were a pylon that was moving in the video, which would be something obvious if you compared a few frames... but you expect your code to be able to pick it out on the first frame before you even know whether it is going to be stationary or not.
By expecting it to be able to pick out the dog on the first frame before it has a chance to move, you are effectively asking for a program with the intelligence to detect things that "don't belong" on the field.
Realistic video tracking programs without template images or gigabytes of scene data to analyze from, do not work that way. Instead, they use the first image as a template and look at the second frame relative to the first frame. 3 frames are usually enough to determine moving objects. The program might then go backwards and be able to mark where the moving object was in previous frames -- but the program does not already know from just the first frame which portion will be the moving object.

サインインしてコメントする。

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by