how to use boundary box algorithm for people tracking in GUI
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
this is my final year project about people tracking in video sequence using GUI.for the Gui.fig, i display 4 axes and have their on push buttons but I'm stuck with the last step to create the rectangle over their head using bounding box(the algorithm method that i used).so, can anyone help me with this method?and how can i create the bounding box frame by frame?
waiting...thank for the helps.
0 commentaires
Réponses (1)
Jacob Mathew
le 25 Sep 2024
Hey CHE,
Assuming you have the video and the bounding box coordinates from your model, you can write a script that reads the frame of the video and draw the corresponding bounding box. Then you can write that frame out into another output video. Rinse and repeat over all the frames to get the video with the bounding box. The following code snippet example dmeonstrates this, using the VideoReader and ViderWriter objects:
% Load the video
videoFile = 'InputVideo.mp4'; % Replace with your video file path
videoReader = VideoReader(videoFile);
% Prepare to write the output video
outputVideo = VideoWriter('OutputVideo');
open(outputVideo);
% Example: Dummy bounding box for illustration
% bboxes = [x, y, width, height];
bboxes = [0, 0, 50, 50]; % Replace with your detection results
while hasFrame(videoReader)
% Read the next frame
frame = readFrame(videoReader);
% Updating bboxes to simulate the algorithm tracking person
bboxes(1,1) = bboxes(1,1) +1;
bboxes(1,2) = bboxes(1,2) +1;
% Draw the rectangles on the frame
if ~isempty(bboxes)
frameWithBoxes = insertShape(frame, 'Rectangle', bboxes, 'LineWidth', 3, 'Color', 'yellow');
else
frameWithBoxes = frame; % No detection, keep the frame unchanged
end
% Write the frame to the output video
writeVideo(outputVideo, frameWithBoxes);
end
% Close the video file
close(outputVideo);
The input video is as follows:
The output video is as follows:
You can refer to the documentation of VideoReader & VideoWriter below:
The insertShape function used to draw the bounding box is from the Computer Vision Toolbox and its documentation is as follows:
0 commentaires
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!