@@ -230,7 +230,7 @@ def loadImgs(self, ids=[]):
230
230
elif type (ids ) == int :
231
231
return [self .imgs [ids ]]
232
232
233
- def showAnns (self , anns ):
233
+ def showAnns (self , anns , draw_bbox = False ):
234
234
"""
235
235
Display the specified annotations.
236
236
:param anns (array of object): annotations to display
@@ -286,6 +286,14 @@ def showAnns(self, anns):
286
286
plt .plot (x [sk ],y [sk ], linewidth = 3 , color = c )
287
287
plt .plot (x [v > 0 ], y [v > 0 ],'o' ,markersize = 8 , markerfacecolor = c , markeredgecolor = 'k' ,markeredgewidth = 2 )
288
288
plt .plot (x [v > 1 ], y [v > 1 ],'o' ,markersize = 8 , markerfacecolor = c , markeredgecolor = c , markeredgewidth = 2 )
289
+
290
+ if draw_bbox :
291
+ [bbox_x , bbox_y , bbox_w , bbox_h ] = ann ['bbox' ]
292
+ poly = [[bbox_x , bbox_y ], [bbox_x , bbox_y + bbox_h ], [bbox_x + bbox_w , bbox_y + bbox_h ], [bbox_x + bbox_w , bbox_y ]]
293
+ np_poly = np .array (poly ).reshape ((4 ,2 ))
294
+ polygons .append (Polygon (np_poly ))
295
+ color .append (c )
296
+
289
297
p = PatchCollection (polygons , facecolor = color , linewidths = 0 , alpha = 0.4 )
290
298
ax .add_collection (p )
291
299
p = PatchCollection (polygons , facecolor = 'none' , edgecolors = color , linewidths = 2 )
0 commit comments