MATLAB Answers

0

Undefined function 'getsnapshot' for input arguments of type 'struct'

Asked by MrMedTech on 11 Mar 2016
Latest activity Answered by michael nabil on 11 Jan 2018
Hi,
I've customized an eye-tracking software in Matlab.
It works just fine, but so far I'm working on the details. I try to force the speed and so I found the possibility to parallize a few steps.
So I tried it with an easy example with using a 'parfor' instead of a general 'for'-loop.
While running it, there was an error within I'm told to add the file containing the parfor loop to te workers with using addAttachedFiles(); So I tried to include the file with the following command:
poolobj = gcp;
addAttachedFiles(poolobj,'boxcalibration.m');
But there is still the same Error und in addition it's told that
Error using boxcalibration (line 11)
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 eyetracking (line 48)
boxcalibration(fig,vid,scrsz);
Caused by:
Undefined function 'getsnapshot' for input arguments of type 'struct'.
Can someone help to handle that?
THX a lot

  0 Comments

Sign in to comment.

4 Answers

Answer by Image Analyst
on 11 Mar 2016

Does "ver" show that you have the Image Acquisition Toolbox installed? You probably need that - not sure if the webcam hardware support package has that function or not. Did you install the webcam packages at all? There are at least 2 packages you need to install for the webcam support. You can have either the webcam package, the Image Acquisition Toolbox, or both. Which do you have?

  0 Comments

Sign in to comment.


Answer by MrMedTech on 11 Mar 2016
Edited by Walter Roberson
on 15 Mar 2016

Computer Vision System Toolbox OpenCV Interface version 15.2.0
Image Acquisition Toolbox Support Package for OS Generic Video Interface version 15.2.0
Image Acquisition Toolbox Support Package for DCAM Hardware version
MATLAB Support Package for USB Webcams version 15.2.0
These are the ones dealing with cameras.
The Error only occurs, when I'm using the parfor attribute. When changing it to a general for-loop, everything works fine.
I also tried this in an extra File where I only made a general for loop in which I'm figuring a sin(x) and after it I did the same with a parfor...
So why ever it works but not as I expected because the parfor loop took much longer than the general one.
Maybe I should change the order of the loops but the key is, that it works in this small test file and not in my code.
What do you mean with 'ver'?
Thx for your quick answer

  1 Comment

Don't you know about the ver command? It means "version" and when you type that on the command line, it will show your license number and all the toolboxes you have bought.
Sorry I can't help more. My cameras work. You'll have to call tech support to find out why your getsnapshot() function does not work.
What does this say:
which -all getsnapshot

Sign in to comment.


Answer by MrMedTech on 15 Mar 2016

Thanks for your answer. I've just got started with matlab 3 weeks ago so I'm pretty unexperienced. The var command says that it's installed. And the which -all getsnapshot command tells me thr path to the function. My camera also works fine when I'm not runnin' it in de parallel mode. Maybe there is a format problem when transfering it between different kernels?

  0 Comments

Sign in to comment.


Answer by michael nabil on 11 Jan 2018

try using snapshot instead of getsnapshot it worked with me

  0 Comments

Sign in to comment.