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