虚拟环境上的Opencv3和Python 2.7-AttributeError:“模块"对象没有属性"createLBPHFaceRecognizer" [英] Opencv3 and Python 2.7 on Virtual Environment - AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer'

查看:104
本文介绍了虚拟环境上的Opencv3和Python 2.7-AttributeError:“模块"对象没有属性"createLBPHFaceRecognizer"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有opencv 3的python函数.它在没有虚拟环境的情况下也可以工作.另外,我还在venv上从以下位置安装了opencv:

I have a python function with opencv 3. it works without virtual environment.Also I installed opencv on venv from:pyimagesearch. i am trying to run that python function on venv, then it gives an error :

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:

with venv in terminal:

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'

我的python代码:

my python code:

#!/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位上使用python 2.7运行Opencv3

I am running Opencv3 with python 2.7 on Linux Mint 64 Bit

推荐答案

在OpenCV 3中,您必须获取并构建 opencv_contrib 存储库.然后,您可以使用子模块"face".

From OpenCV 3, you have to get and build the opencv_contrib repo. Then you can use the submodule "face".

有关cv2中的模块cv2.face的帮助:

Help on module cv2.face in cv2:

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

Voila〜您现在可以使用cv2.face.createLBPHFaceRecognizer()

Voila~ You can now use cv2.face.createLBPHFaceRecognizer()

这篇关于虚拟环境上的Opencv3和Python 2.7-AttributeError:“模块"对象没有属性"createLBPHFaceRecognizer"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆