Checking if face was in previous frame

asked 2016-10-06 09:26:43 -0600

atv gravatar image

updated 2016-10-06 09:30:57 -0600

To avoid false positives or unknowns which only happens in 1 frame (and quick oscillations between predictions), i thought i could do something like this and make sure it happens at least in 2 frames.

prototype code:

int framenumber; // global framecounter

for {
framenumber++;
       { // face loop
            //prediction
           if(framenumber==usernode.framenumber { // if in sync we got face for at least 2 contigious frames, so show it
    showprediction
           usernode.framenumber++; // per user framecounter

The above would work fine if there was only 1 face and if the face showed up every frame. Which is not realistic (and in that case i wouldn't have a problem to worry about). I need some formula that would incorporate the differing amount of recognitions as shown below (400x20x1) and multiply that by the amount of times we have seen that person.

I'm thinking maybe uses a modulus ? I'm not great at math and it seems like a simple thing but it seems to elude me all afternoon as to what the best approach is.

frames persons instances of person

400 peterx20recognitions 1

400 annax16recognitions 4

edit retag flag offensive close merge delete

Comments

1

I have no idea what you're actually doing. I understand the problem, that you want to avoid false detections, but I don't know what information you have, what the code is supposed to be doing, or what that table means.

If you could try to clarify that, I'll try to help.

Tetragramm gravatar imageTetragramm ( 2016-10-06 18:20:44 -0600 )edit

i also have no idea, what you're doing there. is it "tracking" ?

berak gravatar imageberak ( 2016-10-07 00:55:05 -0600 )edit

To track faces inside subsequently frames you need a tracking framework, something like Kalman filter or Parrticle Filtering. Start with googling on those terms. No good to reinvent the wheel.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-10-07 04:41:14 -0600 )edit

It's not tracking, i think that would be to much overkill for what i need.

The basic idea is: As i sometimes get false positives where something is mistakenly detected as a face (but it only appears for a second or so) i thought i would put in a basic check if that face was still there in the subsequent frame

Ignore the column, that was just something i used to illustrate for myself (400 frames, peter was 20 times recognized in that 400 frames, and instances is a dynamic value that counts how many times peter is on screen (so i could factor that in as a multiplier).

I'm keeping a linked list of recognized users, so i could keep track of the user that way. The code displayed is your run of the mill facerecognizer code, with a for loop for getting the frames, and another to processtheface

atv gravatar imageatv ( 2016-10-07 08:16:08 -0600 )edit

I just need a simple way by way of a marker if the user appeared in 2 contiguous frames. I could tune detectmultiscale but i don't want to loose any precision in detecting faces.

atv gravatar imageatv ( 2016-10-07 08:19:23 -0600 )edit

How about something like this:

int framenumber;

for(;;) {
if(framenumber==2)
framenumber==0;

framenumber++;
for(;;) // faces

//after predict
if(predict) {
usernode.framenumber++;

if(framenumber+usernode.instances==usernode.framenumber+usernode.instances)  {
showprediction
framenumber=0;
usernode.framenumber=0;
}
atv gravatar imageatv ( 2016-10-07 09:39:35 -0600 )edit