Calculate Eigen Vector and Eigen Value for PCA
I want to get eigenvalue and eigenvector. But it breaks. this is my part of code.
Mat covmat=((matdev*matdev.t())/3); //data float matrix 5*5, this's working. but when I add with PCA function. It's break.
PCA pt_pca(covmat, Mat(), CV_PCA_DATA_AS_ROW, 0);
Mat pt_eig_vals = pt_pca.eigenvalues;
for (int i = 0; i < 4; ++i)
cout << pt_eig_vals.at<float>(i, 0) <<endl;
This is the error. OpenCV error: Assertion Failed <data.channerls<> =="1"> in unknown function, file ......\src\opencv\modules\core\src\matmul.cpp
Please somebody help me :(. Thanks
what is
matdev
? (please show, how you construct that)can you try again to retrieve the correct error msg ?
data.channels()==1
would make sense,data.channels<>==1
is a syntax error.matdev is matrix data from txtfile like this.
maybe it helps, if you could also explain, how you got this, and what is inside your data ?
The data is vector x y -> 25 data. and I change/ reshape it to nxn = 5x5 (this is int). after that I convert to 32F. and that the result. any i idea for change it to 1 channel matrix with row n column same . thank you