dlibで顔認識から目を認識するものを作成しようとしているのですがエラー内容を検索してもわかりません。わかる方教えていただきたいです。
・ソース
import os,sys
import cv2
import dlib
import numpy as np
from imutils import face_utils
cap = cv2.VideoCapture(0)
face_detector = dlib.get_frontal_face_detector()
face_parts_detector = dlib.shape_predictor('shape_predictor_68_face_landmarks.dat')
while True:
tick = cv2.getTickCount()
ret, rgb = cap.read() gray = cv2.cvtColor(rgb, cv2.COLOR_RGB2GRAY) faces = face_detector(gray) if len(faces) == 1: face = faces[0] cv2.rectangle(rgb, (face.left(), face.top()), (face.right(), face.bottom()), (255, 0, 0), 2) face_parts = face_parts_detector(gray, face) for i, ((x, y)) in enumerate(face_parts[:]): cv2.circle(rgb, (x, y), 1, (0, 255, 0), -1) cv2.putText(rgb, str(i), (x + 2, y - 2), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (0, 255, 0), 1) fps = cv2.getTickFrequency() / (cv2.getTickCount() - tick) cv2.imshow('frame', rgb) if cv2.waitKey(1) == 27: break # esc to quit
cap.release()
cv2.destroyAllWindows()
・エラー箇所
for i, ((x, y)) in enumerate(face_parts[:]):
・エラー内容
TypeError: 'dlib.full_object_detection' object is not subscriptable
あなたの回答
tips
プレビュー