Home > samsung-code > detShowBBoxes.m

detShowBBoxes

PURPOSE ^

DETSHOWBBOXES visualizes the detection results.

SYNOPSIS ^

function detShowBBoxes( I, Bs, Ss, model_or_list, thresh )

DESCRIPTION ^

 DETSHOWBBOXES visualizes the detection results.
   Bounding boxes with detection scores are shown on the image.
   The category label and detection score of a bounding box is shown at
   the corner of the box. Bounding boxes of each category is in a
   different color. 

 Usage:
   detShowBBoxes( I, Bs, Ss, model_or_list, thresh )

 Input:

   I: an image matrix loaded by imread (e.g., I = imread('000220.jpg');)

   Bs, Ss: the detected bounding boxes and their scores returned by
      detSingle( I, ... )

   model_or_list: can be either a model initialized by detInit(...) or
      a list category names, e.g. returned by detVOC2007(...)

   thresh: threshold for pruning false postives, i.e., only boundling
   boxes with scores higher than thresh will be counted.
       Default value: -inf
   Remark: one can set a lower thresh for detSingle(...) to get more
   bounding boxes, and tune the thresh here to get a good visualization
   result

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function detShowBBoxes( I, Bs, Ss, model_or_list, thresh )
0002 % DETSHOWBBOXES visualizes the detection results.
0003 %   Bounding boxes with detection scores are shown on the image.
0004 %   The category label and detection score of a bounding box is shown at
0005 %   the corner of the box. Bounding boxes of each category is in a
0006 %   different color.
0007 %
0008 % Usage:
0009 %   detShowBBoxes( I, Bs, Ss, model_or_list, thresh )
0010 %
0011 % Input:
0012 %
0013 %   I: an image matrix loaded by imread (e.g., I = imread('000220.jpg');)
0014 %
0015 %   Bs, Ss: the detected bounding boxes and their scores returned by
0016 %      detSingle( I, ... )
0017 %
0018 %   model_or_list: can be either a model initialized by detInit(...) or
0019 %      a list category names, e.g. returned by detVOC2007(...)
0020 %
0021 %   thresh: threshold for pruning false postives, i.e., only boundling
0022 %   boxes with scores higher than thresh will be counted.
0023 %       Default value: -inf
0024 %   Remark: one can set a lower thresh for detSingle(...) to get more
0025 %   bounding boxes, and tune the thresh here to get a good visualization
0026 %   result
0027 %
0028 %
0029 
0030 if isstruct( model_or_list )
0031     categ_list = model_or_list.categ_list;
0032 else
0033     categ_list = model_or_list;
0034 end
0035 
0036 if ~exist('thresh','var') || isempty(thresh)
0037     thresh = -inf;
0038 end
0039 if isscalar( thresh )
0040     thresh = repmat(thresh, 1, length( categ_list ));
0041 end
0042 
0043 COLOR = colorcube( ceil( length(categ_list) * 2 ) );
0044 
0045 clf
0046 imshow(I);
0047 for c = 1:length(categ_list)
0048     for j = find( reshape(Ss{c},1,length(Ss{c}))>=thresh(c) )
0049         cur_bbox = num2cell( Bs{c}(j,:) );
0050         [y1, x1, y2, x2] = deal( cur_bbox{:} );
0051         lh = line([x1,x1,x2,x2,x1],[y1,y2,y2,y1,y1]);
0052         set( lh, 'Color', COLOR(c,:), 'LineWidth', 2 );
0053         text(x1,y1, sprintf( '%s: %.2f', categ_list{c}, Ss{c}(j) ), ...
0054             'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom', ...
0055             'Margin', 1, 'BackgroundColor', COLOR(c,:), 'Color', 'white' ) ;
0056     end
0057 end

Generated on Thu 18-Dec-2014 22:27:44 by m2html © 2005