Skip to content

Instantly share code, notes, and snippets.

@arunm8489
Created June 6, 2020 02:50
Show Gist options
  • Save arunm8489/2396761bc62d859194b9775317b7d1cb to your computer and use it in GitHub Desktop.
Save arunm8489/2396761bc62d859194b9775317b7d1cb to your computer and use it in GitHub Desktop.
def draw_boxes(x, img):
c1 = tuple(x[1:3].int())
c2 = tuple(x[3:5].int())
cls = int(x[-1])
label = "{0}".format(classes[cls])
color = (0,0,255)
cv2.rectangle(img, c1, c2,color, 2)
t_size = cv2.getTextSize(label, cv2.FONT_HERSHEY_PLAIN, 1 , 1)[0]
c2 = c1[0] + t_size[0] + 3, c1[1] + t_size[1] + 4
cv2.rectangle(img, c1, c2,color, -1)
cv2.putText(img, label, (c1[0], c1[1] + t_size[1] + 4), cv2.FONT_HERSHEY_PLAIN, 1, [225,255,255], 1)
return img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment