2015-10-30 02:13:33 -0600 received badge ● Enthusiast 2015-10-26 04:59:49 -0600 commented question Confusion about number of distortion parameters @berak This makes sense, especially since the flag CV_CALIB_RATIONAL_MODEL decides if 5 or 8 parameters are used, so the overall mechanism simply does not cover a 4 parameter scenario. However, talking about the distortion coefficients with "4, 5, or 8 elements" is still a bit misleading. The only time I know of 4 distortion parameters being returned is with the fisheye calibration, but it has a separate documentation where the 4 distortion parameters are described. 2015-10-25 23:01:16 -0600 asked a question Confusion about number of distortion parameters Hello, I have a problem with the camera calibration function. I haven't found an existing thread for this particular problem, though I could have overlooked one. Main problem: The function calibrateCamera returns only 5 or 8 distortion parameters, but from the documentation, it should also support 4. Explanantion: The documentation (http://docs.opencv.org/modules/calib3...) for the function "calibrateCamera" states: distCoeffs – Output vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements From this I gathered, that I can decide if OpenCV calibrates the camera distortion with 4, 5 or 8 parameters, depending on the size of the cv::Mat object I pass to the function (one with a size of 4, 5, or 8 elements). However, when passing a cv::Mat object with only 4 elements, the functions reallocates the object to a size of 5. Also, the 5th parameter is not zero. So OpenCV actually fits the distortion with 5 parameters, even though only 4 are expected from the caller. This can lead to some nasty bugs (as it did for me), especially when the first 4 distortion coefficients (of the cv::Mat object with 5 elements) differ strongly from the distortion coefficients if the camera had been calibrated using only 4 coefficients. I used OpenCV 2.4.7 Example: _distortionCoefficients = cv::Mat::zeros(4, 1, CV_64F); _reprojectionError = cv::calibrateCamera(objectPoints, imagePoints, imageSize, _cameraMatrix, _distortionCoefficients, _rvecs, _tvecs, flags, terminationCriteria); // From here on, _distortionCoefficients is of size (5,1).  Am I using the function incorrectly or is this a bug? Regards, Baiz