superimposes realitime web cam stream

I have a webcam stream in a GUI, what I need to do is have two webcams in this one preview window in the GUI superimposed on eachother in real time. I have this following code which refreshes a figure window with images on top of eachother.
clear all
close all
clc;
vid = videoinput('winvideo',1, 'YUY2_640x480');
vid1 = videoinput('winvideo',2, 'YUY2_640x480');
% to convert to rgb colors
vid.ReturnedColorSpace = 'rgb';
vid1.ReturnedColorSpace = 'rgb';
set(vid,'FramesPerTrigger',1);
set(vid1,'FramesPerTrigger',1);
while (1)
start(vid);
start(vid1);
%retrieves all the frames acquired at the last trigger
data = getdata(vid);
data1 = getdata(vid1);
%to display them in one video
result=data+data1;
imshow(result);
drawnow;
end
stop(vid),delete(vid),clear vid;
Can anyone help me to do this in a preview in real time?
Thanks alot.

This question is closed.

Asked:

on 28 Mar 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!