INNER CODE UNIT · Python
crop
minivision-ai/Silent-Face-Anti-Spoofing · src/generate_patches.py:53
def crop(self, org_img, bbox, scale, out_w, out_h, crop=True):
if not crop:
dst_img = cv2.resize(org_img, (out_w, out_h))
else:
src_h, src_w, _ = np.shape(org_img)
left_top_x, left_top_y, \
right_bottom_x, right_bottom_y = self._get_new_box(src_w, src_h, bbox, scale)
img = org_img[left_top_y: right_bottom_y+1,
left_top_x: right_bottom_x+1]
dst_img = cv2.resize(img, (out_w, out_h))
return dst_img