Using getsnapshot in parfor function
Show older comments
Hello all,
I am trying to run this following code in parallel but got this error:
Error using realTime_pointGrey>(parfor body) (line 52)
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.
Error in realTime_pointGrey (line 50)
parfor id = 1:4
Caused by:
Undefined function 'getsnapshot' for input arguments of type 'struct'.
I am not very familiar with using addAttachedFiles, could you please help me?
The code I am working on:
parfor id = 1:4
% Get the snapshot of the current frame
data(:,id) = reshape(double(rgb2gray(getsnapshot(vid))),size(data0,1)*size(data0,2),1);
end
data_mean = mean(data,2);
Accepted Answer
More Answers (1)
Walter Roberson
on 3 Dec 2015
0 votes
If I understand correctly, the parallel workers do not have access to the image hardware devices.
With the code you posted, imagine that the workers did have access to the image hardware devices. You ask to getsnapshot() of the same video device in each of the workers. The result would, at best, depend upon the order the workers happened to execute in. What were you hoping to be able to do? Are you hoping to import images from several different devices?
Categories
Find more on Image Preview and Device Configuration 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!