def detectFaces(image_path):
"""
Open the image based on the image_path and find all faces in the image.
Finally, return the coordinates , width and height as a list
"""
img = cv2.imread(image_path)
face_cascade = cv2.CascadeClassifier("cvdata\\haarcascades\\haarcascade_frontalface_default.xml")
if img.ndim == 3:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
else:
gray = img
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3, minSize=(10,10),
flags=cv2.CASCADE_SCALE_IMAGE)
result = []
for (x,y,width,height) in faces:
result.append((x,y,x+width,y+height))
return result
face1.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录