MANUALBBDRAW_MULTIPLE.m function that produces graphical output for DSKCF tracker MANUALBBDRAW_MULTIPLE overlays on top of the current frame a vector of bounding boxes (if they exist) with different color and linewidth. Also a text is displayed on the top left corner of the image INPUT: -img source image -bbVector bounding box vector in the format [topLeftX, topLeftY, bottomRightX, bottomRightY] read as [columnIndexTopLeft, rowIndexTopLeft, columnIndexBottomRight, rowIndexBottomRight] -myColor selected color for the bounding boxes -lWidth selected line width for the bounding boxes -myText1 list containing text corresponding to the bounding boxes displayed (with the selected color) on the top left of the image OUTPUT -modifiedImage captured from matlab fig, ready to be saved See also MANUALBBDRAW_OCC, MANUALBBDRAW_OCC_WITHLABELSVISUALIZE, ZBUFFER_CDATA University of Bristol Massimo Camplani and Sion Hannuna massimo.camplani@bristol.ac.uk hannuna@compsci.bristol.ac.uk
0001 function modifiedImage=manualBBdraw_MULTIPLE(img,bbVector,myColor,lWidth,myText1,myTextColor) 0002 0003 % MANUALBBDRAW_MULTIPLE.m function that produces graphical output for DSKCF tracker 0004 % 0005 % MANUALBBDRAW_MULTIPLE overlays on top of the current frame a 0006 % vector of bounding boxes (if they exist) with different color and 0007 % linewidth. Also a text is displayed on the top left corner of the image 0008 % 0009 % INPUT: 0010 % -img source image 0011 % -bbVector bounding box vector in the format [topLeftX, topLeftY, 0012 % bottomRightX, bottomRightY] read as [columnIndexTopLeft, rowIndexTopLeft, 0013 % columnIndexBottomRight, rowIndexBottomRight] 0014 % 0015 % 0016 % -myColor selected color for the bounding boxes 0017 % -lWidth selected line width for the bounding boxes 0018 % -myText1 list containing text corresponding to the bounding boxes 0019 % displayed (with the selected color) on the top left of the image 0020 % 0021 % OUTPUT 0022 % -modifiedImage captured from matlab fig, ready to be saved 0023 % 0024 % See also MANUALBBDRAW_OCC, MANUALBBDRAW_OCC_WITHLABELSVISUALIZE, ZBUFFER_CDATA 0025 % 0026 % University of Bristol 0027 % Massimo Camplani and Sion Hannuna 0028 % 0029 % massimo.camplani@bristol.ac.uk 0030 % hannuna@compsci.bristol.ac.uk 0031 0032 imageSize=[size(img,2),size(img,1)]; 0033 0034 0035 myFig=figure('visible','off'); 0036 set(myFig,'resize','off'); 0037 hold on; 0038 imshow(img); 0039 if(isempty(myText1)==false) 0040 if(iscell(myText1)==0) 0041 text(25,25,myText1,'color',myColor(1),'fontsize',20,'fontweight','bold'); 0042 else 0043 for jj=1:length(myText1) 0044 text(25,25+35*(jj-1),myText1(jj),'color',myTextColor(jj),'fontsize',20,'fontweight','bold'); 0045 end 0046 end 0047 end 0048 0049 for kk=1:size(bbVector,1) 0050 bb=bbVector(kk,:); 0051 if(isempty(bb)==false & isnan(bb)==false) 0052 if(bb(1)>imageSize(1) | bb(2)>imageSize(2)) 0053 bb=[]; 0054 else 0055 bb(bb(1:2)<0)=1; 0056 if(bb(1)+bb(3)>imageSize(1)) 0057 bb(3)=imageSize(1)-bb(1); 0058 end 0059 0060 if( bb(2)+bb(4)>imageSize(2)) 0061 bb(4)=imageSize(2)-bb(2); 0062 end 0063 0064 rectangle('Position', bb,'LineWidth',lWidth,'edgecolor',myColor(kk)); 0065 end 0066 end 0067 0068 end 0069 0070 0071 F = im2frame(zbuffer_cdata(gcf)); 0072 0073 modifiedImage=imresize(F.cdata,[size(img,1),size(img,2)]); 0074 0075 close (myFig)