Different number of Frames, using vision.VideoFileReader and VideoReader()

2 次查看(过去 30 天)
Hey everybody, i am currently working on a fish detection and classification software and encountered following problem:
If i load one .avi video using
video = VideoReader(src);
and then look a the properties i see for example:
Video Parameters: 12.01 frames per second, RGB24 704x576.
116 total video frames available.
if i load the same video, using MATLABS compute vision software with
videoVisionTB = vision.VideoFileReader(src)
and i look also at the frames per sercond using
video.info
i get:
VideoFrameRate: 25
Note: For the exact same Video! To count the maximum Numbers of Frames i implemented a count variable i and incremented i in every loop by 1 with following code;
i = 0;
while(~isDone(videoVisionTB))
i = i+1;
frame = videoVisionTB.step();
end;
i get:
i = 241
So i started to wonder, what happens. For that i saved all the frames obtained by the while-loop in a 4-D Matrix to compare the frames. For this i used following code:
Lets say the 4-D Matrix in which all frames a stored is called frames, so i started to look at the similarities of following frames using
imshowpair(frames(:,:,:,x),frames(:,:,:,x+1));
To my surprise (or not?) i found out, that there are a lot of frames exactly the same after each other. But more suprisingly for me was, that it was not equally distributed. For example: First frame IS NOT equal to second frame. Second frame IS equal to third,fourth,fifth,sixth,seventh,eighth,ninth frame. Tenth frame IS NOT equal to the 8 frames before. Eleventh frame IS equal to the tenth frame. Twelfth frame IS NOT equal to the tenth nor eleventh frame. But then again 12.-17. are equal etc.
Later in the video it seems that always two following frames are the same.
So i implemented following code, to get the number of different Frames in the Video:
i=1;
j=0;
while(~isDone(videoVisionTB))
j = j+1;
frame = videoVisionTb.step();
if(j > 1 && ~isequal(frame,lastFrame))
i = i+1;
end;
lastFrame = frame;
end;
The value of i after this script is:
i=104
Note: Looking at the Video produced by the script above by just showing the different frames in vision.VideoPlayer, the Video looks also fluently.
So my question is: How does it come, that a) the two Matlab functions (VideoReader, vision.VideoFileReader) get different Numbers of the FrameCount of a video? b) where are the added frames come from, which seem to be just copies? c) why is the number of really different frames unequal to both of the FrameCounts of the Matlab-funtions (116 by VideoReader, 241 by vision.VideoFileReader, 104 by the script above)
I am concernd about this question because i am doing alot of complex algorithms on each frames, so it is a question of performingspeed for me.
(And i also like to understand where are things comming from...)
Did anybody oberserved the same issue or has experienced with this topic? Because of the background of my work i am only intrested in analysing frames with differ from each other, because exactly the same frames are not giving any new informations.
Thanks to everybody in advanced for reading this kind of long topic and spending time with me, finding answers.
Frederik

回答(1 个)

Frederik Kratzert
Me again, so i noticed, that i forgot to look on the 116 frames obtained by VideoReader() if there are also copies inside, and to my surprise i found out, that the 116 frames are all different. Comparing the 116 frames with the 104 frames obtained by vision.VideoFileReader i see, that there are some frames in the the video, which i dont get, loading the video with the Computer Vision System Toolbox.
Why is that so?!
So at the end, if i want to get all different picutres of the video, to not loose data, i need to go back to the good old VideoReader() function?!
Why do i not find any documentation about a) the loss of data, depending on the function to load a video b) where the copies in the video-data of the vision.VideoFileReader functions come from?!
Help me out please!!

Community Treasure Hunt

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

Start Hunting!

Translated by