have this problem with PCACompute in Android Opencv2.3.1 because when i call PCACompute my eigenvectors are all 0. So, i take 10 photos for each people and i save it into a Mat of 100X100.
After that, i convert my 100X100 Mat in one Mat 1X10000 with this code:
double [] elem = null;
for(int riga=0;riga<m.rows();riga++)
{
for(int colonna=0;colonna<m.cols();colonna++)
{
elem = m.get(riga, colonna);
mrow.put(0,((riga*100)+colonna), elem[0]);
}//for colonna
}//for riga
After that, when i take 10 photos, i insert all Mat of the photos into one mat with this code:
double b[] = null;
for (int i = 0; i< listafoto.size(); i++)
{
Mat t = listafoto.get(i);
for(int riga = 0;riga<t.rows();riga++)
{
for(int colonna =0;colonna<t.cols();colonna++)
{
b = t.get(riga, colonna);
datiOriginali.put(i, colonna, b[0]);
}//for colonna
}//for riga
}//for lista e contemporaneamente riga datiOriginali
After that, i call PCACompute with this code: `
org.opencv.core.Core.PCACompute(datiOriginali,mean, eigenvectors, 10);`
So, datiOriginali is the input Mat of 10 rows and 10000 cols, mean and eigenvectors are the output matrix. mean matrix give me a result, but eigenvectors give me all 0. Can you help me to resolve this problem?
Thanks in advance.MArco
I based my code on the example at http://www.bytefish.de/blog/pca_in_opencv.
Here’s how I did this: