c++ - OpenCV Mahalanobis function to calculate distance between two images -
i'm using opencv test similarity between 2 images taken same environment.
i have series of photos of same moving environment. being , b 2 binary images of edges of 2 sequential images of environment, following:
mat mean; mean.create(a.rows, a.cols, a.type()); mean += a; mean += b; mean/=2; mat covar, mean; calccovarmatrix(mean, covar, mean, covar_normal | covar_rows, cv_8uc1); mat icovar = covar.inv(); std::cout<<"type a:"<<a.type()<<"\n"; std::cout<<"type b:"<<b.type()<<"\n"; std::cout<<"icovar type:"<<icovar.type()<<"\n"; std::cout<<"a cols:"<<a.cols<<"\n"; std::cout<<"a rows:"<<a.rows<<"\n"; std::cout<<"b cols:"<<b.cols<<"\n"; std::cout<<"b rows:"<<b.rows<<"\n"; std::cout<<"icovar cols:"<<icovar.cols<<"\n"; std::cout<<"icovar rows:"<<icovar.rows<<"\n"; double mahaldistance = mahalanobis(a, b, icovar);
the matrixes same type , have following values:
type a:5 type b:5 icovar type:5 cols:1280 rows:400 b cols:1280 b rows:400 icovar cols:1280 icovar rows:1280
the mahalanobis distance function throws error following:
opencv error: assertion failed (type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols) in mahalanobis, file /users/felipefujioka/documents/developer/tg/opencv-3.0.0-beta/modules/core/src/matmul.cpp, line 2486 libc++abi.dylib: terminating uncaught exception of type cv::exception: /users/felipefujioka/documents/developer/tg/opencv-3.0.0-beta/modules/core/src/matmul.cpp:2486: error: (-215) type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols in function mahalanobis
i'd apreciate know i'm wrong. in advance.
you mix a
ma
, b
mb
in code. have tried mahalanobis(ma, mb, icovar)
?