Image acquisition with multiple cameras in a loop

9 次查看(过去 30 天)
Hello,
I want to use a number of cameras to acquire images from the cameras one after the other and as fast as possible.
When I use the script below to get the images from the cameras with a loop and "getdata" I get an error after a while:
"GETDATA timed out before FRAMES were available."
"The error message on your Linux machine is caused by the delay between the device and MATLAB, which is not a constant value and this related to your system and device driver. This is the reason why it happens at random iterations. Due to the delay, there are no available frames when the time exceeds the Timeout value."
(Note: I am using Windows 10 but I guess this does not matter here) To get rid of this error I tried to make sure that there is an available frame in the buffer with the out commented lines in the code below (where I check for "FramesAvailable"). But now it gets stuck in the while-loop as there is never an frame available. I am not sure what I am doing wrong here, but I guess I have a misunderstanding of a basic thing.
Thanks in advance for any help!
% remove any existing objects
objects = imaqfind;
delete(objects);
% define basic camera parameters
frames = 10;
num_cams = 5;
% define how to store the images
mode = 'memory';
% create cells for the cam objects and to store the images
vid_cell = cell(num_cams,1);
data_cell = cell(num_cams,1,frames);
% initialize cameras
for ii = 1:num_cams
if ii == 1 || ii == 2
vid_cell{ii,1} = videoinput('winvideo', ii, 'I420_3840x2160');
else
vid_cell{ii,1} = videoinput('winvideo', ii, 'RGB8_1936x1096');
end
% create the trigger
triggerconfig(vid_cell{ii,1}, 'manual');
set(vid_cell{ii,1},'TriggerRepeat',Inf);
set(vid_cell{ii,1},'FramesPerTrigger',1);
vid_cell{ii,1}.LoggingMode = mode;
start(vid_cell{ii,1})
end
for jj = 1:frames
for kk = 1:num_cams
% while get(vid_cell{kk,1},'FramesAvailable')<1 %Wait until at least 1 frame is available
% unavailable = 1;
% end
trigger(vid_cell{kk,1});
data_cell{kk,1,jj} = getdata(vid_cell{kk,1});
end
end
for mm = 1:numcams
stop(vid_cell{mm,1})
end

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by