Ask Your Question
2

SVD Compute returns matrix with 0 dimension

asked 2013-12-22 07:10:03 -0600

MRDaniel gravatar image

updated 2013-12-22 07:35:46 -0600

Hello. Here is an odd problem, and i would be grateful for any advice for this simple use case of svd.

Code...

cv::Mat x1Tx2 = cv::Mat::zeros(2,2, CV_64FC1 );

cv::Mat UT = cv::Mat::zeros(2,2, CV_64FC1 );

cv::Mat V = cv::Mat::zeros(2,2, CV_64FC1 );

cv::Mat tempW = cv::Mat::zeros(2,2, CV_64FC1 );

cv::Mat VUT = cv::Mat::zeros(2,2, CV_64FC1 );

//Some code ... !!! EVEN IF THIS IS REMOVED ISSUE STILL OCCURS !!!

cout << tempW.size() << " " << V.size() << "" << UT.size() << " " << VUT.size() << endl;

cv::SVD::compute(x1Tx2, tempW, UT, V,CV_SVD_U_T);

cout << tempW.size() << " " << V.size() << "" << UT.size() << " " << VUT.size() << endl;

Output

[2 x 2] [2 x 2][2 x 2] [2 x 2]

[1 x 2] [2 x 0][2 x 0] [2 x 2]

Clearly the SVD function has changed the size of the cv::Mat which results in unusable matrices with 0 size dimensions. Any clues?

If cv::Mat not initialised, then svd produces.... [1 x 2] [0 x 0][0 x 0] [0 x 0]

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2014-01-02 08:02:55 -0600

Nghia gravatar image

I think you're passing an invalid flag, CV_SVD_U_T. The documentation for SVD::compute says

  • flags – operation flags - see SVD::SVD().

There are 3 options

  • SVD::MODIFY_A
  • SVD::NO_UV
  • SVD::FULL_UV

Maybe you want SVD::FULL_UV ?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-12-22 07:10:03 -0600

Seen: 1,135 times

Last updated: Jan 02 '14