MATLAB Answers

Error when running compiled application: Undefined function ’webcammex'

9 ビュー (過去 30 日間)
I am using the Application Compiler to deploy my Matlab program (2015b). The packaging is successful but when I run it I’m getting the error:
Undefined function or variable 'webcammex'.
Error in matlab.webcam.internal.Utility.enumerateWebcams
Error in webcamlist (line 25)
Error in ...
MATLAB:UndefinedFunction
Does anyone know what’s causing this and what file I need to add when I compile the application?
Thanks.
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 12 日
FInd the webcammex.w32 file and add it to the dependencies ?

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2020 年 5 月 15 日
I had this problem today and will show you how to fix it. When it hit
webcamlist
it threw the error: "Unrecognized function or variable 'webcammex'." Normally that command in the development environment would give something like this:
>> webcamlist
ans =
1×1 cell array
{'Integrated Webcam'}
So the webcam worked in development environment but not in the compiled standalone Windows executable, even though I had the required Support Package installed. Now I will tell you how to fix it.
First make sure you have the support package installed by going to the Home tab of the tool ribbon and selecting Add-Ons\Get Add-Ons.
Install the "MATLAB Support Package for USB Webcams".
Now, here's the unexpected thing (and why I had to call tech support). Unlike toolbox functions, Support Package functions are not automatically found and included/built-in to your function when you compile it. They need to be specifically added in with the '-a' option of the mcc function/command. So here is essentially how we got it to work (finally, after 20 minutes of trying different things with tech support):
mFileName = 'my_webcam_app.m'; % or whatever it's called. Change to match your m-file's name.
outputFolder = 'C:\My MATLAB Executables'; % Or wherever you want the compiled "my_webcam_app.exe" to go.
fprintf('Beginning compile of %s application at %s ...\n', mFileName, datestr(now));
tic;
% Now we're ready to compile.
% But first, make sure you change R2020a in the line below to whatever release year you're using.
mcc('-m', mFileName, '-d', outputFolder, '-a', 'C:\ProgramData\MATLAB\SupportPackages\R2020a\toolbox\matlab\webcam\supportpackages');
% Done compiling. Tell developer that we're done, and how long it took to compile.
elapsedSeconds = toc;
minutes = int32(floor(elapsedSeconds / 60));
seconds = elapsedSeconds - 60 * double(minutes);
message = sprintf('It is done compiling %s at %s. It took %d minutes and %.1f seconds.\n', mFileName, datestr(now), minutes, seconds);
fprintf('%s\n', message);
msgboxw(message);
For more information, here is the documentation link I got from Tech support:
This is the resource I mentioned that describes how to include a support package for compiled applications:
I hope this helps you get your compiled webcam application working. If it was helpful, then please click the Vote button up at the top of my Answer.
  1 件のコメント
Bernard Rivera Camacho
Bernard Rivera Camacho 2020 年 6 月 3 日
Hello Thanks for the reply it was the good solution.
Now my code is working. :)

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by