在做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