Image acquisition in parallel via FireWire
Show older comments
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
on 25 Aug 2023
1 vote
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
Walter Roberson
on 25 Aug 2023
imaqfind() as a function is not being deleted: imaqfind() is returning a value, and what is being returned is what is being deleted.
Image Analyst
on 26 Aug 2023
I think you should not be calling videoinput every time you want to get a snapshot. You should call it once for each camera to get the object, then call getsnapshot with the object of the camera you want, so try
vid1 = videoinput('gentl', 1, 'Mono8'); % Initialize video input object for camera 1.
vid2 = videoinput('gentl', 2, 'Mono8'); % Initialize video input object for camera 2.
% Now, later, call these as many times as you want
% without having to call videoinput again.
cam1Image = getsnapshot(vid1); % Get frame from camera #1.
cam2Image = getsnapshot(vid2); % Get frame from camera #2.
If that doesn't work there are alternative ways using functions like start() and getdata().
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.
Categories
Find more on Acquisition Using Image Acquisition Explorer in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
