I am using the MATLAB Image Acquisition Toolbox 'videoinput' function to try and capture large volumes of photos (~100 GB at a time) from an IO Industries Flare 48M camera. In an attempt to improve performance, I have used 'VideoWriter' to create an AVI object, and set the LoggingMode to disk. My understanding is that this should allow the captured images to be written directly to my SSD in the AVI file in (basically) real time.
What I observe instead, however, is that MATLAB appears to write the images to my RAM, which progressively fills up until the script crashes without acquiring the full number of frames. The script also takes substantially longer than it should to execute based off the frame rate and acquisition time, and that extra time seems to be spent transferring the files from the RAM to the AVI file on the disk.
Has anyone had similar problems using DiskLogging, and found better ways to write large numbers of images to the disk? Sample code below for capturing 3200 frames (about a 100 seconds of frames, far less than I want, but enough to fill my RAM):
delete(imaqfind);
totaltic = tic;
pth = 'D:\MATLAB Tests';
d = dir(sprintf('%s\\test*.avi',pth));
if ~isempty(d); setno = str2num(d(end).name(6:9)) + 1; else; setno = 1; end
fprintf('The set number is %04.0f\n',setno);
vid = videoinput('bitflow', 1, 'IOIndustries-Flare-48M30CCX.bfml');
src = getselectedsource(vid);
src.BuffersToUse = 50;
vid.FramesPerTrigger = 3200;
vid.LoggingMode = 'disk';
diskLogger = VideoWriter(sprintf('%s/test%04.0f',pth,setno),'Grayscale AVI');
vid.DiskLogger = diskLogger;
vid.Timeout = Inf;
% TriggerRepeat is zero based and is always one
% less than the number of triggers.
vid.TriggerRepeat = 0;
triggerconfig(vid, 'immediate');
fprintf('Starting acquisition.\n')
start(vid); toc(totaltic)
tic; wait(vid); t1 = toc
fprintf('Stopping.\n')
toc(totaltic)
stop(vid); fprintf('Stopped.\n')
while (vid.FramesAcquired ~= vid.DiskLoggerFrameCount) %Prevents deleting vid until logging has caught up to acquisition
pause(.1)
end
toc(totaltic)
fprintf('The number of frames acquired is %04.0f\n',vid.FramesAcquired);
fprintf('The number of frames logged is %04.0f\n',vid.DiskLoggerFrameCount);
delete(vid);
delete(imaqfind);