DEBUGGING FOR STANDALONE APP ?

6 views (last 30 days)
Rakan Khair
Rakan Khair on 21 Sep 2023
Commented: Walter Roberson on 26 Apr 2025
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 Comments
Steven Lord
Steven Lord on 21 Sep 2023
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 on 22 Sep 2023
Edited: Rakan Khair on 22 Sep 2023
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?

Sign in to comment.

Accepted Answer

Rakan Khair
Rakan Khair on 22 Sep 2023
Edited: dpb on 26 Apr 2025
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 Comment
Walter Roberson
Walter Roberson on 26 Apr 2025
You could have done
imageData = screencapture(0, [700,700,150,100]);
flag = ocr(imageData);
without needing to write to file at all.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!