From: Mo on
hi everone,

I'm working on a project and i was woundering if anyone could help me with my problem. I'm using matlab r2009a where i filter a live video and display it real time with the original video "so i have two preview windows" one that previows the real live video and the other that previews the filtered one. What i want to do now is to have both videos in the same window. i've done some research and now i know how to create my own preview window but i have a problem insertting the other "filtered video" next to the live original video. So if anyone knows anything about how to have two previews in one window, please advice me

i've tried the following code to make my own preview window with a start and a stop button for viewing.

%%start of function
function mypreview_fcn(obj,event,himage)
% Example update preview window function.

% Get timestamp for frame.
tstampstr = event.Timestamp;

% Get handle to text label uicontrol.
ht = getappdata(himage,'HandleToTimestampLabel');

% Set the value of the text label.
set(ht,'String',tstampstr);

% Display image data.
set(himage, 'CData', event.Data)
%%end of function
%------------------------------------
%%start of code
% Create a video input object.
vid = videoinput('winvideo');

% Create a figure window. This example turns off the default
% toolbar and menubar in the figure.
hFig = figure('Toolbar','none',...
'Menubar', 'none',...
'NumberTitle','Off',...
'Name','My Custom Preview GUI');

% Set up the push buttons
uicontrol('String', 'Start Preview',...
'Callback', 'preview(vid)',...
'Units','normalized',...
'Position',[0 0 0.15 .07]);
uicontrol('String', 'Stop Preview',...
'Callback', 'stoppreview(vid)',...
'Units','normalized',...
'Position',[.17 0 .15 .07]);
uicontrol('String', 'Close',...
'Callback', 'close(gcf)',...
'Units','normalized',...
'Position',[0.34 0 .15 .07]);

% Create the text label for the timestamp
hTextLabel = uicontrol('style','text','String','Timestamp', ...
'Units','normalized',...
'Position',[0.85 -.04 .15 .08]);

% Create the image object in which you want to
% display the video preview data.
vidRes = get(vid, 'VideoResolution');
imWidth = vidRes(1);
imHeight = vidRes(2);
nBands = get(vid, 'NumberOfBands');
hImage = image( zeros(imHeight, imWidth, nBands) );

% Specify the size of the axes that contains the image object
% so that it displays the image at the right resolution and
% centers it in the figure window.
figSize = get(hFig,'Position');
figWidth = figSize(3);
figHeight = figSize(4);
set(gca,'unit','pixels',...
'position',[ ((figWidth - imWidth)/2)...
((figHeight - imHeight)/2)...
imWidth imHeight ]);

% Set up the update preview window function.
setappdata(hImage,'UpdatePreviewWindowFcn',@mypreview_fcn);

% Make handle to text label available to update function.
setappdata(hImage,'HandleToTimestampLabel',hTextLabel);

preview(vid, hImage);

%%end of code