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
i get:
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:
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:
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