How to optimize video writing if you have a folder full of images of a moving object, and you want to your movie to have a boundary around your object?
1 view (last 30 days)
Show older comments
Hello, I have an object that is moving throughout 200 images and I would like to add a border around the object in each image and stitch all these images into a movie.
I'm currently creating an invisible figure showing the image using hold on and plotting the edge around the object and taking the data from the current figure and saving the cData into a variable using that for a movie frame.
Although this meathod works it take a long time to write the movie and I was wondering if ther is a more efficient way to do this?
ds = imageDatastore('path_to_imgs') ;
video = VideoWriter('myVideoName');
open(video)
while hasdata(ds);
Img_with_obj = read(ds) ;
boundary_of_obj = bwboundaries(Img_with_obj);
figure('visible', 'off'), imshow(Img_with_obj)
hold on
visboundaries(boundary_of_obj)
hFrame = getframe(gca)
writeVideo(vide, hFrame.cData)
close(figure)
end
close(video)
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!