Ask Your Question
1

opencv matrix of matrix

asked 2015-02-11 12:02:03 -0600

Fabien R gravatar image

I'm trying to calibrate a fisheye camera using opencv3. But it crashes in cv::fisheye::calibrate() in fisheye.cpp on this line:

  rvecs.getMat(i)=omc[i];

It seems that rvecs is empty, so getMat() fails. I would like to resize rvecs to contain the number of elements of omc. I tried

 if (rvecs.empty())
{
    std::vector<cv::Mat>* v = (std::vector<cv::Mat>*)&rvecs;
    v->resize(omc.size());
}

But it crashes because OpenCV dereferences things when closing the bracket.

Any hints ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-02-22 09:07:46 -0600

Fabien R gravatar image

A possible solution is to initialise the variables before calling cv::fisheye::calibrate():

rvecs.resize(imagePoints.size(), cv::Mat(1, 1, CV_64FC3));
tvecs.resize(imagePoints.size(), cv::Mat(1, 1, CV_64FC3));

A sample of the undistortion after calibration:

original

undistorted

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-11 12:02:03 -0600

Seen: 330 times

Last updated: Feb 22 '15