Time for action – creating a 3-D video from left and right videos

Assuming you have done everything right and shot your left and right video, you can follow the next steps to mix them into one that can be watched using a pair of red-cyan 3-D glasses (using the imfuse function we have already discussed in the previous chapter):

  1. First, load the two videos:
    >> left = VideoReader('left.avi'), % Open left video file
    >> right = VideoReader('right.avi'), % Open right video file
  2. Create and open a video file to write your results in:
    >> vidOut = VideoWriter('Vid3D.avi'), % Open 3D video file
    >>open(vidOut);
  3. Now we must loop through all the frames:
    >> for i = 1:left.NumberOfFrames  % For all frames
    l = read(left,i); % Load i-th left frame 
    r = read(right,i); % Load i-th right frame 
    %Fuse the right and left channel into a red-cyan false color image
    v3 = imfuse(r,l,'falsecolor','ColorChannels','red-cyan'),
    writeVideo(vidOut ,v3); % Write frame to video
    end
    close(vidOut);

What just happened?

This was pretty simple, right? The process of making a 3-D false-colored video is really a piece of cake, provided you have shot your left and right channels. The steps are very few, since the only things that have to be done are opening the input videos for the left and right camera, creating an output video for the fused 3-D frame sequence, and then reading each frame of the right and left channel and fusing them using imfuse. The generated image was written as a new frame in the output video. When the whole process was over, we closed the open video object used for writing, so that the video was finalized.

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

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