【OpenCV Error】 Assertion failed (a_size.width == len) in gemm,

在做opencv實驗的時候,遇到這個問題。

實驗代碼問題定位到:

Mat tDiag = Mat::diag(t);
cout << tDiag.rows << " <-rows,tDiag,cols->" << tDiag.cols << endl;
cout << "BreakPoint 21" << endl;
cout << U.rows << " <-rows,U,cols->" << U.cols << endl;
Mat Vt = V.t();
cout << Vt.rows << " <-rows,Vt,cols->" << Vt.cols << endl;
Mat X = U * tDiag * Vt;

實驗報錯如下:

原因是在進行矩陣相乘的時候,矩陣的維度不符合標準。

上述代碼中U.cols應該和Vt.rows相等才能進行矩陣乘法。

 

參考:https://stackoverflow.com/questions/25377628/assertion-failed-a-size-width-len-in-cvgemm

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章