How to select specific frames (ex. every 10th frame) out of a video for further analysis?
Show older comments
I have an .avi video file with ca. 300,000 frames (7 FPS) and I would like to analyze every nth frame (for example, frame 1, 10, 20, 30, 40, etc.).
I have successfully uploaded the file in clusters of 1000 frames and the analysis (image tracking) works well if I include every video frame. But I cannot seem to get MatLab to loop through every nth frame.
I tried something like this:
FishVid = VideoReader('MP02a.avi')
VidInfo=get(FishVid);
numberOfFrames = FishVid.NumberOfFrames
vidHeight = FishVid.Height;
vidWidth = FishVid.Width;
i= 1;
while i<= numberOfFrames
currentFrame= read(VidInfo,i);
combinedString=strcat(int2str(i-1),'.jpg');
imwrite(i,combinedString);
i=i+700;
end
BUT, this 1. saves each frame but doesn't concatenate them for further analysis and 2. in its current form, just gives me blank .jpg images.
Any suggestions on how to do this? Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!