修复高宽比大于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

@@ -11,12 +11,15 @@ def face_center(filename, model):
img = fp.read()
result = client.bodyAnalysis(img)
if 'error_code' in result:
raise result['error_msg']
raise ValueError(result['error_msg'])
print('[+]Found person ' + str(result['person_num']))
# 中心点取鼻子x坐标
max = 0
maxRight = 0
maxTop = 0
for person_info in result["person_info"]:
x = int(person_info['body_parts']['nose']['x'])
if x > max:
max = x
return max
top = int(person_info['location']['top'])
if x > maxRight:
maxRight = x
maxTop = top
return maxRight,maxTop