Layering Two Web Cam Streams - Matlab

I currently have a code in Matlab that takes images from two webcams, overlays them and displays them on a figure that is updated at a time interval to give semi-real secret. However, I need to do this in real time, does anyone have an idea on how to overlay two webcam streams, as you would with a 3D movie?

Thank!

+5
source share
2 answers

If you mean Anaglyph 3D , with both images, you can do the following:

left = imread('vipstereo_hallwayLeft.png');
right = imread('vipstereo_hallwayRight.png');

imshow(cat(3, left(:,:,1), right(:,:,2:3)));

both pngs already come with an image processing panel.

The result will be like this (and you can look at it with red / blue glasses.) image

:
1. 2 , , ;
2. 2 , . ( )
.


, 2 -, :
1. ,
2. 1 ,
3. ;
4. .

2 -, , , :

:

% Get a handle to each cam
Lvid = videoinput('winvideo', 1, 'YUY2_1280x1024');
Rvid = videoinput('winvideo', 2, 'YUY2_1280x1024');

% Set them to get one frame/trigger
Lvid.FramesPerTrigger = 1;
Rvid.FramesPerTrigger = 1;

, , .

while(1)
    % Trigers both video sources
    start(Lvid);
    start(Rvid);

    % Get the frames
    left = getdata(Lvid);
    right = getdata(Rvid);

    % Convert them to RGB
    left = ycbcr2rgb(left);
    right = ycbcr2rgb(right);
    % mix them (R from right + GB from left)
    frame = cat(3, left(:,:,1), right(:,:,2:3));
    % show
    imshow(frame);
    pause(0.0001) % to refresh imshow 
end

, - YUV, RGB .

, !

+1

OpenCV.

0

All Articles