Undefined function 'snapshot' for input arguments of type 'char'.
이전 댓글 표시
Hello, i am building a neural network and i am trying to use my phone camera for object classification. To do this i installed ip webcam to start a live stream and from matlab i acces the stream. The problem is it work if i dont try to use it for classification. But if i add the lines for classification it gives me this error: "Undefined function 'snapshot' for input arguments of type 'char'."
*i have to mantion that if i use laptop camera it works with no problems. Here is the code for classification and acces the live stream
url = ('http://192.168.1.2:8080/shot.jpg');
framesAcquired = 0;
%camera = webcam; % Connect to the camera
net = Net; % Load the neural net
h = figure;
h.Position(3) = 2*h.Position(3);
ax1 = subplot(1,2,1);
ax2 = subplot(1,2,2);
ax2.ActivePositionProperty = 'position';
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
% Select the top five predictions
[~,idx] = sort(score,'descend');
idx = idx(5:-1:1);
classes = net.Layers(end).Classes;
scoreTop = score(idx);
classNamesTop = string(classes(idx));
% Plot the histogram
barh(ax2,scoreTop)
title(ax2,'Top 5')
xlabel(ax2,'Probability')
xlim(ax2,[0 1])
yticklabels(ax2,classNamesTop)
ax2.YAxisLocation = 'right';
drawnow
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB Support Package for IP Cameras에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!