我这段代码大致意思是判断下有没有人脸坐标 ,如果有保存下坐标,然后剪裁人脸,如果没有,就用上个循环的坐标剪裁图片
for detection in results.detections:
mp_drawing.draw_detection(annotated_image, detection)
coording = mp_drawing.draw_detection(annotated_image, detection)
if coording[0] == None:
a = tmp[0]
b = tmp[1]
c = tmp[2]
d = tmp[3]
print (tmp)
else:
a = coording[0][0]
b = coording[0][1]
c = coording[1][0]
d = coording[1][1]
cv2.rectangle(annotated_image, (a, b), (c, d), (0, 0, 255), thickness=1)
tmp=[a,b,c,d]
print(tmp)
image = annotated_image[b:d, a:c]
image=cv2.resize(image,(112,112))