关于opencv找不到cv2文件夹,找不到分类器的解决方案

下载了opencv之后,运用代码,报错找不到分类器 

import  cv2

def facedetect(windowname,camera_id):
#命名和打开摄像头
    cv2.namedWindow(windowname) # 创建一个已windowname为名字的窗口

    cap=cv2.VideoCapture(camera_id) # camera_id为设备摄像头的id,默认是0,如果有usb摄像头可能会变为1
    # Face Detection using Haar Cascades http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html?highlight=cascadeclassifier
    classfier=cv2.CascadeClassifier('haarcascade_frontalface_alt2.xml') #

    color=(0,225,0)#人脸框的颜色,采用rgb模型,这里表示g取255,为绿色框

    while cap.isOpened():
        ok,frame=cap.read() # 读取一帧数据,ok表示摄像头读取状态,frame表示摄像头读取的图像矩阵mat类型
        if not ok:
            break
        # 灰度化在后面检测时可以降低计算量,cvtColor changing colorspace
        gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)#图像灰度化,cv2.cvtColor(input_image, flag) where flag determines the type of conversion.
 # detectMultiScale完成人脸探测工作,returns the positions of detected faces as Rect(x,y,w,h),x、y是左上角起始坐标,h、w
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值