Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unable to get Mahalanobis distance

I am trying to find the Mahalanobis distances between a test sample and a few training data (At&t database). I took http://answers.opencv.org/question/3494/adding-new-method-in-facerecognizer/ as reference for my code. When I run the code I am getting the following error

Blockquote

"OpenCV Error: Assertion failed (type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols) in Mahalanobis, file /home/valuser/opencv-2.4.9/modules/core/src/matmul.cpp, line 2244 " Please find the code snippet for mahalanobis distance here http://pastebin.com/Mg8DbFQJ

Unable to get Mahalanobis distance

I am trying to find the Mahalanobis distances between a test sample and a few training data (At&t database). I took http://answers.opencv.org/question/3494/adding-new-method-in-facerecognizer/ as reference for my code. When I run the code I am getting the following error

Blockquote

"OpenCV Error: Assertion failed (type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols) in Mahalanobis, file /home/valuser/opencv-2.4.9/modules/core/src/matmul.cpp, line 2244 " "

Please find the code snippet for mahalanobis distance here http://pastebin.com/Mg8DbFQJ

Unable to get Mahalanobis distance

I am trying to find the Mahalanobis distances between a test sample and a few training data (At&t database). I took http://answers.opencv.org/question/3494/adding-new-method-in-facerecognizer/ as reference for my code. When I run the code I am getting the following error

"OpenCV Error: Assertion failed (type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols) in Mahalanobis, file /home/valuser/opencv-2.4.9/modules/core/src/matmul.cpp, /home/opencv-2.4.9/modules/core/src/matmul.cpp, line 2244 "

Please find the code snippet for mahalanobis distance here http://pastebin.com/Mg8DbFQJ

Unable to get Mahalanobis distance

I am trying to find the Mahalanobis distances between a test sample image and a few training data images (At&t database). I took http://answers.opencv.org/question/3494/adding-new-method-in-facerecognizer/ as reference for my code. When I run the code I am getting the following error

"OpenCV Error: Assertion failed (type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols) in Mahalanobis, file /home/opencv-2.4.9/modules/core/src/matmul.cpp, line 2244 "

Please find the code snippet for mahalanobis distance here http://pastebin.com/Mg8DbFQJ

click to hide/show revision 5
No.5 Revision

updated 2015-09-07 04:39:50 -0600

berak gravatar image

Unable to get Mahalanobis distance

I am trying to find the Mahalanobis distances between a test sample image and a few training data images (At&t database). I took http://answers.opencv.org/question/3494/adding-new-method-in-facerecognizer/ as reference for my code. When I run the code I am getting the following error

"OpenCV Error: Assertion failed (type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols) in Mahalanobis, file /home/opencv-2.4.9/modules/core/src/matmul.cpp, line 2244 "

Please find the code snippet for mahalanobis distance here http://pastebin.com/Mg8DbFQJ

Mat covar, invcovar, mean;
for(size_t sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {

    calcCovarMatrix(_projections[sampleIdx], covar, mean, CV_COVAR_SCRAMBLED|CV_COVAR_ROWS,CV_64F); //Calculating the covariance matrix
      invert(covar, invcovar, DECOMP_SVD);                          //Calculating the inverse covariance matrix
        double dist=Mahalanobis( _projections[sampleIdx], q, invcovar );
         // Add to the resulting distance array:
        if(distances.needed()) {
            distances.getMat().at<double>(sampleIdx) = dist;
        }
        if((dist < minDist) && (dist < _threshold)) {
            minDist = dist;
            minClass = _labels.at<int>((int)sampleIdx);
        }
     }