from future import print_function
from facedetector import FaceDetector
import argparse
import cv2
import os
i = 0
ap = argparse.ArgumentParser()
“”“ap.add_argument(”-f", “–face”, required=True,
help=“path to where the face cascade resides”)"""
“”“ap.add_argument(”-i","–image",required=True,
help=“path to where the image file resides”)"""
args =vars(ap.parse_args())
“”“image =cv2.imread(args[“image”])”""
#fd = FaceDetector(args[“face”])
path = ‘D:/Big semester/project/Computer vision/face_and_car/jpg’
path1 = ‘D:/Big semester/project/Computer vision/face_and_car/model’
for lists1 in os.listdir(path1):
for lists in os.listdir(path):
if lists1 == “oneface.xml” :
su_path1 = os.path.join(path1, lists1)
fd = FaceDetector(su_path1)
su_path = os.path.join(path,lists)
image = cv2.imread(su_path, cv2.IMREAD_COLOR)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faceRects =

这篇博客展示了如何使用Python和FaceDetector库来检测一张照片中的人脸。通过读取图像文件,应用预训练的面部检测模型,然后在灰度图像上检测面部区域,用矩形框标记出来,并将检测到的每张人脸保存为单独的图片。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



