周村有做网站广告的吗,怎么开通网站,四维码制作网站,天河区网站公司python-opencv 人脸检测
代码还使用到了dlib 和face_recognition这两个库#xff0c;需要安装一下#xff0c;看一下代码#xff1a;
import face_recognition
import cv2# 创建视频捕捉对象
video_capture cv2.VideoCapture(0)
print(video_capture.isOpened())# video_…python-opencv 人脸检测
代码还使用到了dlib 和face_recognition这两个库需要安装一下看一下代码
import face_recognition
import cv2# 创建视频捕捉对象
video_capture cv2.VideoCapture(0)
print(video_capture.isOpened())# video_capture.set(3, 1280)
# video_capture.set(4, 480)while video_capture.isOpened():# ret 表示读取是否成功# frame 具体的图像数据ret, frame video_capture.read()# 尺寸缩放为原来的 1/4# 作用为了加速人脸检测过程small_frame cv2.resize(frame, None, fx0.25, fy0.25)# bgr - rgbrgb_frame small_frame[:, :, ::-1]# 拿到人脸坐标face_loc face_recognition.face_locations(rgb_frame)for (top, right, bottlm, left), in zip(face_loc):top * 4right * 4bottlm * 4left * 4cv2.rectangle(frame,(left, top),(right, bottlm),(255, 0, 0),2)cv2.imshow(face detection, frame)# 退出条件if cv2.waitKey(1) 0xFF 27:breakvideo_capture.release()
cv2.destroyAllWindows()