本文整理匯總了Python中imutils.face_utils.FACIAL_LANDMARKS_IDXS屬性的典型用法代碼示例。如果您正苦於以下問題:Python face_utils.FACIAL_LANDMARKS_IDXS屬性的具體用法?Python face_utils.FACIAL_LANDMARKS_IDXS怎麽用?Python face_utils.FACIAL_LANDMARKS_IDXS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類imutils.face_utils
的用法示例。
在下文中一共展示了face_utils.FACIAL_LANDMARKS_IDXS屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from imutils import face_utils [as 別名]
# 或者: from imutils.face_utils import FACIAL_LANDMARKS_IDXS [as 別名]
def __init__(self, path):
import dlib # lazy loading
# use dlib 68-point facial landmark
self._detector = dlib.shape_predictor(path + 'shape_predictor_68_face_landmarks.dat')
(self._leye_start, self._leye_end) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"]
(self._reye_start, self._reye_end) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye"]
try:
(self._mouth_start, self._mouth_end) = face_utils.FACIAL_LANDMARKS_IDXS["inner_mouth"]
except:
(self._mouth_start, self._mouth_end) = (60, 68)
示例2: recognize
# 需要導入模塊: from imutils import face_utils [as 別名]
# 或者: from imutils.face_utils import FACIAL_LANDMARKS_IDXS [as 別名]
def recognize():
database = initialize()
cap = cv2.VideoCapture(0)
(lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"]
(rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye"]
while True:
ret, img = cap.read()
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
subjects = detector(gray, 0)
for subject in subjects:
shape = predictor(gray, subject)
shape = face_utils.shape_to_np(shape) # converting to NumPy Array
leftEye = shape[lStart:lEnd]
rightEye = shape[rStart:rEnd]
leftEAR = eye_aspect_ratio(leftEye)
rightEAR = eye_aspect_ratio(rightEye)
ear = (leftEAR + rightEAR) / 2.0
leftEyeHull = cv2.convexHull(leftEye)
rightEyeHull = cv2.convexHull(rightEye)
cv2.drawContours(img, [leftEyeHull], -1, (0, 255, 0), 1)
cv2.drawContours(img, [rightEyeHull], -1, (0, 255, 0), 1)
extract_face_info(img, img_rgb, database,ear)
cv2.imshow('Recognizing faces', img)
if cv2.waitKey(1) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()