def _plot_patch(ax, bbox, prob, class_name, color):
""" Plot a rectangle (labeled with color, class_name, and prob) on the test image """
# Calculate Bounding Box Rectangle and plot it
height = bbox[3] - bbox[1]
width = bbox[2] - bbox[0]
rect = patches.Rectangle((bbox[0], bbox[1]), width, height, linewidth=2, edgecolor=color, facecolor='none')
ax.add_patch(rect)
# Add confidence prob and class text to box
if prob is not None:
ax.text(bbox[0], bbox[1] - 2,
'{:s} {:.3f}'.format(class_name, prob),
bbox=dict(facecolor=color, alpha=0.5),
fontsize=8, color='white')
评论列表
文章目录