首页 > 技术文章 > #利用openCV裁脸

ansang 2018-02-16 13:59 原文

#利用openCV裁脸

import
cv2 def draw_rects(img, rects): for x, y, w, h in rects: cv2.rectangle(img, (x, y), (x+w, y+h), (255, 255, 00), 2) cv2.circle(img, (x, y), 1, (0, 0, 255), 10) print(img.shape) imgs = img[y :y + h , x :x + w ] print(imgs.shape) cv2.imshow('img', imgs) haar__cascade_path = "haarcascade_frontalface_default.xml" face_cascade = cv2.CascadeClassifier(haar__cascade_path) print(face_cascade) img = cv2.imread("7.jpg") faces = face_cascade.detectMultiScale(img, 1.5, 4) print(faces) draw_rects(img,faces) cv2.waitKey(0) cv2.destroyAllWindows()

 

推荐阅读