Advertisement
Guest User

nie dziala

a guest
May 26th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.84 KB | None | 0 0
  1. clear all
  2. close all
  3.  
  4. camera = webcam;
  5. net = googlenet;
  6.  
  7. inputSize = net.Layers(1).InputSize(1:2)
  8.  
  9. h = figure;
  10. h.Position(3) = 2*h.Position(3);
  11. ax1 = subplot(1,2,1);
  12. ax2 = subplot(1,2,2);
  13. ax2.ActivePositionProperty = 'position';
  14.  
  15. while ishandle(h)
  16.     % Display and classify the image
  17.     im = snapshot(camera);
  18.     image(ax1,im)
  19.     im = imresize(im,inputSize);
  20.     [label,score] = classify(net,im);
  21.     title(ax1,{char(label),num2str(max(score),2)});
  22.  
  23.     % Select the top five predictions
  24.     [~,idx] = sort(score,'descend');
  25.     idx = idx(5:-1:1);
  26.     scoreTop = score(idx);
  27.     classNamesTop = string(classes(idx));
  28.  
  29.     % Plot the histogram
  30.     barh(ax2,scoreTop)
  31.     title(ax2,'Top 5')
  32.     xlabel(ax2,'Probability')
  33.     xlim(ax2,[0 1])
  34.     yticklabels(ax2,classNamesTop)
  35.     ax2.YAxisLocation = 'right';
  36.  
  37.     drawnow
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement