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):
First, load the two videos:
>> left = VideoReader('left.avi'); % Open left video file >> right = VideoReader('right.avi'); % Open right video file
Create and open a video file to write your results in:
>> vidOut = VideoWriter('Vid3D.avi'); % Open 3D video file >>open(vidOut);
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);