[英]'NoneType' object has no attribute 'size' - how to face detection using mtcnn?
[英]How to reduce the size of the rectangular boxes on face detection in a group photo?
import cv2
import face_recognition as fc
image = fc.load_image_file('classA.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
face_locations = fc.face_locations(image)
print(face_locations)
for i in range(len(face_locations)):
image = cv2.rectangle(image, (face_locations[i][3],face_locations[i][0],face_locations[i][1],face_locations[i][2]),(0,255,0),2)
cv2.imshow(' Students present in class detected',image)
cv2.waitKey(0)
我期待檢測到的臉應該只有一個矩形框而不是整個身體
你需要一個左上角和一個右下角。 像:
top_left = (face_locations[i][3], face_locations[i][0])
bottom_right = (face_locations[i][1], face_locations[i][2])
image = cv2.rectangle(image, top_left, bottom_right, (0,255,0), 2)
希望對你有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.