Need to take simultanous snapshots from 2 gigE Devices-will parfor work? how?
1 view (last 30 days)
Show older comments
Hello there,
Im not a good programmer and need your help. Having two gige cams connected to my computer, I need them to take one snapshot each simultanously. No external trigger is currently available.
Trying to implement a parfor loop to aquire the simultanous snapshots but it doenst work.
Here the code:
clc,clear all,imaqreset
% Accessing both cams
cam = [videoinput('gige', 1),videoinput('gige', 2)];
cam1=cam(1);
cam2=cam(2);
% Display all valid trigger configurations.
triggerinfo(cam1)
triggerinfo(cam2)
triggerconfig(cam1, 'manual')
triggerconfig(cam2, 'manual')
% View the current trigger configuration.
currentConfiguration_cam1 = triggerconfig(cam1)
currentConfiguration_cam2 = triggerconfig(cam2)
% Initiate the acquisition.
start(cam)
% Verify no frames have been logged.
frameslogged_cam1 = cam1.FramesAcquired
frameslogged_cam2 = cam2.FramesAcquired
% Trigger the acquisition.
trigger(cam)
sizecam=size(cam,2);
parfor ii=sizecam
img1=getsnapshot(cam(ii));
img2=getsnapshot(cam(ii));
end
% Wait for the acquisition to end.
wait(cam);
% Determine the number frames acquired.
frameslogged_cam = cam.FramesAcquired
% frameslogged_cam2 = cam2.FramesAcquired
this is the error I get:
An UndefinedFunction error was thrown on the workers for 'getsnapshot'. This might be because the file containing 'getsnapshot' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached. See the documentation for 'parallel.Pool/addAttachedFiles' for more details.
Caused by: Undefined function 'getsnapshot' for input arguments of type 'struct'.
How can I solve this issue? Is there any other way to get the snapshots?
Thank you in advance
0 Comments
Answers (1)
See Also
Categories
Find more on GigE Vision Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!