I am using VisualStudio 2010 with OpenCV 3.0. I want to calibrate a camera and I am having basically the same issue described in this post from last year, but it was not be responded. I am calling calibrateCamera and I am getting the error "Assertion failed (ni == ni1) in cv::collectCalibrationData".
The line of code that is getting this error is:
double rms = calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, s.flag | CALIB_FIX_K4 | CALIB_FIX_K5);
I have checked the size of both objectPoints and imagePoints, and they are the same. It seems to be an error in the conversion of vector to InputArrayOfArrays. I have written the next code to find it out:
cv::InputArrayOfArrays IMGPOINT = imagePoints; std::cout << (int) IMGPOINT.total() << std::endl;
cv::InputArrayOfArrays OBJPOINT = objectPoints; std::cout << (int) OBJPOINT.total() << std::endl;
for( int i = 0; i < 3; ++i ){
std::cout << OBJPOINT.getMat(i).checkVector(3, CV_32F) << std::endl;
std::cout << IMGPOINT.getMat(i).checkVector(2, CV_32F) << std::endl;
}
And it printed out:
5
5
48
48
174912
16
788167652
111826623
When I tend to think that it should print the next:
5
5
48
48
48
48
48
48
As I have described, it appears a random integer every time I run the program - they are not consistent and are never equal to each other. I am not sure why collectCalibrationData is getting the wrong values for the size of my vectors, and why converting the vectors to an InputArrayofArrays seems to change their size. Any thoughts on this?
Thanks in advance.