MATLAB Answers

How to Capture frames from live streaming using camera? Each Time when the start button is clicked it should capture images after 5 seconds pause and save the images session-wise.

1 view (last 30 days)
saeeda saher
saeeda saher on 12 May 2019
Edited: saeeda saher on 12 May 2019
I have tried the following code,
(1) I want to the camera to stop when the session ends and strat again when the start button is clicked.
(2) I want to save the captured frames session wise into the folder.
please help me , I am biggner to MATLAB
% --- Executes on button press in camerabutton.
function camerabutton_Callback(hObject, eventdata, handles)
Folder = 'CapImages\';
vid =;
axes (handles.axes1)
hImage=image(zeros( 720,1280,3),'Parent',handles.axes1);
hImage = image(handles.axes1 ,zeros(720,1280,3));
preview (vid,hImage);
guidata (hObject, handles);
for iframe = 1:10;
frames = snapshot(vid);
imwrite(frames, fullfile(Folder, sprintf('%0d.jpg',iframe)));
f = msgbox({'Operation';'Completed'});

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!