Qengineering / Face-Recognition-with-Mask-Jetson-Nano

Recognize 2000+ faces on your Jetson Nano with additional mask detection, auto-fill and anti-spoofing
https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html
BSD 3-Clause "New" or "Revised" License
35 stars 6 forks source link

Issue with someone standing behind #4

Closed rsingh2083 closed 3 years ago

rsingh2083 commented 3 years ago

Theres one small issue. When the algorithm detects a tiny face (personA) at a distance, and then suddenly if someone comes near the camera (personB), then personB is also recognized as "too tiny". But when the personA from behind goes away, then personB is aptly recognized.

rsingh2083 commented 3 years ago

This same problem is occurring even with the raspberry code. My face is recognized , but as soon as someone comes in the background (at a distance of 3 to 4 metres from the camera) with a tiny face, then suddenly my face is also labelled as tinyFace. Sir can you please fix this issue

Qengineering commented 3 years ago

It would be of great help if you could record a little movie of the situation. Not the output of the app, but your webcam input. I can then easily play back the situation at my office.

rsingh2083 commented 3 years ago

Face recognized https://ibb.co/Yj78gCb : background person face is down, so foreground person is recognized as person4

Face not recognized https://ibb.co/wQYk5jQ : background person face is up and tiny, so foreground person is also recognized as tiny. Its a bug

Qengineering commented 3 years ago

I see the problem. Thanks for the images, it makes everything clear. All found faces are labeled as tiny by default on line 341 Faces[i].NameIndex = -2; //-2 -> too tiny Next a loop runs through the list to see if a face is recognized. line 352 for(i=0;i<Faces.size();i++){ However, keeping the app fast and given the fact that two or more faces probably are too tiny the be recognized accurate, I only investigate the situation with one face found. It is done by line 349 if(Faces.size()==1){ With one face, there is no problem, as in the image where the background person is faced downwards. With two faces, line 349 will block further recognition and both faces are still in their default state, labeled too tiny. Your solution is commenting line 349, which will disable the blocking. All found faces are now investigated.

349 //        if(Faces.size()==1){
         .........
487 //        }

You could place an extra test right behind the loop to filter out small faces on forehand.


349// if(Faces.size()==1){
            //looks stupid, running through a loop of size 1
            //however, for your convenience using [i]
            for(i=0;i<Faces.size();i++){
                float x1 = Faces[i].rect.x;
                float y1 = Faces[i].rect.y;
                float x2 = Faces[i].rect.width+x1;
                float y2 = Faces[i].rect.height+y1;

               if(Faces[i].rect.height < MinHeightFace) continue;  //<- too tiny ? skip the remaining part

}