Effacer les filtres
Effacer les filtres

How to add a stream screen in gui

5 vues (au cours des 30 derniers jours)
Niculai Traian
Niculai Traian le 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;

Réponse acceptée

Walter Roberson
Walter Roberson le 8 Mai 2019
Modifié(e) : Walter Roberson le 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

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by