Taking a frame from a live video

  • Follow


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.

David
0
Reply David 8/15/2010 2:43:03 PM

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
preview(vidobj);

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

%% ----------------------------------------------------------
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');
0
Reply Adrian 8/22/2010 6:16:04 AM


1 Replies
472 Views

(page loaded in 0.903 seconds)

Similiar Articles:













7/26/2012 3:54:44 PM


Reply: