openCV recognition throws exception (LBPH algorithm)

asked 2013-12-17 07:18:55 -0600

sarwar026 gravatar image

updated 2013-12-17 09:00:28 -0600

Hello, I tried to detect and recognize face through LBPH algorithm. For that, I tried the following example:

Mastering OpenCV Chapter 8 FaceRecognition

The code runs and works successfully for Eignefaces and Fisherfaces but gives an exception when recognize for LBPH algorithm. I can't figure it out. The exception is:

OpenCV Error: Bad argument (no parameter 'eigenvectors' is found)  in unknown function, file "..\modules\core\src\algorithm.cpp" line 882.

In line 882,

CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );

So, what am I doing wrong? Please experts come and rescue me. Thanks

Update:

The following is the code where is the problem:

        else if (m_mode == MODE_RECOGNITION) {
            if (gotFaceAndEyes && (preprocessedFaces.size() > 0) && (preprocessedFaces.size() == faceLabels.size())) {

                // Generate a face approximation by back-projecting the eigenvectors & eigenvalues.
                Mat reconstructedFace;
                reconstructedFace = reconstructFace(model, preprocessedFace);
                if (m_debug)
                    if (reconstructedFace.data)
                        imshow("reconstructedFace", reconstructedFace);

                // Verify whether the reconstructed face looks like the preprocessed face, otherwise it is probably an unknown person.
                double similarity = getSimilarity(preprocessedFace, reconstructedFace);

                string outputStr;
                if (similarity < UNKNOWN_PERSON_THRESHOLD) {
                    // Identify who the person is in the preprocessed face image.
                    identity = model->predict(preprocessedFace);
                    outputStr = toString(identity);
                }
                else {
                    // Since the confidence is low, assume it is an unknown person.
                    outputStr = "Unknown";
                }
                cout << "Identity: " << outputStr << ". Similarity: " << similarity << endl;

                // Show the confidence rating for the recognition in the mid-top of the display.
                int cx = (displayedFrame.cols - faceWidth) / 2;
                Point ptBottomRight = Point(cx - 5, BORDER + faceHeight);
                Point ptTopLeft = Point(cx - 15, BORDER);
                // Draw a gray line showing the threshold for an "unknown" person.
                Point ptThreshold = Point(ptTopLeft.x, ptBottomRight.y - (1.0 - UNKNOWN_PERSON_THRESHOLD) * faceHeight);
                rectangle(displayedFrame, ptThreshold, Point(ptBottomRight.x, ptThreshold.y), CV_RGB(200,200,200), 1, CV_AA);
                // Crop the confidence rating between 0.0 to 1.0, to show in the bar.
                double confidenceRatio = 1.0 - min(max(similarity, 0.0), 1.0);
                Point ptConfidence = Point(ptTopLeft.x, ptBottomRight.y - confidenceRatio * faceHeight);
                // Show the light-blue confidence bar.
                rectangle(displayedFrame, ptConfidence, ptBottomRight, CV_RGB(0,255,255), CV_FILLED, CV_AA);
                // Show the gray border of the bar.
                rectangle(displayedFrame, ptTopLeft, ptBottomRight, CV_RGB(200,200,200), 1, CV_AA);
            }
        }
edit retag flag offensive close merge delete

Comments

1

lbp does not have eigenvectors / eigenvalues.

were you trying the eigenface visualization with lbp ? will only work with eigen/fisher, you'll have to skip/comment that part of the code, if using lbp

berak gravatar imageberak ( 2013-12-17 08:56:33 -0600 )edit

@berak: as I've added more codes, can you plz tell me whether the above code should only works for eigen/fisher NOT for LBPH? Thanks

sarwar026 gravatar imagesarwar026 ( 2013-12-17 09:03:23 -0600 )edit
  • reconstructFace -no
  • getSimilarity (yes, but there's no reconstructed face, so no)
  • identity = model->predict(preprocessedFace); // YES, and this is the essential needed thing
berak gravatar imageberak ( 2013-12-17 09:18:47 -0600 )edit

@berak: Thanks. In that case, I just need to call predict method directly, right?

sarwar026 gravatar imagesarwar026 ( 2013-12-17 09:23:01 -0600 )edit

yes !!!!!!

berak gravatar imageberak ( 2013-12-17 09:27:10 -0600 )edit

@berak: Thanks. It works as you said. If you post your comment as answer, I will accept it. Thanks for help.

sarwar026 gravatar imagesarwar026 ( 2013-12-18 04:44:17 -0600 )edit