MATLAB standalone App not working when installed on another system
12 次查看(过去 30 天)
显示 更早的评论
I designed a MATLAB App using MATLAB App Designer. My app plays videos corresponding to the given words. It works fine. Next, using MATLAB compiler I developed .exe file of my app. Using this .exe file I installed the app on different system. On this system, my app window opens but when I give words as input I don't get any video. I simply get blank GUI window of my app. Can anyone suggest some way out? Feel free to comment.
采纳的回答
Image Analyst
2023-8-27
See the FAQ for a list of common reasons your compiled app won't run on a target system:
Most likely it's a path problem where you are either not deploying the videos to the target system, or you are not specifying the full path name correctly in the code (like you're just assuming the videos should be in the current folder).
15 个评论
NAVNEET NAYAN
2023-8-27
% Button pushed function: PlayButton
function PlayButtonPushed(app, event)
alph = app.InputDataEditField.Value;
Folder = 'F:\test_vids';
% Folder = pwd;
for k=1:length(alph)
aFile = fullfile(Folder, alph(k) + ".avi");
videoFReader = VideoReader(aFile);
n=videoFReader.NumberOfFrames;
for m=1:n
frames=read(videoFReader,m);
imshow(frames, 'Parent', app.UIAxes);
end
end
end
This is how I am reading my video files. Using Folder = pwd, also didn't solve my issue.
Should there be the video files (that are to be played after giving input) deployed on the target system? While packaging I have included the video files along with code in MATLAB compiler.
I have visited the link provided by you but couldn't sort out my issues.
Image Analyst
2023-8-27
Add this:
aFile = fullfile(Folder, alph(k) + ".avi");
if ~isfile(aFile)
warningMessage = sprintf('Warning: file not found. Please check path.\n"%s"', aFile)
uiwait(warndlg(warningMessage));
% Pop open that folder in File Explorer if using Windows
if ispc
winopen(Folder);
end
break;
end
NAVNEET NAYAN
2023-8-27
I got an error message while using your code. Please find the attached screenshot.
Image Analyst
2023-8-27
That doesn't make sense. If you put that code inside the for loop, then break is certainly 100% allowed. I think you didn't have it inside your for loop. But regardless, you can replace it with return as well, which will get out of the function. Or you can replace it with "continue" which will not exit the for loop but try to read in the next video.
NAVNEET NAYAN
2023-8-27
Yes, I corrected it there was a mistake. Now I got an error stating Warning: file not found. Please check path. How can we give path on target system? Do we need to deploy videos on target system? If yes, then it is problematic for a general use purpose.
NAVNEET NAYAN
2023-8-27
Can you please suggest me some ways to develop a link between path of videos to be played and the app installed on the target system?
Image Analyst
2023-8-27
What kind of variable is alph? Isn't it just a string that the user type in? So you don't want to loop over every character in the filename with a for loop. That doesn't make sense. You just want to take the name and build the filename from it and loop over the individual frames ONLY. Here is much more robust code:
% Button pushed function: PlayButton
function PlayButtonPushed(app, event)
% Get base file name from edit field.
baseFileName = app.InputDataEditField.Value;
% Specify a folder in a fixed location.
folder = 'F:\test_vids';
% Folder = pwd;
% See if the folder exists.
if ~isfolder(folder)
warningMessage = sprintf('Warning: folder not found. Please check path.\n"%s"', folder)
uiwait(warndlg(warningMessage));
% Pop open that folder in File Explorer if using Windows
if ispc
winopen(folder);
end
return;
end
% If it gets here the folder is good.
% Build the filename from what the user typed in in the edit field.
fullFileName = fullfile(folder, baseFileName);
% See if the user specified an extension.
[f, baseFilenameNoExt, ext] = fileparts(baseFileName);
% If they did not specify an extension, tack on .avi.
if isempty(ext)
fullFileName = fullfile(folder, [baseFilenameNoExt, '.avi']);
end
% See if the avi file actually exists.
if ~isfile(fullFileName)
warningMessage = sprintf('Warning: file not found. Please check path.\n"%s"', fullFileName)
uiwait(warndlg(warningMessage));
% Pop open that folder in File Explorer if using Windows
if ispc
winopen(Folder);
end
return;
end
% If it gets to here both the folder and AVI file exist. So read it in.
videoFReader = VideoReader(fullFileName);
numFrames = videoFReader.NumberOfFrames;
for m = 1 : numFrames
thisFrame = read(videoFReader,m);
imshow(thisFrame, 'Parent', app.UIAxes);
drawnow; % Make sure axes updates immediately.
end
end
However, even this is not great. You should not force users to type in a filename. You should have a listbox where you call dir and load up the listbox with the filenames so they can simply click a filename in the listbox.
NAVNEET NAYAN
2023-8-28
Thanks a lot for all your efforts and time but I am still facing the same issue of path.
Image Analyst
2023-8-28
Upload your lastest .mlapp file along with any files it needs to launch (splash images, .mat files, etc.) and I'll run it and fix it.
NAVNEET NAYAN
2023-9-1
@Image Analyst Sorry for being so late in replying. Please find attached the latest .mlapp file and videos of 4 alphabets and one word as an example to run the app. The only thing is I am not able to upload is .mp4 or .avi file. So, I converted these files into .gif format. For running the app, you need to convert these .gif files to .mp4 files.
Please let me know if you require anything else.
Image Analyst
2023-9-1
Try zipping them up and attaching. I'm traveling the next 6 days without MATLAB so I won't be able to try anything for about a week.
NAVNEET NAYAN
2023-9-4
编辑:NAVNEET NAYAN
2023-9-5
Here, I have attached the .zip file that contains the .mlapp files and .mp4 files of few alphabets and words. My target is to display videos of alphabets, combination of alphabets (with space and without space) and words and run this app as a standalone app on a different system.
NAVNEET NAYAN
2023-9-11
@Image Analyst Did you get some time to look into the problem? I kept on trying to find a way but I couldn't find a solution.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)