How to add a stream screen in gui

1 Ansicht (letzte 30 Tage)
Niculai Traian
Niculai Traian am 8 Mai 2019
Hello, i need to add a live stream screen in a gui application. For streaming i am using a http link. From gui i need to acces it and it should be a video and not just a frame. For normal script i use this code:
url = ipcam('http://192.168.43.1:8080/video');
framesAcquired = 0;
h = figure;
while ishandle(h)
im = snapshot(url);
image(im)
im = imresize(im,[227,227]);
[label,score] = classify(net,im);
title({char(label), num2str(max(score),2)});
drawnow
end;
In gui i tried to add axes screen and then add my code to generated code by gui but didn't work.
% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes1(handle.axes1);
url = ipcam('http://192.168.43.1:8080/video');
framesAcquired = 0;
h = figure;
while ishandle(h)
im = snapshot(url);
image(im)
im = imresize(im,[227,227]);
[label,score] = classify(net,im);
title({char(label), num2str(max(score),2)});
drawnow
end;

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Mai 2019
Bearbeitet: Walter Roberson am 8 Mai 2019
% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ax = handle.axes1;
url = ipcam('http://192.168.43.1:8080/video');
framesAcquired = 0;
h = ancestor(ax, 'figure');
imh = image(ax, []);
prevheader = 'classifying, previous was:';
this_title = {prevheader, 'unknown', 'score unavailable'};
while ishandle(h)
im = snapshot(url);
framesAcquired = framesAcquired + 1;
set(imh, 'CData', im);
this_title{1} = prevheader;
title(ax, this_title);
drawnow();
im = imresize(im,[227,227]);
[label,score] = classify(net,im);
this_title = {'classified!', char(label), num2str(max(score),2)};
title(ax, this_title)
drawnow();
end

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by