Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';模块';对象没有属性';createFisherFaceRecognizer';?_Python_Python 2.7_Opencv - Fatal编程技术网

Python 属性错误:';模块';对象没有属性';createFisherFaceRecognizer';?

Python 属性错误:';模块';对象没有属性';createFisherFaceRecognizer';?,python,python-2.7,opencv,Python,Python 2.7,Opencv,我使用的是Python 2.7和OpenCV 3.2,我使用的是64位Windows。 我正在编写一个人脸识别代码,我想使用OpenCV人脸识别器 recognizer = cv2.face.createFisherFaceRecognizer() 但是当我运行代码时,我得到了这个错误, AttributeError:“模块”对象没有属性“createFisherFaceRecognizer” 我也试着这样写 recognizer=cv2.createFisherFaceRecognizer(

我使用的是Python 2.7和OpenCV 3.2,我使用的是64位Windows。 我正在编写一个人脸识别代码,我想使用OpenCV人脸识别器

recognizer = cv2.face.createFisherFaceRecognizer()
但是当我运行代码时,我得到了这个错误, AttributeError:“模块”对象没有属性“createFisherFaceRecognizer” 我也试着这样写
recognizer=cv2.createFisherFaceRecognizer()
但仍然得到同样的错误

这是代码,代码是kivy代码的一部分

def FaceRecognizer():
    recognizer = cv2.face.createFisherFaceRecognizer()
    recognizer.load('Trainer/Trainer.yml')
    face_detector = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
    cam = cv2.VideoCapture(0)
    font = cv2.cv.InitFont(cv2.cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0, 1, 1)
    while (True):
        retval,image = cam.read() # reading image from cam
        print np.shape(image)
        gray_image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) # converting image to gray image
        faces = face_detector.detectMultiScale(gray_image,1.3,5)
        ''' detectMultiScale, detects objects of different sizes in the input image.
        the detected objects are returned as a list of rectangles
        '''
        for (x,y,w,h) in faces:
            cv2.rectangle(image, (x,y), (x+w, y+h), (255,0,0), 2)
            Id, conf = recognizer.predict(gray[y:y+h,x:x+w])
            if(conf<50):
                    Id="Aladdin Hammodi"
            else:
                    Id= "Unknown"
            cv2.cv.PutText(cv2.cv.fromarray(im),str(Id), (x,y+h),font, 255)
        cv2.imshow('frame',image)
        if cv2.waitKey(100) & 0xFF == ord('q'):
            break

    cam.release()
    cv2.destroyAllWindows()
    output = "Recognition is done"
    return output
def FaceRecognizer():
识别器=cv2.face.createFisherFaceRecognizer()
识别器.load('Trainer/Trainer.yml'))
face_detector=cv2.CascadeClassifier('haarcascade_frontalface_default.xml'))
cam=cv2.视频捕获(0)
font=cv2.cv.InitFont(cv2.cv.cv\u font\u HERSHEY\u SIMPLEX,1,1,0,1,1)
虽然(正确):
retval,image=cam.read()#从cam读取图像
打印np.形状(图像)
gray_image=cv2.CVT颜色(图像,cv2.COLOR_BGR2GRAY)#将图像转换为灰度图像
面部=面部检测器。检测多尺度(灰度图像,1.3,5)
''detectMultiScale,检测输入图像中不同大小的对象。
检测到的对象作为矩形列表返回
'''
对于面中的(x,y,w,h):
cv2.矩形(图像,(x,y),(x+w,y+h),(255,0,0),2)
Id,conf=recognizer.predict(灰色[y:y+h,x:x+w])

如果(请给我们完整的代码,可能你是用cv2导入界面的
之类的东西导入的吗?
我从cv2导入界面尝试了一下,但遇到了这个错误,ImportError:无法导入名称界面否,请复制/粘贴你的完整代码。我们无法在此处执行任何操作。你确定opencv是用所需的模块构建的吗?我已将其添加到e上述问题