Commit cf1c54ae authored by Ahmed Abobakr's avatar Ahmed Abobakr Committed by Facebook Github Bot

Fix errors in vis.py (#555)

Summary:
Fixing error:
TypeError: Layout of the output array img is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)

in vis_class(..) and vis_bbox(..) methods when calling vis_one_image_opencv(..).
Pull Request resolved: https://github.com/facebookresearch/Detectron/pull/555

Reviewed By: rbgirshick

Differential Revision: D10027949

Pulled By: ir413

fbshipit-source-id: e34b8b881ffe231984f270910f778c5abe79e489
parent e8942c88
...@@ -113,6 +113,7 @@ def vis_mask(img, mask, col, alpha=0.4, show_border=True, border_thick=1): ...@@ -113,6 +113,7 @@ def vis_mask(img, mask, col, alpha=0.4, show_border=True, border_thick=1):
def vis_class(img, pos, class_str, font_scale=0.35): def vis_class(img, pos, class_str, font_scale=0.35):
"""Visualizes the class.""" """Visualizes the class."""
img = img.astype(np.uint8)
x0, y0 = int(pos[0]), int(pos[1]) x0, y0 = int(pos[0]), int(pos[1])
# Compute text size. # Compute text size.
txt = class_str txt = class_str
...@@ -130,6 +131,7 @@ def vis_class(img, pos, class_str, font_scale=0.35): ...@@ -130,6 +131,7 @@ def vis_class(img, pos, class_str, font_scale=0.35):
def vis_bbox(img, bbox, thick=1): def vis_bbox(img, bbox, thick=1):
"""Visualizes a bounding box.""" """Visualizes a bounding box."""
img = img.astype(np.uint8)
(x0, y0, w, h) = bbox (x0, y0, w, h) = bbox
x1, y1 = int(x0 + w), int(y0 + h) x1, y1 = int(x0 + w), int(y0 + h)
x0, y0 = int(x0), int(y0) x0, y0 = int(x0), int(y0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment