I'm trying to generate an InputArrayOfArrays to pass into OpenCV calibrate. I believe it should be a vector of vectors. However, when I call the calibrate function it bombs out with an exception that my input and output arrays aren't the same size. I've tried to perform the conversion outside of the calibrate call and the resulting InputArrayOfArrays (op and ip) appear to not be initialised (the reported total() size is random). If I interrogate the vectors directly, they are as expected. Any help is much appreciated!
{
....
//pixel position is imagePoints
std::vector<std::vector<cv::Point> > imagePoints(1); //={ Point(144,103), Point(206,75), Point(109,151), Point(253,159) };
imagePoints[0].push_back(Point(144,103));
imagePoints[0].push_back(Point(206,75));
imagePoints[0].push_back(Point(109,151));
imagePoints[0].push_back(Point(253,159));
//real world position is object Points
std::vector<std::vector<cv::Point3d> > objectPoints(1); //={ Point3d(4,3,0), Point3d(7,2,0), Point3d(2,5,0), Point3d(8,6,0)};
objectPoints[0].push_back(Point3d(4,3,0));
objectPoints[0].push_back(Point3d(7,2,0));
objectPoints[0].push_back(Point3d(2,5,0));
objectPoints[0].push_back(Point3d(8,6,0));
InputArrayOfArrays ip = InputArrayOfArrays(imagePoints);
InputArrayOfArrays op = InputArrayOfArrays(objectPoints);
printf("ip (%d, %I64u) op (%d, %I64u)\n", ip.empty(), ip.total(), op.empty(), op.total());
fisheye::calibrate(objectPoints, imagePoints, distorted.size(), Ka, Da, rvec, tvec, flag, cv::TermCriteria(3, 20, 1e-6));
}
Ouptut is:
ip (0, 18446744073709499195) op (0, 18446744073709499176)
OpenCV Error: Assertion failed (!objectPoints.empty() && !imagePoints.empty() && objectPoints.total() == imagePoints.total()) in cv::fisheye::calibrate, file C:\Temp\OpenCV_3.2_extra\source\opencv\modules\calib3d\src\fisheye.cpp, line 701