updates
This commit is contained in:
parent
91eaf2f8fe
commit
308eda38fd
|
@ -405,10 +405,11 @@ def letterbox(img, new_shape=416, color=(128, 128, 128), mode='auto'):
|
|||
new_unpad = (new_shape, new_shape)
|
||||
ratiow, ratioh = new_shape / shape[1], new_shape / shape[0]
|
||||
|
||||
if shape[::-1] != new_unpad:
|
||||
img = cv2.resize(img, new_unpad, interpolation=cv2.INTER_AREA) # resize
|
||||
top, bottom = int(round(dh - 0.1)), int(round(dh + 0.1))
|
||||
left, right = int(round(dw - 0.1)), int(round(dw + 0.1))
|
||||
img = cv2.resize(img, new_unpad, interpolation=cv2.INTER_AREA) # resized, no border
|
||||
img = cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # padded square
|
||||
img = cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # add border
|
||||
return img, ratiow, ratioh, dw, dh
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue