Created
April 19, 2023 12:10
-
-
Save neerajadsul/5d12af633b8075b62238ae959a195398 to your computer and use it in GitHub Desktop.
Crop Bounding Box and Show Object Detection Result
This file contains 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 imshow_od_bbox(image_file, bbox_voc, object_class, labelmap_dict): | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
xmin,ymin,xmax,ymax = bbox_voc | |
right = xmin + (xmax - xmin) | |
bottom = ymin + (ymax - ymin) | |
image = Image.open(image_file) | |
detected_object = image.crop((xmin, ymin, right, bottom)) | |
plt.imshow(detected_object) | |
plt.title(f'{object_class} : {labelmap_dict[object_class]}') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment