I am trying to implement mahalanobis distance using OpenCV and VC++ 2010.
I know the algorithm for it, the function.
(x-mean)^T*inv(covarmatrix)*(x-mean)
But when I implement it in OpenCV it just gives errors over and over.
this is my code where I am calculating the covariance matrix.
int Main(){
Mat Image;
Mat, Cov,mean;
float samples=1920000;
calcCovarMatrix(image,samples,covmat,mean,CV_COVAR_NORMAL);
}
the calcCovarMatrix
gives error:
no instance of overloaded function calcCovarMatrix matches the argument list.
After I would then do
vec3b pixel;
icovar=covmat^-1;
mdist = mahalanobis(vec3b,mean,icovar);
Note: I calculate mahalanobis distance without square root, but the above function does square root, how comes and also I will square it to make it fair as I did the same to get the threshold distance.
thanks