人脸识别步骤:项目测试图像

时间:2014-04-16 16:22:56

标签: c++ opencv

我对特征脸识别步骤的理解存在一些问题,我已经在某处读过我们必须将测试图像投影到本征空间,然后计算投影图像测试与存储之间的距离投影向量。

// READ THE STORED LEARN DATA
FileStorage fs("test.xml", FileStorage::READ);
Mat stored_mean, stored_eigenvalues, stored_vectors, stored_projections, stored_labels;
int stored_num_componants = fs["num_components"];
fs["mean"] >> stored_mean;
fs["eigenvalues"] >> stored_eigenvalues;
fs["eigenvectors"] >> stored_vectors;
fs["projections"] >> stored_projections;
fs["labels"] >> stored_labels;

// PROJECT THE TEST IMAGE
Mat result;
pca.project(testImageInGrayScale, result); // bugs here ...

// PRINT THE DISTANCES
for (int i = 0; stored_projections.rows; ++i){
    qDebug() << norm( stored_projections.row(i),weightVect );
}

错误代码是:

  

OpenCV错误:断言失败(mean.data&amp;&amp; eigenvectors.data&amp;&amp;   ((mean.rows == 1&amp;&amp; mean.cols == data.cols)||(mean.cols == 1&amp;&amp;   mean.rows == data.rows)))在项目,文件中   c:/opencv/sources/modules/core/src/matmul.cpp,第3042行

我完全错了吗?或者我只是使用了错误的方法和错误的类型?

1 个答案:

答案 0 :(得分:0)

浏览This链接。它会帮助您