Reputation: 41
I'll try to make this question as specific as possible.
When calling stereoCalibrate() in opencv 3.0, I get an error message like this:
Assertion failed <nimages > 0 && nimages == <int>imagePoints1.total() && <!imgPtMat2 || nimages == <int>imagePoints2.total(()) in cv::collectCalibrationData
I have went through the parameters multiple times, and my CameraDistortion, cameraMatrix, and imagePoints are all reading in values from an earlier cameraCalibrate, and are consistent in dimension with the two cameras.
I have the flags CV_CALIB_ZERO_TANGENT_DIST and CV_CALIB_FIX_FOCAL_LENGTH, and have been experimenting with different combinations.
I've played with imageSize as well and have it resting on the size of the image i'd like to compute a disparity map with after the stereo calibrate.
My best guess is that I'm passing in a bogus objectPoints matrix into this parameter, as I can't seem to save the vector of vectors computed in cameraCalibrate to an xml file in a readable way.
Here's a link to stereoCalibrate() doc: http://docs.opencv.org/3.0.0/d9/d0c/group__calib3d.html#ga246253dcc6de2e0376c599e7d692303a
Here's my method call:
stereoCalibrate(test, Image_Points, Image_Points2, Camera_Matrix, Distortion_Coefficients, Camera_Matrix2, Distortion_Coefficients2, imgLeft.size(), R, T, E, F, CV_CALIB_FIX_FOCAL_LENGTH && CV_CALIB_ZERO_TANGENT_DIST, TermCriteria9(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 30, 1e-6))
Thanks for any help, Rowan
Upvotes: 1
Views: 445
Reputation: 41
The assertion failed error nimages =..... was simply an issue with the sizes of the matrices or vectors (the method accepts either) that were used as parameters for imagePoints, imagePoints2, and objectPoints. This seems obvious enough, but I had a frustrating time trying to save these parameters to an xml file and read them in properly.
I clumsily circumnavigated this problem, by combining my stereoCalibrate, stereoRectify, and disparity map code with my calibration and saved these vectors as global variables. This is not the best way to handle this problem as my code is burdensome and hefty, yet I figured some answer is better than no answer.
Thanks, Rowan
Upvotes: 0