PCACompute Opencv 返回特征向量 = 0
Android Opencv2.3.1 中的 PCACompute 有这个问题,因为当我调用 PCACompute 时,我的特征向量都是 0。所以,我为每个人拍了 10 张照片,并将其保存到 100X100 的 Mat 中。 之后,我使用以下代码将我的 100X100 Mat 转换为一个 Mat 1X10000:
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
之后,当我拍摄 10 张照片时,我使用以下代码将照片的所有 Mat 插入到一个 Mat 中:
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
之后,我使用以下代码调用 PCACompute:`
org.opencv.core.Core.PCACompute(datiOriginali,mean, eigenvectors, 10);`
所以,datiOriginali是10行10000列的输入Mat,均值和特征向量是输出矩阵。平均矩阵给我一个结果,但特征向量给我全0。你能帮我解决这个问题吗? 提前致谢。MArco
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的代码基于 http://www.bytefish.de/blog/pca_in_opencv 上的示例。
我是这样做的:
I based my code on the example at http://www.bytefish.de/blog/pca_in_opencv.
Here's how I did this: