Ask Your Question
0

NEWBIE calibrateCamera and calibrationMatrixValues

asked 2013-07-26 10:10:25 -0600

gardyll gravatar image

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 flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2013-07-31 03:42:24 -0600

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.

edit flag offensive delete link more
1

answered 2013-07-29 09:31:12 -0600

tenta4 gravatar image

What about documentation? http://opencv.willowgarage.com/documentation/cpp/camera_calibration_and_3d_reconstruction.html

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 image description

edit flag offensive delete link more
0

answered 2013-07-30 06:26:55 -0600

gardyll gravatar image

thanks very much!

edit flag offensive delete link more

Comments

Since you new, just a warning, please read the FAQ! Responses are placed in comments or by editing your original question. Please do not generated tons of answers when it isn't needed.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-30 08:00:53 -0600 )edit

Question Tools

Stats

Asked: 2013-07-26 10:10:25 -0600

Seen: 4,764 times

Last updated: Jul 31 '13