# NEWBIE calibrateCamera and calibrationMatrixValues

hi- i am a total newb to opencv- and to python as well. i'm trying to get a better understanding of the workings of the calibrateCamera and calibrationMatrixValues functions. i'm stepping through someone else's (working) python code. thanks in advance for your patience.

i am ultimately trying to use calibrationMatrixValues to extract the fovx and fovy from a previously (successfully) solved camera calibration using calibrateCamera. these are the settings used (where geoPoints, imgPoints, pWidth, and pHeight have been determined).

calibrateCamera((geoPoints,imgPoints),width=pWidth, height=pHeight, useIntrinsicGuess=True, fixAspectRatio=True, zeroTangentDist=True, fixPrincipalPoint=False)

calibrateCamera - the output camera matrix i get is indeed a 3x3 matrix, but it is a rotation matrix that is being used to calculate my camera's extrinsics. i think i am looking for output that is a projection matrix- so i can feed that into calibrationMatrixValues.

calibrationMatrixValues - where can i find the camera matrix to input? imageSize, is this an array of two values [x,y]? i know the image size, i'm not sure how to format it properly.

and finally- apertureWidth and apertureHeight. these i am stuck on. any guess as to how i would extract or calculate these values from calibrateCamera?

in stepping through the source code for the calibrationMatrixValues function i find:

fovx = 2 * atan(imgWidth / (2 * alphax)) * 180.0 / CV_PI; fovy = 2 * atan(imgHeight / (2 * alphay)) * 180.0 / CV_PI;

alphax and alphay are pulled directly from the input camera matrix. so, a big problem for me is the matrix i feed it looks like a rotation matrix, and this produces very unusable results.

thanks very much

edit retag close merge delete

Sort by » oldest newest most voted

All docs on opencv.willowgarage.com are out of date and are not maintained by OpenCV dev team. I recommend you to use official docs.

more

The output param cameraMatrix - intrinsic camera parameters, non rotation matrix.

This matrix is input in calibrationMatrixValues function.

In c++ it's look like this

int w = 640, h = 480; // for example
cv::calibrateCamera(objectPoints, imagePoints, cv::Size(w, h), cameraMatrix, distCoeffs, rvecs, tvecs);
cv::calibrationMatrixValues(cameraMatrix, cv::Size(w, h), apertureWidth, apertureHeight, fieldOfViewX, fieldOfViewY, focalLength, principalPoint, aspectRatio);

But not all devices give you the apertureHeight information, thats why you can compute angles, using this formula

fx = cameraMatrix.at<double>(0);
fy = cameraMatrix.at<double>(4);
fovx = 2 * atan(imgWidth / (2 * fx)) * 180.0 / CV_PI;
fovy = 2 * atan(imgHeight / (2 * fy)) * 180.0 / CV_PI;

Fx and Fy = its elements of cameraMatrix more
more

Official site

GitHub

Wiki

Documentation