Recording video from three webcams with app designer
조회 수: 16(최근 30일)
표시 이전 댓글
Hi All,
Posting again with more tags.
I am trying to create a simple MatLab app using the app designer. I have three USB webcams (named ANT, POST and MED) plugged into my laptop which have a resolution of 1080 x1920. The goal is to press a record button so a 5 second video records simultaneously from each camera at at least 25 fps.
I have posted the app and the 'push record button' callback code below:
I find the videos record and save to the current folder, however, the playback speed and duration of the videos is really variable and usually not 5 seconds.
Sometimes MatLab crashes and sends an error message that there is insufficient physical memory. My laptop has 16GB of RAM, however, having matlab open as well as running the app does use a lot.
I have tried packaging the app so it is a standalone .exe to use less RAM, however, this doesnt seem to work. Is this because without MatLab open, the app does not have a folder to store the output videos in? If so, how can I tell a standalone app to save files to a specific folder? would I have to add a browse folder box?
Also is the code incorrect? Do I need to set the individual properties of each video object? Or can a loop be used to make the code more succinct?
Any help much appreciated.
Many thanks.
The app looks like this:

My code for the properties and the record button pushed callback is:
properties (Access = private)
AntCam = videoinput('winvideo',2); % Description
PostCam = videoinput('winvideo',3); % Description
MedCam = videoinput('winvideo',4); % Description
Filename;
Date;
Sample;
end
% Button pushed function: RECORDButton
function RECORDButtonPushed(app, event)
%% Set Properties for Videoinput AntCam
app.AntCam.TimeOut = Inf;
app.AntCam.FrameGrabInterval = 1;
app.AntCam.LoggingMode = 'disk&memory';
app.AntCam.FramesPerTrigger = 1;
app.AntCam.TriggerRepeat = Inf;
app.AntCam.TimerPeriod = 5;
%% Set Properties for Videoinput PostCam
app.PostCam.TimeOut = Inf;
app.PostCam.FrameGrabInterval = 1;
app.PostCam.LoggingMode = 'disk&memory';
app.PostCam.FramesPerTrigger = 1;
app.PostCam.TriggerRepeat = Inf;
app.PostCam.TimerPeriod = 5;
%% Set Properties for Videoinput MedCam
app.MedCam.TimeOut = Inf;
app.MedCam.FrameGrabInterval = 1;
app.MedCam.LoggingMode = 'disk&memory';
app.MedCam.FramesPerTrigger = 1;
app.MedCam.TriggerRepeat = Inf;
app.MedCam.TimerPeriod = 5;
%% Construct VideoWriter objects and set Disk Logger Properties
vidWriterAnt = VideoWriter(([app.Date, app.Sample, app.Filename, 'ANT']),'MPEG-4');
vidWriterPost = VideoWriter(([app.Date, app.Sample, app.Filename,'POST']),'MPEG-4');
vidWriterMed = VideoWriter(([app.Date, app.Sample, app.Filename, 'MED']),'MPEG-4');
vidWriterAnt.Quality = 50;
vidWriterAnt.FrameRate = 25;
app.AntCam.DiskLogger = vidWriterAnt;
vidWriterPost.Quality = 50;
vidWriterPost.FrameRate = 25;
app.PostCam.DiskLogger = vidWriterPost;
vidWriterMed.Quality = 50;
vidWriterMed.FrameRate = 25;
app.MedCam.DiskLogger = vidWriterMed;
start(app.AntCam);
start(app.PostCam);
start(app.MedCam);
app.AntCam.TimerFcn = {'stop'};
app.PostCam.TimerFcn = {'stop'};
app.MedCam.TimerFcn = {'stop'};
clear app.AntCam
clear app.PostCam
clear app.MedCam
end
답변(1개)
Tatiana Leon
2021년 9월 5일
hi
I have a mistake
Undefined function 'videoinput' for input arguments of type 'char'.
Can somebody help me
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!