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

Thread Subject:
real time video display problem..help?!

Subject: real time video display problem..help?!

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',...
       '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 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');
tic
 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
subplot(1,2,1)
set(gca,'unit','pixels',...
        'position',[ ((figWidth - imWidth)/6)...
                     ((figHeight - imHeight)/2)...
                       imWidth imHeight ]);
subplot(1,2,2)
set(gca,'position', [ ((figWidth - imW)/2)...
                     ((figHeight - imH)/2)...
                       imW imH ]);
% Set up the update preview window function.
setappdata(hImage,'UpdatePreviewWindowFcn',@mypreview_fcn);

preview(vid, hImage);

 end
%%end of code


any advice and thanks in advance...

Subject: real time video display problem..help?!

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:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/289374

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