I am trying to fit a plane via SVD and was hoping someone could point out the errors in my code. The plane I generate does not seem right at all. I am very sure the points I have filled in are correct.
vector Crds;
// Fill up Crds
Mat matOnes = Mat::ones(Size(1, Crds.size()), CV_32F);
Mat homoCrds, matCrds = Mat(Size(3, Crds.size()), CV_32F, Crds.data());
hconcat(matCrds, matOnes, homoCrds); // homogenous coordinates
Mat w, u, vt;
SVD::compute(homoCrds, w, u, vt);
Mat temp = u.row(Crds.size() - 1); // normal vector of plane = eigenvector with the lowest eigenval
supPixel[id].plane = temp(Rect(0, 0, 3, 1)).clone();
↧