安装opencv
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
测试代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
import numpy as np import cv2 as cv cap = cv.VideoCapture(0) if not cap.isOpened(): print("Cannot open camera") exit() while True: # 逐帧捕获 ret, frame = cap.read() # 如果正确读取帧,ret为True if not ret: print("Can't receive frame (stream end?). Exiting ...") break # 我们在框架上的操作到这里 gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) # 显示结果帧e cv.imshow('frame', gray) if cv.waitKey(1) == ord('q'): break # 完成所有操作后,释放捕获器 cap.release() cv.destroyAllWindows()View Code
编译Cpython
pip install Cpython #在/utils/mesh/cython打开cmd,activate “虚拟环境”,运行下两行 python setup.py build_ext --inplace python setup.py install
标签:masker,python,frame,cap,ret,face,install,cv From: https://www.cnblogs.com/su1212/p/16740873.html