简体   繁体   中英

I can't create an recognizer using the lastest opencv version

I'm' trying to build a face recognition project with python. But I've found a problem, I can't instantiate the recognizer because when I try execute this line:

recognizer = cv2.face.LBHFaceRecognizer_create()

I got this error:

AttributeError: module 'cv2.cv2' has no attribute 'face'

So I've searched for a solution in the web, much of them, suggested to execute this command on terminal:

pip install opencv-contrib-python

it doesn't solve the problem, I've tried to reinstall to but the problem remains. I've seek information about the documentation but it looks that there's a miss of information about how to create an recognizer in the web.Do Someone know how to solve the problem?

It works for me with a slight modification:

recognizer = cv2.face.LBPHFaceRecognizer_create()

I added a P after LB.

I have a working example here

If someone knows how to solve the problem this post shows exactly the solution for this problems step by step, it's only follow the first answer:

No module named 'cv2.cv2'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM