我已经安装了带有额外模块的opencv 3.1.0,但是当我尝试使用
时>>> s = cv2.face.MinDistancePredictCollector()
它会返回错误
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
s.MinDistancePredictCollector()
AttributeError: 'module' object has no attribute 'MinDistancePredictCollector'
我还检查了文档:
>>> help(cv2.face)
Help on module cv2.face in cv2:
NAME
cv2.face
FILE
(built-in)
FUNCTIONS
StandardCollector_create(...)
StandardCollector_create([, threshold]) -> retval
createEigenFaceRecognizer(...)
createEigenFaceRecognizer([, num_components[, threshold]]) -> retval
createFisherFaceRecognizer(...)
createFisherFaceRecognizer([, num_components[, threshold]]) -> retval
createLBPHFaceRecognizer(...)
createLBPHFaceRecognizer([, radius[, neighbors[, grid_x[, grid_y[, threshold]]]]]) -> retval
我发现MinDistancePredictCollector()
不存在。那么我该如何安装呢?
答案 0 :(得分:3)
我刚刚在Github上问了同样的问题,可以通过以下代码解决:
if cv2.__version__ >= "3.1.0":
collector = cv2.face.StandardCollector_create()
recognizer.predict_collect(face_img, collector)
conf = collector.getMinDist()
pred = collector.getMinLabel()
else: # older version
pred, conf = recognizer.predict(face_img)