Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use function calcCovarMatrix ?

image description

I want to compute the covariance matrix using function calcCovarMatrix in java. The size of covariance matrix should be 22 ,but result coming from the code is 1010 . I can not see the fail! Could you tell me? Thanks in advance!

Here is my code:

double[] a= new double[]{1.5,2.3,3.0,1.7,1.2,2.9,2.1,2.2,3.1,3.1, 1.3, 2.7,2.0,1.7, 1.0,2.0,0.5,0.6,1.0,0.9};

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

Mat srcMat = Mat.zeros(10, 2, CvType.CV_64FC1);

srcMat.put(0,0,a);

System.out.println(srcMat.dump());

Mat Avg = Mat.zeros(2,1, CvType.CV_64FC1);

Mat COV = Mat.zeros(2,2,CvType.CV_64FC1);

Core.calcCovarMatrix(srcMat,COV,Avg,Core.COVAR_ROWS);

System.out.println(Avg.dump());

System.out.println(COV.dump());