Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added confidence value #12

Merged
merged 2 commits into from
Mar 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions 6_cornernet_lite/lib/core/vis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

def draw_bboxes(image, bboxes, font_size=0.5, thresh=0.5, colors=None):
"""Draws bounding boxes on an image.

Args:
image: An image in OpenCV format
bboxes: A dictionary representing bounding boxes of different object
Expand All @@ -16,15 +15,14 @@ def draw_bboxes(image, bboxes, font_size=0.5, thresh=0.5, colors=None):
will be drawn.
colors: (Optional) Color of bounding boxes for each category. If it is
not provided, this function will use random color for each category.

Returns:
An image with bounding boxes.
"""

image = image.copy()
for cat_name in bboxes:
keep_inds = bboxes[cat_name][:, -1] > thresh
cat_size = cv2.getTextSize(cat_name, cv2.FONT_HERSHEY_SIMPLEX, font_size, 2)[0]
cat_size = cv2.getTextSize(cat_name +' : %.2f' % bboxes[cat_name][:, -1], cv2.FONT_HERSHEY_SIMPLEX, font_size, 2)[0]

if colors is None:
color = np.random.random((3, )) * 0.6 + 0.4
Expand All @@ -40,7 +38,7 @@ def draw_bboxes(image, bboxes, font_size=0.5, thresh=0.5, colors=None):
(bbox[0] + cat_size[0], bbox[1] + cat_size[1] + 2),
color, -1
)
cv2.putText(image, cat_name,
cv2.putText(image, cat_name +' : %.2f' % bboxes[cat_name][:, -1],
(bbox[0], bbox[1] + cat_size[1] + 2),
cv2.FONT_HERSHEY_SIMPLEX, font_size, (0, 0, 0), thickness=1
)
Expand All @@ -50,7 +48,7 @@ def draw_bboxes(image, bboxes, font_size=0.5, thresh=0.5, colors=None):
(bbox[0] + cat_size[0], bbox[1] - 2),
color, -1
)
cv2.putText(image, cat_name,
cv2.putText(image, cat_name +' : %.2f' % bboxes[cat_name][:, -1],
(bbox[0], bbox[1] - 2),
cv2.FONT_HERSHEY_SIMPLEX, font_size, (0, 0, 0), thickness=1
)
Expand Down