OpenCV解决:AttributeError: module ‘cv2‘ has no attribute ‘data‘

OpenCV解决:AttributeError: module ‘cv2’ has no attribute 'data’
运行人脸检测代码时会出现如下报错:

face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml') 
AttributeError: module 'cv2' has no attribute 'data'

解决方法:

将()里的路径改为绝对路径即可,
如('opencv/data/haarcascades/haarcascade_frontalface_default.xml')

你可能感兴趣的:(OpenCV问题,opencv,人工智能)