MATLAB: Converting video frames into image file using vision.VideoFileReader

convert_ frames_ into_image

for i = 1:nframes
frames = read(videoread,i);
imwrite(frames,['Image' int2str(i), '.jpg']);
im(i)=image(frames);
end
this is the code for videoReader.
i need the vision.VideoFileReader format.plz help
N.B: my matlab is 2018a

Best Answer

videoread = vision.VideoFileReader('YourFile.avi');
i = 0;
hold on
while ~isDone(videoread)
i = i + 1;
frames = step(videoread);
imwrite(frames,['Image' int2str(i), '.jpg']);
im(i)=image(frames);
drawnow()
end
release(videoread)
However, I do would recommend you consider removing the image() call, as you would simply be putting image on top of image. It would make more sense to,
videoread = vision.VideoFileReader('YourFile.avi');
i = 0;
hold on
while ~isDone(videoread)
i = i + 1;
frames = step(videoread);
imwrite(frames,['Image' int2str(i), '.jpg']);
if i == 1
all_images = frames;
else
all_images(:,:,:,i) = frames;
end
end
release(videoread)
after which you could
implay(all_images)