www.gusucode.com > vision 源码程序 matlab案例代码 > vision/RunTheNonmaximalSuppressionOnBoundingBoxesWithAPeopleDetExample.m

    %% Run Nonmaximal Suppression on Bounding Boxes Using People Detector 
%
%% 
% Load the pretrained people detector and disable bounding box merging.
peopleDetector = vision.PeopleDetector('ClassificationThreshold',...
        0,'MergeDetections',false);
%% 
% Read an image, run the people detector, and then insert bounding boxes
% with confidence scores.
I = imread('visionteam1.jpg'); 
[bbox,score] = step(peopleDetector,I); 
I1 = insertObjectAnnotation(I,'rectangle',bbox,...
        cellstr(num2str(score)),'Color','r');
%% 
% Run nonmaximal suppression on the bounding boxes.
[selectedBbox,selectedScore] = selectStrongestBbox(bbox,score); 
I2 = insertObjectAnnotation(I,'rectangle',selectedBbox,...
        cellstr(num2str(selectedScore)),'Color','r');
%% 
% Display detection before and after suppression.
figure, imshow(I1); ...
title('Detected people and detection scores before suppression'); 
figure, imshow(I2); ...
title('Detected people and detection scores after suppression');