I trained my neural network and want to apply it on key frames extracted from real time video and I can't understand how to extract key frames from live video.?

1 visualizzazione (ultimi 30 giorni)
How to extract keyframes from real-time video until video is stopped deliberately.

Risposte (1)

Walter Roberson
Walter Roberson il 11 Giu 2016
There is no method built into MATLAB that allow you to extract key frames from videos. The marking of frames as I frames (key frames) or P frames or B frames, is something done deep in the binary file representation of multimedia files. MATLAB uses pre-written standard software libraries in C or C++ to read the movies, and for everything more advanced it passes the responsibility off to operating-system provided multimedia libraries. Those libraries do not offer any mechanism to extract only the I frames. Only fully-decoded frames are provided back up to the user: there is no way at all for the user to read a frame and ask whether the frame was an I, B, or P frame.
It would be a huge waste of time to write the movie decoding libraries in MATLAB just to be able to extract the I frames. You would be better advised to start with a standard library such as mmpeg or gstreamer and modify their C or C++ code to provide you with the option to return only the I frames.
There is not always anything special about key frames. Encoders build key frames under two circumstances:
1) They are encoding to a standard that states a maximum number of intermediate frames between key frames and to meet the standard it is time to generate an I frame (key frame); or
2) They are keeping track of the accumulated complexity of building up a frame from B and P frames relative to the last I frame, and the model they have been instructed to use of the computing capacity of the playback device indicates that it would take more time to put together the frame incrementally than the playback device can spare, so it is necessary to generate an I frame as those are the lowest complexity. You might notice that this is not an absolute measure: for example a Blue Ray encoder is permitted to assume that it will be played back with a decoder that is faster than the standards mandate for a plain DVD player. Likewise, because 3D movies take more decoder capacity than non-3D movies, the encoding of a 3D movie is permitted to use fewer key frames since the decoder should be able to keep up. It is even considered legitimate for movies to be encoded at several different rates, with the playback rate chosen automatically according to the decoder's knowledge of how fast the decoder is.
I would recommend that for the scope of your project, you should instead just train your network on every N'th frame, like every 50th frame, or perhaps every 22nd frame (about one per second.)

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by