1
Dlibs imutils.face_utils
を使用して顔認識を行う前に、Dlibのrectに変換することで顔を整列しようとしています。しかし、私はgettngエラー矩形を保持しないiterableです。ここ は、私がDLIB FaceUtilsを用いて、第1整列させ、その後、OpenCVののrecognizer.predict()
を使用して予測を行うにはどうすればよいコードTypeError: 'rectangle'オブジェクトは、顔の整列後に反復できません。Dlib FaceUtils
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
fa = FaceAligner(predictor)
のですか?
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = detector(gray, 2)
# If faces are found, try to recognize them
for (x,y,w,h) in faces:
(x1, y1, w1, h1) = rect_to_bb(x,y,w,h)
faceAligned = fa.align(image, gray, (x1,y1,w1,h1))
label, confidence = recognizer.predict(faceAligned)
if confidence < threshold:
found_faces.append((label, confidence, (x, y, w, h)))
return found_faces