DEBUGGING FOR STANDALONE APP ?

6 Ansichten (letzte 30 Tage)
Rakan Khair
Rakan Khair am 21 Sep. 2023
Kommentiert: Walter Roberson am 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 Kommentare
Steven Lord
Steven Lord am 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 am 22 Sep. 2023
Bearbeitet: Rakan Khair am 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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Rakan Khair
Rakan Khair am 22 Sep. 2023
Bearbeitet: dpb am 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 Kommentar
Walter Roberson
Walter Roberson am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by