Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

openCV recognition throws exception (LBPH algorithm)

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

openCV recognition throws exception (LBPH algorithm)

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);
            }
        }