How to add a stream screen in gui

1 回表示 (過去 30 日間)
Niculai Traian
Niculai Traian 2019 年 5 月 8 日
編集済み: Walter Roberson 2019 年 5 月 8 日
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;

採用された回答

Walter Roberson
Walter Roberson 2019 年 5 月 8 日
編集済み: Walter Roberson 2019 年 5 月 8 日
% --- 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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by