Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def draw_contours_on_image(contours, img):
- color = SCALAR_GREEN
- for contour in contours:
- cv2.polylines(img, [contour], True, color=color, thickness=2)
- def draw_boxes_on_image(boxes, img):
- for box in boxes:
- color = (colours[box.track_id % 11], colours[box.track_id * 23 % 13], colours[box.track_id * 11 % 17])
- p1 = (int(box.left), int(box.bottom))
- p2 = (int(box.right), int(box.top))
- if box.phantom:
- drawrect(img, p1, p2, color=color, thickness=2, style='dashed')
- else:
- cv2.rectangle(img, p1, p2, color=color, thickness=2)
- # dblFontScale = blobs[i].dblCurrentDiagonalSize / 60.0
- # intFontThickness = int(dblFontScale * 1.0)
- # cv2.putText(imgFrame2, str(i), blobs[i].centerPositions[-1], cv2.FONT_HERSHEY_COMPLEX, dblFontScale,
- # SCALAR_GREEN,
- # intFontThickness)
- def draw_boxes_with_contour(contours, boxes, img_con):
- for box in boxes:
- if not box.phantom:
- mid_y = (box.left + box.right) / 2
- mid_x = (box.top + box.bottom) / 2
- mid_p = (mid_y, mid_x)
- p1 = (int(box.left), int(box.bottom))
- p2 = (int(box.right), int(box.top))
- for i, contour in enumerate(contours):
- res = cv2.pointPolygonTest(contour, mid_p, False)
- if res == OUTSIDE_CONTOUR:
- cv2.rectangle(img_con, p1, p2, color=SCALAR_RED, thickness=2)
- else:
- cv2.rectangle(img_con, p1, p2, color=SCALAR_GREEN, thickness=2)
- else:
- p1 = (int(box.left), int(box.bottom))
- p2 = (int(box.right), int(box.top))
- cv2.rectangle(img_con, p1, p2, color=SCALAR_RED, thickness=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement