The cvInvert() method takes a flag CV_LU that does the LU factorisation to invert an input matrix. However is there any way to obtain the L and U matrices that are formed du
It is possible to use the function Cholesky() provided by OpenCV (using 2.4.6), see source code of modules\stitching\src\autocalib.cpp. But it needs some scaling to get a comparable result with Matlab:
Mat chol = mat.clone();
if (Cholesky(chol.ptr(), chol.step, chol.cols, 0, 0, 0))
{
Mat diagElem = chol.diag();
for (int e = 0; e < diagElem.rows; ++e)
{
float elem = diagElem.at(e);
chol.row(e) *= elem;
chol.at(e,e) = 1.0f / elem;
}
}