How to capture video frames or images with uncompressed format in Image acquisition toolbox app,I'm using matlab-2013a and I have connected my logitech webcam c525 to the system
MATLAB: Image acquisition toolbox app
capture video frames
Related Solutions
Not sure what needs to be on the handles structure and what doesn't. This saves images every 10 seconds for me.
function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
info = imaqhwinfo; % Get info
feed = info.InstalledAdaptors; % Find available camera feeds
vid = videoinput(feed{1}); % Use first camera input, or whatever # camera
vid.TimerFcn = @trigger; % Specify function to execute for each period of time
vid.TimerPeriod = 10; % Period of time between timer events
triggerconfig(vid, 'manual'); % Set trigger to manual
vid.FramesPerTrigger = 1; % Specify number of frames to acquire per trigger
vid.TriggerRepeat = Inf; % Specify number of additional times to execute trigger
vid.ReturnedColorSpace = 'grayscale';vid.FramesAcquiredFcnCount = 1; % Number of frames that must be acquired before frames acquired event is generated
vid.FramesAcquiredFcn = @saveFrame;start(vid)handles.vid = vid;guidata(hObject, handles);end
I was playing with the order, though I don't think it's that important. I did change how vid.TimerFcn called the trigger. I also changed the saveFrame function a bit.
function saveFrame(src, event)image = getdata(src, 1);imwrite(image, [datestr(now,'yyyymmddHHMMSS') '.jpg']);end
You're trying to display an image in the YCbCr color space (that's what the I420 in your videoinput line means) with a function that is expecting RGB data.
If you do:
vid = videoinput('winvideo', 1, 'I420_640x480'); vid.ReturnedColorSpace = 'RGB';
then the toolbox will convert the data to RGB data when you call getsnapshot or getdata. If you actually want the YCbCr data you can omit changing the ReturnedColorSpace property and instead convert the data before displaying it:
frame = getsnapshot(vid); imshow(ycbcr2rgb(frame));
Best Answer