Created
August 31, 2015 16:54
-
-
Save wookayin/cec7deb6c0353c34b0a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def im_drawbox(window, color='r', class_name='', score=0.0): | |
""" | |
Add a detection window (bounding box) into the current plot image. | |
window: tuple-like of length 4 (xmin, ymin, xmax, ymax) | |
""" | |
import matplotlib.pyplot as plt | |
xmin, ymin, xmax, ymax = window | |
coords = (ymin, xmin), ymax - ymin, xmax - xmin | |
currentAxis = plt.gca() | |
currentAxis.add_patch( | |
plt.Rectangle(*coords, fill=False, edgecolor=color, linewidth=3) | |
) | |
currentAxis.text(ymin, xmin - 5, | |
'{:s} ({:.3f})'.format(str(class_name), score), | |
bbox=dict(facecolor=color, alpha=0.5), | |
fontsize=12, color='white') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment