修复高宽比大于3/2的图片裁剪

This commit is contained in:
hejianjun
2022-02-10 19:27:29 +08:00
parent ece2ee451c
commit 3814695d88
4 changed files with 77 additions and 41 deletions

View File

@@ -5,11 +5,13 @@ def face_center(filename, model):
image = face_recognition.load_image_file(filename)
face_locations = face_recognition.face_locations(image, 1, model)
print('[+]Found person ' + str(len(face_locations)))
max = 0
maxRight = 0
maxTop = 0
for face_location in face_locations:
top, right, bottom, left = face_location
# 中心点
x = int((right+left)/2)
if x > max:
max = x
return max
if x > maxRight:
maxRight = x
maxTop = top
return maxRight,maxTop