本文整理汇总了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()