Skip to content

Commit aec2536

Browse files
committed
update vis obj box for pixel unit input
1 parent 4cd7c49 commit aec2536

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tensorlayer/visualize.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def draw_boxes_and_labels_to_image(image, classes=[], coords=[],
104104
classes_list : list of string, for converting ID to string.
105105
bbox_center_to_rectangle : boolean, defalt is True.
106106
If True, convert [x_center, y_center, w, h] to [x, y, x2, y2] (up-left and botton-right).
107+
is_rescale : boolean, defalt is True.
108+
If True, the input coordinates are the portion of width and high, this API will scale the coordinates to pixel unit internally.
109+
If False, feed the coordinates with pixel unit format.
107110
save_name : None or string
108111
The name of image file (i.e. image.png), if None, not to save image.
109112
@@ -130,7 +133,8 @@ def draw_boxes_and_labels_to_image(image, classes=[], coords=[],
130133
else:
131134
x, y, x2, y2 = coords[i]
132135

133-
x, y, x2, y2 = prepro.obj_box_coord_scale_to_pixelunit([x, y, x2, y2], (imh, imw))
136+
if is_rescale: # scale back to pixel unit if the coords are the portion of width and high
137+
x, y, x2, y2 = prepro.obj_box_coord_scale_to_pixelunit([x, y, x2, y2], (imh, imw))
134138

135139
cv2.rectangle(image,
136140
(x, y), (x2, y2), # up-left and botton-right

0 commit comments

Comments
 (0)