HelloWorld 发表于 2018-10-13 10:02:08

虚拟环境中的Opencv3和Python 2.7 - AttributeError:'module'对象没...

本帖最后由 HelloWorld 于 2018-10-13 10:12 编辑

   我有一个opencv 3的python函数。它在没有虚拟环境的情况下工作。我还在venv上安装了opencv:pyimagesearch。我试图在venv上运行该python函数,然后它给出一个错误:
AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer'
在终端没有venv:
gkhan@Gkan ~/Masaüstü/face_recognizer $ python face_recognizer.py
Yol :./sinif/114.jpg.
114 Yuz Tanindi 12与终端的venv:
gkhan@Gkan ~/Masaüstü/face_recognizer $ workon cv
(cv)gkhan@Gkan ~/Masaüstü/face_recognizer $ python face_recognizer.py
Traceback (most recent call last):
File "face_recognizer.py", line 15, in <module>
    recognizer = cv2.createLBPHFaceRecognizer()
AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer代码如下:
#!/usr/bin/python
# -*- coding: utf-8 -*-

import cv2, os
import numpy as np
from PIL import Image

# For Test
if 0==0:

    cascadePath = "haarcascade_frontalface_default.xml"
    faceCascade = cv2.CascadeClassifier(cascadePath)

    recognizer = cv2.createLBPHFaceRecognizer()
...我在Linux Mint 64 Bit上使用python 2.7运行Opencv3




stamina 发表于 2018-10-13 10:08:55

本帖最后由 stamina 于 2018-10-13 10:13 编辑

从OpenCV 3开始,您必须获取并构建opencv_contrib存储库。然后你可以使用子模块“face”。

NAME
    cv2.face

FILE
    (built-in)

FUNCTIONS
    createEigenFaceRecognizer(...)
      createEigenFaceRecognizer([, num_components[, threshold]]) -> retval

    createFisherFaceRecognizer(...)
      createFisherFaceRecognizer([, num_components[, threshold]]) -> retval

    createLBPHFaceRecognizer(...)
      createLBPHFaceRecognizer([, radius[, neighbors[, grid_x[, grid_y[, threshold]]]]]) -> retval
页: [1]
查看完整版本: 虚拟环境中的Opencv3和Python 2.7 - AttributeError:'module'对象没...