Last active
January 21, 2020 03:04
-
-
Save qmaruf/52545c06f8b71e3e73f682be5471bab9 to your computer and use it in GitHub Desktop.
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
from PIL import Image, ImageDraw | |
import cv2 | |
def draw_rect(img, box, img_src): | |
x1, y1, x2, y2 = map(int, box) | |
if img_src == 'pil': | |
draw = ImageDraw.Draw(img) | |
draw.rectangle(((x1, y1), (x2, y2)), width=10, outline="red") | |
del draw | |
elif img_src == 'cv2': | |
img = cv2.rectangle(img, (x1, y1), (x2, y2), (0, 0, 255), 4) | |
return img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment