0
我碰到过这个link用于人脸检测和图像裁剪。我想使用这个脚本,但我有cv2安装,只导入cv2工程,但不导入cv。cv2相当于cv的属性
如何将以下函数中的cv函数转换为cv2函数?
def faces_from_pil_image(pil_image):
"Return a list of (x,y,h,w) tuples for faces detected in the PIL image"
storage = cv.CreateMemStorage(0)
facial_features = cv.Load('haarcascade_frontalface_alt.xml', storage=storage)
cv_im = cv.CreateImageHeader(pil_image.size, cv.IPL_DEPTH_8U, 3)
cv.SetData(cv_im, pil_image.tostring())
faces = cv.HaarDetectObjects(cv_im, facial_features, storage)
# faces includes a `neighbors` field that we aren't going to use here
return [f[0] for f in faces]
错误:'文件 “face_detect.py”,第55行,在faces_from_pil_image 存储= cv2.cv.CreateMemStorage(0) AttributeError:'模块'对象没有属性'cv'' – Sibi
你的'cv2 .__ version__'是什么?哪个版本的Python? – Mailerdaimon
Python 3.4。 cv2 3.1.0-dev – Sibi