INNER CODE UNIT · Python
_get_new_box
minivision-ai/Silent-Face-Anti-Spoofing · src/generate_patches.py:17
def _get_new_box(src_w, src_h, bbox, scale):
x = bbox[0]
y = bbox[1]
box_w = bbox[2]
box_h = bbox[3]
scale = min((src_h-1)/box_h, min((src_w-1)/box_w, scale))
new_width = box_w * scale
new_height = box_h * scale
center_x, center_y = box_w/2+x, box_h/2+y
left_top_x = center_x-new_width/2
left_top_y = center_y-new_height/2
right_bottom_x = center_x+new_width/2
right_bottom_y = center_y+new_height/2
if left_top_x < 0: