Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Unable to get Mahalanobis distance

$
0
0
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(sampleIdx) = dist; } if((dist < minDist) && (dist < _threshold)) { minDist = dist; minClass = _labels.at((int)sampleIdx); } }

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>