How to use start and stop buttons to save video in app designer?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jessica West
am 30 Okt. 2023
Beantwortet: Jessica West
am 31 Okt. 2023
I am trying to create an app that will start recording video when the user presses 'start' and ends and saves the video when the user presses 'stop'.
Right now, the buisness part of my code looks a bit like this:
function StartCameraButtonPushed(app, event)
% preview video feed
app.vidObj = videoinput("winvideo", 1, "YUY2_1280x960");
app.vidObj.LoggingMode = 'disk';
vidImage = image(app.UIAxes,zeros(960,1280,3)); %If image resolution is 1280x960
preview(app.vidObj,vidImage);
end
% Button pushed function: StartRecordingButton
function StartRecordingButtonPushed(app, event)
app.vidWriteObj = VideoWriter('myVidFile.avi');
set(app.vidObj,'DiskLogger', app.vidWriteObj);
start(app.vidObj);
end
% Button pushed function: StopRecordingButton
function StopRecordingButtonPushed(app, event)
stop(app.vidObj);
app.vidWriteObj = get(app.vidObj, 'DiskLogger');
end
The video preview works, and 'myVidFile.avi' is created, but it is only one frame. What do I need to add besides the start() and stop() commands to make this work as intended?
1 Kommentar
Image Analyst
am 31 Okt. 2023
If you have any more questions, then attach your .mlapp file with the paperclip icon after you read this:
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!