DEBUGGING FOR STANDALONE APP ?

6 ビュー (過去 30 日間)
Rakan Khair
Rakan Khair 2023 年 9 月 21 日
コメント済み: Walter Roberson 2025 年 4 月 26 日
Hope you are all doing well
I made an app using app designer to read a counter by screen shot using screencapture.m and to turn the light green if the number changed or red if stayed the same , when run with matlab it works great , but when trying it as a standalone exe on the same laptop the program does not work
classdef neuro < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Lamp matlab.ui.control.Lamp
LampLabel matlab.ui.control.Label
startButton matlab.ui.control.Button
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: startButton
function startButtonPushed(app, event)
for in=1:inf
imageData = screencapture(0, [700,700,150,100]);
imwrite(imageData,'flag.jpg');
flag=ocr(imread('flag.jpg'))
n=str2num(flag.Text)
pause(.5)
imageData = screencapture(0, [700,700,150,100]);
imwrite(imageData,'flag.jpg');
flag=ocr(imread('flag.jpg'))
x=str2num(flag.Text)
image= uiimage(app.UIFigure,"ImageSource",'flag.jpg');
image.Position=[256,288,200,200];
if mod(n,1)==0
if mod(x,1)==0
if x==n
app.Lamp.Color = 'r'
else
app.Lamp.Color = 'g'
end
end
end
end
  2 件のコメント
Steven Lord
Steven Lord 2023 年 9 月 21 日
What does "does not work" mean in this context?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support so we can investigate.
Rakan Khair
Rakan Khair 2023 年 9 月 22 日
編集済み: Rakan Khair 2023 年 9 月 22 日
Thank you for your reply
1-No Matlab work great and no error messages
2-when pressing the button for the standalone app nothing happens , but when pressing it using run in matlab appdesigner it works perfectly , the light goes red if number does not increase and green if it incease . in the designer the lamp does not change while the flag.jpg is changing.
3-no crash .
I am afraid that the app does not take OCR libarary because flag.jpg always changing as it is intended, is there anyway to debeug the app afte making it standalone?

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

採用された回答

Rakan Khair
Rakan Khair 2023 年 9 月 22 日
編集済み: dpb 2025 年 4 月 26 日
The issue was that I had to make matlab delete the old jpg file
I changed the code to
imageData = screencapture(0, [700,700,150,100]);
imwrite(imageData,'count.jpg');
flag=ocr(imread('count.jpg'))
n=str2num(flag.Text)
delete ('count.jpg')
imageData = screencapture(0, [700,700,150,100]);
imwrite(imageData,'count.jpg');
flag=ocr(imread('count.jpg'))
x=str2num(flag.Text)
delete ('count.jpg')
if mod(n,1)==0
if mod(x,1)==0
if x==n
app.Lamp.Color = 'r'
app.Label_2.Text=num2str(n)
pause(.5)
else
app.Lamp.Color = 'g'
app.Label_2.Text=num2str(n)
pause(.5)
end
end
end
  1 件のコメント
Walter Roberson
Walter Roberson 2025 年 4 月 26 日
You could have done
imageData = screencapture(0, [700,700,150,100]);
flag = ocr(imageData);
without needing to write to file at all.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by