Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
real time video display!

Subject: real time video display!

From: Mo

Date: 17 Jun, 2010 16:33:04

Message: 1 of 2

hi everone,

i was woundering if anyone can help me with my prblem, i have created a preview vedio of my own, and in it i display a live video of my camera, what i have done is that i take that video "real time" and i do some filtering on it "also real time" now my problem is that i wanna show the filtered "real time" video in the same figure window i made.

i've tried the following code but an error occurs saying: "??? Error using ==> setappdata
Invalid object handle"

%%start of code
%initialize the webcam
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',...
       'Name','My Custom Preview GUI');
% Set up the push buttons
uicontrol('String', 'Start Preview',...
    'Callback', 'preview(vid)',...
    'Position',[0 0 0.15 .07]);
uicontrol('String', 'Stop Preview',...
    'Callback', 'stoppreview(vid)',...
    'Position',[.17 0 .15 .07]);
uicontrol('String', 'Close',...
    'Callback', 'close(gcf)',...
    'Position',[0.34 0 .15 .07]);

% Create the image object in which you want to
% display the video preview data.
vidRes = get(vid, 'VideoResolution');
imWidth = vidRes(1);%1
imHeight = vidRes(2);%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');
 while toc ~= 0
    x = getsnapshot(vid);

    % sharpening "filtering" the image with a scale from 0-1
    h = fspecial('unsharp',0.5);
    sharpened_Image = imfilter(x,h,'conv');
    imW = sharpened_Image(1);%1
    imH = sharpened_Image(2);%2
figWidth = figSize(3);%3
figHeight = figSize(4);%4
        'position',[ ((figWidth - imWidth)/6)...
                     ((figHeight - imHeight)/2)...
                       imWidth imHeight ]);
set(gca,'position', [ ((figWidth - imW)/2)...
                     ((figHeight - imH)/2)...
                       imW imH ]);
% Set up the update preview window function.

preview(vid, hImage);

%%end of code

any advice and thanks in advance...

Subject: real time video display!

From: FMC

Date: 22 Aug, 2010 16:13:24

Message: 2 of 2

Details on how to do real-time video image processing in Matlab are in the post at:

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us