2014-04-16 30 views
0

我有一些與特徵臉識別步驟的理解問題,我讀過的地方,我們必須將測試圖像投影到本徵空間,然後計算投影圖像測試和存儲的投影矢量。人臉識別步驟:項目測試圖像

// 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 Error: Assertion failed (mean.data && eigenvectors.data && ((mean.rows == 1 && mean.cols == data.cols) || (mean.cols == 1 && mean.rows == data.rows))) in project, file c:/opencv/sources/modules/core/src/matmul.cpp, line 3042

我是完全以錯了嗎?或者我剛剛使用了錯誤的方法和錯誤的類型?

+0

這不是一個關於你所使用的類型的問題,但是這樣你的數據進行格式化。看看錯誤信息:你是否有數據進入mean變量,是否意味着等於1的行,依此類推。在這裏和那裏幾個斷點,你會知道發生了什麼。這裏的例子可能會幫助https://github.com/Itseez/opencv/blob/master/samples/cpp/pca.cpp – CTZStef

回答

0

經過This link.It將幫助您

+2

更好地作爲評論... – yizzlez

+0

@awesomeyi將在下一次關心它 –