Image acquisition in parallel via FireWire

1 view (last 30 days)
PeLa
PeLa on 25 Aug 2023
Commented: Image Analyst on 28 Aug 2023
Hi everyone,
I am trying to capture images from two cameras via firewire with Matlab. For this I use the parallel toolbox. I have oriented myself on the following example: https://de.mathworks.com/matlabcentral/answers/388286-how-can-i-acquire-images-from-multiple-gige-cameras-using-image-acquisition-toolbox-and-parallel-com . I do not use a GigE interface, so I have adapted the code accordingly.
The code I use is the following:
delete(imaqfind);
parpool(2)
spmd(2)
delete(imaqfind);
vid=videoinput('gentl',labindex, 'Mono8')
img=getsnapshot(vid);
end
This does not work, however. Does someone know what might be the error?
Many thanks in advance

Answers (1)

Image Analyst
Image Analyst on 25 Aug 2023
Post a screenshot of what you see when you run imageAcquisitionExplorer or imaqtool
If there are two cameras you should see two cameras. If they both use the same interface, there should be a unique ID for each one.
imaqfind() is a function and you should not delete it. Maybe you meant to run imaqreset instead?
Type imaqfind into the command window (without deleting it of course) and what does it show?
  5 Comments
PeLa
PeLa on 28 Aug 2023
Edited: PeLa on 28 Aug 2023
Thanks for your answer!
I did now the following, which kind of worked but somehow the cameras only take pictures sometimes I press the Run button, do you maybe know what might be the reason for this?
The error message is
Caused by:
Error using imaqdevice/getsnapshot (line 65)
The image acquisition device failed to start acquiring images.
What I also don't understand is why I have to call the cameras in both workers with the same number, i.e. in both workers I have to use videoinput('gentl',1, 'Mono8'), if I use videoinput('gentl',2, 'Mono8') for one camera, then there appears an error message.
if isempty(gcp('nocreate'))
parpool(2)
end
spmd(2)
if labindex==1
vid1=videoinput('gentl',1, 'Mono8')
else
vid2=videoinput('gentl',1, 'Mono8')
end
end
spmd(2)
if labindex==1
img1=getsnapshot(vid1);
else
img2=getsnapshot(vid2);
end
end
Many thanks in advance
Image Analyst
Image Analyst on 28 Aug 2023
I don't know how your user interface works. You don't have to snap images from both camera at the same time. You can snap them one at a time, you just need to be sure that when you get the image from camera #1 you use vid1 and when you get the image from camera #2 you use vid2. You can do that by making them globals and call this just in your startup routine.
app.vid1 = videoinput('gentl', 1, 'Mono8'); % Initialize video input object for camera 1.
app.vid2 = videoinput('gentl', 2, 'Mono8'); % Initialize video input object for camera 2.
After that use app.vid1 and app.vid2 (the global instances of those video input objects) in your button callback functions or wherever else you want (as long as app is in scope).
Tech support told me that you only need to get the video inputs once -- you do not want to call them every time you click a button on your GUI. Use getdata or getsnapshot as many times as you want without ever getting (or overwriting) the video input objects.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!