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:
Taking a frame from a live video

Subject: Taking a frame from a live video

From: David Elsdoerfer

Date: 15 Aug, 2010 14:43:03

Message: 1 of 2

Hey folks me again,

I'm still working on my project(see "Detecting Braille in an image") and now have a new problem to solve. I have to analyze a Live-Video constantly , take a frame when a Box comes in to view and reaches a certain spot and then analyze it for the Braille(I already have the algorithm for the last part). I can't find any functions or means to tell matlab to take a frame out of a Live Video(not a video previously stored on the pc but a video comming directly from a webcam). Thanks in advance for any suggestions and help.


Subject: Taking a frame from a live video

From: Adrian

Date: 22 Aug, 2010 06:16:04

Message: 2 of 2

You can do this with the UpdatePreviewWindowFcn. A good description of how to use this is actually found in the comments in the preview.m file. Search Matlab folder to find this preview.m file.

% create the video object with the desired resolution
vidobj = videoinput('winvideo', 1, info.DeviceInfo(1,1).SupportedFormats{1});

% create a handle to the axes where the image will be displayed
vidRes = get(vidobj, 'VideoResolution');
hImage = image( zeros(vidRes(2), vidRes(1), nBands), 'parent', handles.axes1);

% identify which function is associated with the UpdatePreviewWindowFcn
% video_preview_fcn (see below) is called automatically each time the camera has an i% mage available - you don't need to call this function
setappdata(hImage, 'UpdatePreviewWindowFcn', @video_preview_fcn);

% call preview to start the live image feed

% after you are done with real-time processing, set this function back to null
setappdata(hImage, 'UpdatePreviewWindowFcn', []);

%% ----------------------------------------------------------
function video_preview_fcn(obj, event, himage)
% this is called each time the camera makes a new frame available.
% the input arguments are passed automatically. You can add others if you need
% them, but they also have to be included where this function is created (above)
% do all your real-time processing here in this function

% you can get the time-stamp string associated with this image from:
tstampstr = event.Timestamp;

% you get the image in this function from:
im = event.Data;

% you actively need to display the image in this function
set(himage, 'CData', im, 'EraseMode', 'none');

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