2024年1月18日发(作者:)

classNamesTop = string(classes(idx));scoreTop = score(idx);

barh(ax2,scoreTop)xlim(ax2,[0 1])title(ax2,'Top 5')xlabel(ax2,'Probability')yticklabels(ax2,classNamesTop)ocation = 'right';

while ishandle(h) % Display and classify the image im = snapshot(camera); image(ax1,im) im = imresize(im,inputSize); [label,score] = classify(net,im); title(ax1,{char(label),num2str(max(score),2)});

% Select the top five predictions [~,idx] = sort(score,'descend'); idx = idx(5:-1:1); 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) ocation = 'right';

drawnowend