How can I connect my self written code with an the Matlab App Designer?

조회 수: 2 (최근 30일)
Marlene Patterer
Marlene Patterer 2021년 6월 16일
댓글: Cris LaPierre 2021년 6월 17일
Hello,
I am trying to create a platform where the user can click on the button and after doing so the program (my self written code) will run.
Right now it opens the camera but as it doesn't analyze anything I assume there is no connection between the code and the button.
How can I establish the connection between them?
In %Button pushed function: Button, I tried to implement my code for hand detection with my network, but nothing is working.
Thanks for any help.
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: StartButton
function StartButtonPushed(app, event)
c = webcam("Webcam(X1-HTL)");
frame = snapshot(c);
im = image(app.UIAxes,zeros(size(frame),'uint8'));
axis(app.UIAxes,'image');
preview(c,im);
pause;
end
% Button pushed function: StopButton
function StopButtonPushed(app, event)
d= webcam("Webcam(X1-HTL)");
frame = snapshot(d);
im = image(app.UIAxes,zeros(size(frame),'uint8'));
axis(app.UIAxes,'image');
closepreview;
pause;
end
% Button pushed function: Button
function ButtonPushed(app, event)
a = webcam('Webcam(X1-HTL)');
frame = snapshot(a);
Handbox=[0 0 400 400];
while true
video = a.snapshot;
load Netzwerk.mat;
%Video RGB to gray
video_grey = rgb2gray(video);
videoAdj = imadjust(video_grey);
%Video RGB to BW
BW = imbinarize(videoAdj);
%Fill holes
BW_IH = imfill(BW, 'holes');
%change format [x x 1] --> [x x 3] and uint8
BW_3D = cat(3,BW_IH,BW_IH,BW_IH);
format = im2uint8(BW_3D);
%Create Handbox
Handbox_new = insertObjectAnnotation(video,'rectangle',Handbox,'Handgeste');
Handbox_crop = imcrop(format,Handbox);
video_new = imresize(Handbox_crop, [227 227]);
%classify
label=classify(Netzwerk,video_new);
im = image(app.UIAxes,zeros(size(frame),'uint8'));
axis(app.UIAxes,'image');
preview(a,im)
% title(char(label));
drawnow;
end
  댓글 수: 1
Cris LaPierre
Cris LaPierre 2021년 6월 17일
Is your function in the same folder as your app or in a folder that is on your MATLAB path?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by