Time for action – don't wait for the ball

In one of our previous examples, we used the video called singleball.avi, which is included in MATLAB as a demo. This video portrays a static box and a green ball that enters from the left of the frame and passes underneath the box to exit from the right part of the frame. Of course, without inspecting the video, we have no idea when the ball enters our frame. It could be at the beginning of the video, or maybe we would have to wait a while until we see it. So let's inspect all the frames to get a better idea:

  1. First off, we load the video using VideoReader:
    >> vObj = VideoReader('singleball.avi'),
    >> video = read(vObj);  % read in all frames from video object
  2. Now, we have our video stored in a four-dimensional matrix. This is enough for montage to take over:
    >> montage(video,'Size',[5 9]) % Using a 5x9 grid for 45 frames
  3. The result of the preceding steps is as follows:
    Time for action – don't wait for the ball

What just happened?

Now we are in a position to pinpoint the frames that are most useful for us. As we can remember from the previous example in which we used the same video, it comprises of 45 frames. Thus, our call to montage with a 5 x 9 grid as input is rather intuitive, since it will fit all frames without leaving any empty spaces. As you can easily observe, the ball enters our scene at the 13th frame and exits at the 42nd frame. Of course in this example the number of frames we would exclude knowing this information is small (12 at the beginning and 3 at the end), but it still is 1/3rd of the entire video. However, imagine a long video with only a few frames containing motion. This overall inspection tool would be a lifesaver in terms of time and effort. It can also be invaluable in artistic or other video editing tasks, since we can quickly skim through chunks of frames and pinpoint the ones we want to process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset