import cv2 as cv
import numpy as np
def face_detect_demo(image):
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
face_detector = cv.CascadeClassifier("1.xml")
#face_detector = cv.CascadeClassifier("2.xml")
#下载地址:https://github.com/opencv/opencv
faces = face_detector.detectMultiScale(gray, 1.02, 4)
for x, y, w, h in faces:
cv.rectangle(image, (x, y), (x+w, y+h), (0, 0, 255), 2)
cv.imshow("result", image)
src = cv.imread("person.png")
cv.namedWindow("input", cv.WINDOW_AUTOSIZE)
cv.namedWindow("result", cv.WINDOW_AUTOSIZE)
cv.imshow("input", src)
face_detect_demo(src)
cv.waitKey(0)
cv.destroyAllWindows()
06-02
2326
08-23
1075
12-26
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交