python - AttributeError:“NoneType”对象没有属性“预测”
问题描述
#creating recognizer
recognizer= cv2.face_LBPHFaceRecognizer()
....
#predicting sad images
image_paths = [os.path.join(path, f) for f in os.listdir(path) if f.endswith('.sad')]
for image_path in image_paths:
predict_image_pil = Image.open(image_path).convert('L')
predict_image = np.array(predict_image_pil, 'uint8')
faces = faceCascade.detectMultiScale(predict_image)
for (x, y, w, h) in faces:
nbr_predicted, conf = recognizer.predict(predict_image[y: y + h, x: x + w])
....
得到错误
nbr_predicted, conf = Recognizer.predict(predict_image[y: y + h, x: x + w]) AttributeError: 'NoneType' object has no attribute 'predict'
如何解决这个错误,因为 face_PredictCollector() 也不起作用
解决方案
推荐阅读
- javascript - 如何在jquery属性值中设置变量
- php - 通过带有 href 的 id 链接获取价值
- aem - 是否可以在不使用 JavaScript 的情况下检查要在 AEM 网站上突出显示的特定文本?
- ios - 将通过 AlamoFire 下载的 MPEG 音频文件转换为 mp3 文件
- javascript - 不工作:Highcharts bar plotOptions series className
- amazon-web-services - 如何通过角色链接来限制 IAM 角色以获得比其本身所允许的更高的权限?
- graph-theory - 在无向图中找到所有可能的简单路径是 NP hard/ NP complete
- fortran - Fortran IIFIX 未知符号
- c# - 如何在“Unity”中使用 Firebase 在某些日子重置游戏分数
- sql - 避免循环导致的数据库往返