Tracking object in video and plot path of object

16 views (last 30 days)
Hello,
I have one video and in that video i am tracking a car's particular one point through the video and i got success in that one
but i want to plot that (point on a car) point's path at a same on video. How can i do that??
Please help me
thank you in adavance

Accepted Answer

Image Analyst
Image Analyst on 7 Dec 2019
Extract a frame, find the car and add it's (x,y) coordinate to a growing list of them, then call "hold on" and plot the entire list of (x,y) coordinates on the frame. Here's a start
% Open up the VideoReader for reading an input video file.
inputVideoReaderObject = VideoReader(inputFullFileName)
% Determine how many frames there are.
numberOfFrames = inputVideoReaderObject.NumberOfFrames;
% Prepare a figure to show the images.
figure;
% screenSize = get(0, 'ScreenSize');
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Loop through the movie, writing all frames out.
allX = zeros(1, numberOfFrames);
allY = zeros(1, numberOfFrames);
for frame = 1 : numberOfFrames
% Extract the frame from the movie structure.
thisFrame = read(inputVideoReaderObject, frame); % Get the next frame in the video.
imshow(thisFrame);
[x,y] = FindCar(thisFrame); % however you do it...
allX(frameIndex) = x;
allY(frameIndex) = y;
plot(allX, allY, 'r.-', 'LineWidth', 2, 'MarkerSize', 25);
end
See several assorted, attached movie demos.
  4 Comments
Image Analyst
Image Analyst on 15 Nov 2021
That is a custom function that @MA khan or you write to find cars. That was not my concern - you can use whatever code you want to find the car(s) and return their location(s). My concern was what the poster asked and that was how to plot the one point he says he successfully got somehow. Perhaps if @MA khan sees this he can tell you how he got the location of the car, but personally I don't know or have that code.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!