Showing posts with label How to locate people in an image. Show all posts
Showing posts with label How to locate people in an image. Show all posts

Tuesday, 14 October 2014

How to locate people in an image

%Create a people detector, and load the input image.

   peopleDetector = vision.PeopleDetector;
   I = imread('visionteam1.jpg');
%Detect people using the people detector object.

   [bboxes, scores] = step(peopleDetector, I);
%Create a shape inserter and a score inserter.

   shapeInserter = vision.ShapeInserter('BorderColor','Custom','CustomBorderColor',[255 255 0]);
   
    scoreInserter = vision.TextInserter('Text',' %f','Color', [0 80 255],'LocationSource','Input port','FontSize',16);
%Draw detected bounding boxes, and insert scores using the inserter objects.

    I = step(shapeInserter, I, int32(bboxes));
    I = step(scoreInserter, I, scores, int32(bboxes(:,1:2)));
    figure, imshow(I)
    title('Detected people and detection scores');