How to get eigenvalues in opencv java?

asked 2013-06-03 11:08:13 -0500

orochi gravatar image

updated 2013-06-03 23:12:04 -0500

Hi guys, i have this snipped code

coeffs.<Double>at(0,0) = ((value1 * 1.0 / alphaMax) - 0.5) * 2 * 3 * Math.sqrt(pca.eigenvalues.<Double>at(0,0));

and i want to write it in java language. based on what i have read, if above code i write into java it will become like this

    //coeffs is CV_64f
    double coeffsBuff[] = new double[(int) (coeffs.total() * coeffs.channels())];
    double pcaEigenvalueBuff[] = new double[(int) (pcaEigenvalue.total() * pcaEigenvalue.channels())];

Mat pcaEigenvalue = new Mat();
Mat pcaEigenvactor = new Mat();

Core.eigen(pca, true, pcaEigenvalue, pcaEigenvactor);

coeffs.get(0, 0, coeffsBuff);
coeffsBuff = ((value1 * 1.0 / alphaMax) - 0.5) * 2 * 3 * Math.sqrt(pcaEigenvalue.get(0, 0, pcaEigenvalueBuff));

i got an error because coeffsBuff require double[] value meanwhile ((value1 * 1.0 / alphaMax) - 0.5) * 2 * 3 * Math.sqrt(pcaEigenvalue.get(0, 0, pcaEigenvalueBuff)) return double value. can anybody tell me how to convert those code into java?

edit retag flag offensive close merge delete