Giter Site home page Giter Site logo

opencv-face-recognition's Introduction

opencv-face-recognition's People

Contributors

mjrovai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencv-face-recognition's Issues

module 'cv2' has no attribute 'face'

I got this error while trying to run 02_face_training.py. I think I got opencv_contrib successfully installed by following Adrian Rosebrock's Raspbian Stretch: Install OpenCV 3 + Python on your Raspberry Pi. cv2.version also returns the correct value.

Some answers from Stackoverflow suggest running these command: pip install opencv-python and pip install OpenCV-contrib-python. After doing that, however, import cv2 gets an error and version check fails as well.

So, anyone got a solution?

PS: Pillow is installed and I'm doing all of these within the 'cv' virtual environment.

Value Error: Face Training

id = int(os.path.split(imagePath)[-1].split(".")[1])
ValueError: invalid literal for int() with base 10: 'Shubham'

Getting an invalid literal issue while using trying to implement face training. Could not find a solution on stackoverflow. Will be greatful if you help. Thank You!

IndexError: list index out of range

Error in Face_recoginition_3 shows the error

Traceback (most recent call last):
File "C:\Users\sub\PycharmProjects\Face_Detection\face_recog.py", line 31, in
id = names[id]
IndexError: list index out of range

IndexError: list index out of range

Been trying to solve this error but have no luck, tried all whatever was said in https://www.hackster.io/mjrobot/real-time-face-recognition-an-end-to-end-project-a10826 comment section, but same error. My code is :

`''''
Real Time Face Recogition
==> Each face stored on dataset/ dir, should have a unique numeric integer ID as 1, 2, 3, etc
==> LBPH computed model (trained faces) should be on trainer/ dir
Based on original code by Anirban Kar: https://github.com/thecodacus/Face-Recognition

Developed by Marcelo Rovai - MJRoBot.org @ 21Feb18

'''

import cv2
import numpy as np
import os

recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('trainer/trainer.yml')
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath);

font = cv2.FONT_HERSHEY_SIMPLEX

#iniciate id counter
id = 0

names related to ids: example ==> Marcelo: id=1, etc

names = ["PhotoAni", "Aniket", "Mum", "Dad"]

Initialize and start realtime video capture

cam = cv2.VideoCapture(0)
cam.set(3, 640) # set video widht
cam.set(4, 480) # set video height

Define min window size to be recognized as a face

minW = 0.1cam.get(3)
minH = 0.1
cam.get(4)

while True:

ret, img =cam.read()
#img = cv2.flip(img, -1) # Flip vertically

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

faces = faceCascade.detectMultiScale( 
    gray,
    scaleFactor = 1.2,
    minNeighbors = 5,
    minSize = (int(minW), int(minH)),
   )

for(x,y,w,h) in faces:

    cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0), 2)

    id, confidence = recognizer.predict(gray[y:y+h,x:x+w])

    # Check if confidence is less them 100 ==> "0" is perfect match 
    if (confidence < 100):
        id = names[id]
        confidence = "  {0}%".format(round(100 - confidence))
    else:
        id = "unknown"
        confidence = "  {0}%".format(round(100 - confidence))
    
    cv2.putText(img, str(id), (x+5,y-5), font, 1, (255,255,255), 2)
    cv2.putText(img, str(confidence), (x+5,y+h-5), font, 1, (255,255,0), 1)  

cv2.imshow('camera',img) 

k = cv2.waitKey(10) & 0xff # Press 'ESC' for exiting video
if k == 27:
    break

Do a bit of cleanup

print("\n [INFO] Exiting Program and cleanup stuff")
cam.release()
cv2.destroyAllWindows()
`

The error is:

C:\Users\anike\Downloads\Setups\Dev\OpenCV-Face-Recognition-master\FacialRecognition>python 03_face_recognition.py
Traceback (most recent call last):
File "03_face_recognition.py", line 59, in
id = names[id]
IndexError: list index out of range
[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback

Same name (ID) on different faces

Hi...I am having a problem in face recognition.

I used LBPHFaceRecognizer() in training and pre trained HaarCascadeClassifier in face recognition.

I used two samples faces and 30 images of each face. Whenever I tested the model using a new face (that the model has not ben trained for) instead of showing un known it every time shows the name of the first face which I used for the training.

Can you help me in this regard?

OpenCV Error: Assertion failed (

While running face detection.py script I am facing this issue.

OpenCV Error: Assertion failed (!empty()) in detectMultiScale, file /home/pi/opencv-3.3.0/modules/objdetect/src/cascadedetect.cpp, line 1698

Confidence level

Your work is simply amazing. During my implementation, to leverage the model confidence value I'm using 100 images and still, the algorithm predicts the confidence value of less than 50. In addition, I observe many false positives during recognition. I tried tweaking the confidence values but still, the same problem persists. Am I missing something here?

Traceback Error

Traceback (most recent call last):
File "C:... /OpenCV-Face-Recognition-master/FacialRecognition/02_face_training.py", line 21, in
recognizer = cv2.face.LBPHFaceRecognizer_create()
AttributeError: module 'cv2.cv2' has no attribute 'face'

OpenCV help

I'm following Adrian's installation for OpenCV 3
Latest Raspbian Jessie
Raspberry Pi 4
I'm stuck at compiling OpenCV 3 with 2 errors

fatal error: stdlib.h: No such file or directory

What should I do?

Name display problem

Code run correctly but name will not display , instead of name unknown will be print

How to run an action upon seeing someone who hasn't been trained in?

Hi! I love this amazing face recognizer that you have made, and I play with it so much. There is one thing that I have a question about, though: How do you run an action upon seeing someone who hasn't been trained into the system? Basically, if the AI sees someone, and it isn't ID 1, 2, 3, etc., what ID is it? I know the code for if a certain ID is found, which is:
elif str(id) == "1":
confidence = " {0}%".format(round(100 - confidence))

but no matter how much I have toyed around with the confidence settings, I cant get it to work.
Is there is a fix to this?

Negative confidence

I am getting negative confidence in 03_face_recognition.py. I didn't modify the code, and I don't understand how getting negative confidence is possible.

Error in face detection code

while running face detection code
faces = faceCascade.detectMultiScale(gray,scaleFactor=1.2,minNeighbors=5,minSize=(20,20))

got error as

error: OpenCV(4.1.0) /io/opencv/modules/objdetect/src/cascadedetect.cpp:1658: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'

please help me to resolve. thanks in advance.

Is it possible to make a live trainning ?

HI,

Thank for your code, it is very clear and it helps me a lot.
I am new in this world and i am looking for information specificly about the live trainning.
By that i mean a code that could add any new face it appears in front of the camera in order to disciminate them continiously.

I know that if you do that you will not make a good dataset but i would have the choice to refine the dataset for one specific ID later.
I see a way to do that with your code by refhreshing the path of the model after we retrain it, but is it a good way to do that ?

Thanks
Jon

[ERROR:[email protected]]

global D:\a\opencv-python\opencv-python\opencv\modules\core\src\persistence.cpp (505) cv::FileStorage::Impl::open Can't open file: 'Cascades/haarcascade_frontalface_default.xml' in read mode

How to preprocess?

Can you also add some code for preprocessing the image before training it

Is there any assistance needed ?

Hi everyone,
I would love to contribute to this project, however I am not sure if maintainers are still active here ... ๐Ÿค”
Would appreciate your answer.

Dataset

where is the dataset stored??

cant solve error in trainer part

File "sample.py", line 25, in
faces,ids = getImagesAndLabels(path)
File "sample.py", line 16, in getImagesAndLabels
PIL_img = Image.open(imagePath).convert('L') # grayscale
File "C:\Users\HP\lib\site-packages\PIL\Image.py", line 2904, in open
fp = builtins.open(filename, "rb")
PermissionError: [Errno 13] Permission denied: 'dataset\trainer'

what to do?

how to solove stagnant problem?

When running faceDetection.py on pi3B, CPU reached 100%, and the video was also obviously stagnant. How to solve this problem? thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.