查了2天,发现原来是不能使用网上下载的“haarcascade_frontalface_default.xml”
使用自己系统中原有的“haarcascade_frontalface_default.xml”
因为是anconda下配置的环境,cv2的xml文件路径为“C:\ProgramData\Anaconda3\envs\tensorflow\Lib\site-packages\cv2\data”
使用网上下载的发在和.py文件一个路径下,出现错误“class 'cv2.CascadeClassifier' returned a result with an error set”
修改为C:\ProgramData\Anaconda3\envs\tensorflow\Lib\site-packages\cv2\data\haarcascade_frontalface_default.xml
可以正常显示。
参考了别人的回答,自己本地建一个xml,然后在线打开github中的haarcascade_frontalface_default.xml,拷贝过来,也可以运行!
cv2
opencv-contrib-python (4.1.0.25)
opencv-python (3.4.1.15)
是在虚拟环境tensorflow 下安装的,
activate tensorflow
pip install -i -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
pip install -i -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python
我的系统是win7 64 anconda3.0 创建了虚拟环境 tensorflow,在安装tensorflow时时
tensorboard (1.13.1)
tensorflow (1.13.1)
tensorflow-estimator (1.13.0)
tensorflow-tensorboard (1.5.1)
查看tensorboard图形。
切换到 tensorflow虚拟环境 activate tensorflow
pip install -i -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow1.13
pip install -i -i https://pypi.tuna.tsinghua.edu.cn/simple tensorboard1.13