0

I have been using OpenCv Libraries for awhile , used and understood a code that detects [Only one face] and recognize it the main functions are there .. this is the function of recognition

// Find the most likely person based on a detection. Returns the index, and stores the confidence value into pConfidence.
int findNearestNeighbor(float * projectedTestFace, float *pConfidence)
{
double leastDistSq = DBL_MAX;
int i, iTrain, iNearest = 0;

for(iTrain=0; iTrain<nTrainFaces; iTrain++)
{
    double distSq=0;

    for(i=0; i<nEigens; i++)
    {
        float d_i = projectedTestFace[i] - projectedTrainFaceMat->data.fl[iTrain*nEigens + i];
#ifdef USE_MAHALANOBIS_DISTANCE
        distSq += d_i*d_i / eigenValMat->data.fl[i];  // Mahalanobis distance (might give better results than Eucalidean distance)
#else
        distSq += d_i*d_i; // Euclidean distance.
#endif
    }

    if(distSq < leastDistSq)
    {
        leastDistSq = distSq;
        iNearest = iTrain;
    }
}

// Return the confidence level based on the Euclidean distance,
// so that similar images should give a confidence between 0.5 to 1.0,
// and very different images should give a confidence between 0.0 to 0.5.
*pConfidence = 1.0f - sqrt( leastDistSq / (float)(nTrainFaces * nEigens) ) / 255.0f;

// Return the found index.
return iNearest; 
}

after that it would return the value of iNearest to the follow code

        // Check which person it is most likely to be.
            iNearest = findNearestNeighbor(projectedTestFace, &confidence);
            nearest  = trainPersonNumMat->data.i[iNearest];

            printf("Most likely person in camera: '%s' (confidence=%f).\n", personNames[nearest-1].c_str(), confidence);

how can I let it recognize the unknown person as unknown and stop comparing to with the faces in my db ?

also how can i detect multi-faces at once?.

0 Answers0