FaceRecognizer debug & enhance

EDIT 5/11/2017 - Video explanations ( inmoov use )

 

EDIT 4/11/2017 - Added unicode support

Added unicode support to this filter because opencv dont like it ( cannot use unicode inside folder names ).

Nothing will change about use, but want to explain the workarround :
Because opencv create a folder based on the trained name we need to map the trained unicode name to ascii name. I use an extra file called "THENAME".label , and use a random string for folder name. This is mapped inside internal hashMap

---------------

First report  :

Inside this test there are 4 faces. 3 of those faces are correctly parsed by cascade classifiers.

2 faces was trained ( Ryan + Rachel )

 

 

 

 

Script : https://github.com/MyRobotLab/pyrobotlab/blob/develop/home/moz4r/Test/Fa...


#file : home/moz4r/Test/FaceRecognizer.py edit raw
opencv = Runtime.start("opencv","OpenCV")
opencv.setMinDelay(500)
opencv.captureFromImageFile("resource/OpenCV/testData/ryan.jpg")

Python = Runtime.start("Python","Python")

Python.subscribe("opencv", "publishRecognizedFace")
def onRecognizedFace(name):
    print(name)

opencv.capture()



#### LKOpticalTrack ####################
# experiment with Lucas Kanade optical flow/tracking
# adds the filter and one tracking point
opencv.addFilter("PyramidDown")
fr=opencv.addFilter("FaceRecognizer")
fr.train()
opencv.setDisplayFilter("FaceRecognizer")
sleep(5)
opencv.captureFromImageFile("resource/OpenCV/testData/nok-test2.jpg")
sleep(5)
opencv.captureFromImageFile("resource/OpenCV/testData/rachel.jpg")
sleep(5)
opencv.captureFromImageFile("resource/OpenCV/testData/OK-test1.jpg")

2 problems :

1 clear face is not parsed ( nok-test2.jpg ).

1 face ( OK-test1.jpg is reconized as Ryan a previous trainded face. This guy is not ryan ( tested with other faces too, it seem something is forced when the classifier detect a no trained face.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kwatters's picture

nice video!

Moz4r, fantastic video!  You've got it basically all working.  There are some keys to how the current face recognition works.

1. as you know, you need at least 2 faces trained before it will recognize anyone.

2. it will always guess the face based on who it knows.  It does not have a concept of an unknown person.

3. face recognition only occurs when both the eyes , mouth , and a face is detected.  This is pretty strict, we could relax this.

So, it's not that face recognition is broken, it's just that , I think , we want it to work better :)

The original implementation that we did (with scruffybob's help) is very strict and doesn't attempt to make a face recognition prediction until it's very very confident that it's seen a face.  This is a decision that favors "precision" over "recall".  

the idea is that it will only predict a face being recognized in a very conservative manor, we can relax this requirement and in a way, I think that's probably a good idea....  maybe we could require a very strict match for training, and a looser match for recognition... 

That's one issue that you're probably seeing, the second issue is there is no concept of an unknown face with the current face recognition algorithm and I think that problem needs a bit more thought...

 

 

 

moz4r's picture

Hi Kevin can you help me to

Hi Kevin can you help me to implement concept of an unknown person I don't know where to start..

Goal is to use publishNoRecognizedFace(), store the face as temp, and ask the name.

I didnt find how the filter chose a random picture for an unknown person and fake the result

 

GroG's picture

Wow Moz4r !That's the way to

Wow Moz4r !

That's the way to do a tutorial !  Inspiring !

Nice worky-round !

Looks like the request has been there for a while - https://github.com/opencv/opencv/issues/4242

Ash's picture

Great !! ;-) I like your

Great !! ;-)

I like your work, thanks moz4r