2017-02-03 295 views
1

我使用的是Ubuntu 16.04(64位)python2.7 Open-CV 3.1.0 我已经遵循了将Open-CV额外模块的Repository下载到通过 https://github.com/opencv/opencv_contrib激活此功能, 但是我得到了同样的错误,我也采用了最新的开放式CV 3.2.0,而不是3.1.0试过,但我已经得到了同样的错误:AttributeError:'模块'对象没有属性'createFisherFaceRecognizer'

AttributeError: 'module' object has no attribute 'createFisherFaceRecognizer'. 

的一部分我的代码:

import numpy as np 
import cv2 
import sys 
import os 
class TrainFisherFaces: 
    def __init__(self): 
     cascPath = "haarcascade_frontalface_default.xml" 
     self.face_cascade = cv2.CascadeClassifier(cascPath) 
     self.face_dir = 'data' 
     self.face_name = sys.argv[1] 
     self.path = os.path.join(self.face_dir, self.face_name) 
     if not os.path.isdir(self.path): 
      os.mkdir(self.path) 
     self.model = cv2.createFisherFaceRecognizer() 

回答

2

看来,createFisherFaceRecognizer()是在Python中的子模块cv2.face。要访问它,你应该cv2.face.createFisherFaceRecognizer()

从教程example用于面部识别在C++改编。我将这个安装作为问题中描述的那个安装,并对其进行了测试。

+0

它给我这个错误:AttributeError:'模块'对象没有属性'脸' – Bolly

+0

这很奇怪。我得到了与OpenCV 3.1完全相同的配置。如果我从cv2.face模块中调用createFisherFaceRecognizer(),则完美适用于我。 – NAmorim

+0

谢谢,我发现我没有正确卸载我的旧OpenCV,正确地按照说明正确下载它并添加cv2.face后,它可能工作! – Bolly

相关问题