INNER CODE UNIT · Python
new_height
minivision-ai/Silent-Face-Anti-Spoofing · src/generate_patches.py:26
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:
right_bottom_x -= left_top_x
left_top_x = 0
if left_top_y < 0:
right_bottom_y -= left_top_y
left_top_y = 0
if right_bottom_x > src_w-1:
left_top_x -= right_bottom_x-src_w+1