This commit is contained in:
Glenn Jocher
2019-04-22 16:52:14 +02:00
parent ab8d8cbc93
commit 5f69861958
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -103,8 +103,8 @@ def xywh2xyxy(x):
def scale_coords(img1_shape, coords, img0_shape):
# Rescale coords1 (xyxy) from img1_shape to img0_shape
gain = max(img1_shape) / max(img0_shape) # gain = old / new
coords[:, [0, 2]] -= (img1_shape[3] - img0_shape[1] * gain) / 2 # x padding
coords[:, [1, 3]] -= (img1_shape[2] - img0_shape[0] * gain) / 2 # y padding
coords[:, [0, 2]] -= (img1_shape[1] - img0_shape[1] * gain) / 2 # x padding
coords[:, [1, 3]] -= (img1_shape[0] - img0_shape[0] * gain) / 2 # y padding
coords[:, :4] /= gain
coords[:, :4] = coords[:, :4].clamp(min=0)
return coords