Resizing live usb webcam feed in Preview
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am using preview to display live images from a USB camera using the webcam support package (I do NOT have the image acquisition toolbox). I would like to be able to double the size of each incoming frame before it displays. I do not want to do this by using repeated getsnapshot calls because that requires a while loop. I imagine the best way to resize each incoming frame before displaying it is by changing UpdatePreviewWindowFcn. However for some reason even when I set the UpdatePreviewWindowFcn to simply display "success" after each frame grab, it does not get called. Here is the code to set up the preview and define the function:
clear cam
close all force
cam = webcam(2);
hImage = image(zeros(480,640,3));
setappdata(hImage,'UpdatePreviewWindowFcn',@mypreview_fcn);
preview(cam, hImage);
and here is the 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.
ht.String = tstampstr;
% Display image data.
himage.CData = event.Data;
%Display success each time the function is called
disp('success')
end
The program displays the live preview fine otherwise and does not throw any errors. Can anyone figure out why the UpdatePreviewWindowFcn is not being called for each frame? Or can anyone figure out an alternative way to double the size of the actual images being displayed?
Thanks!
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!