1
OpenCV rect를 Dlib의 rect로 변환하여 Dlibs imutils.face_utils
을 사용하여 얼굴 인식 전에 얼굴을 정렬하려고합니다. 하지만 gettng 오류 사각형은 반복 할 수 없습니다. 다음은 어떻게 처음 Dlib의 FaceUtils를 사용하여 정렬한다 않는 코드TypeError : 'rectangle'객체가면 정렬 후 반복되지 않습니다. Dlib FaceUtils
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
fa = FaceAligner(predictor)
하고 다음 예측을 OpenCV의 recognizer.predict()
를 사용합니까?
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