OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 31 Jul 2013 03:42:24 -0500NEWBIE calibrateCamera and calibrationMatrixValueshttp://answers.opencv.org/question/17590/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 muchFri, 26 Jul 2013 10:10:25 -0500http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/Answer by Alexander Smorkalov for <p>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.</p>
<p>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).</p>
<p>calibrateCamera((geoPoints,imgPoints),width=pWidth, height=pHeight, useIntrinsicGuess=True, fixAspectRatio=True, zeroTangentDist=True, fixPrincipalPoint=False)</p>
<p>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. </p>
<p>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.</p>
<p>and finally- apertureWidth and apertureHeight. these i am stuck on. any guess as to how i would extract or calculate these values from calibrateCamera?</p>
<hr>
<p>in stepping through the source code for the calibrationMatrixValues function i find:</p>
<p>fovx = 2 * atan(imgWidth / (2 * alphax)) * 180.0 / CV_PI;
fovy = 2 * atan(imgHeight / (2 * alphay)) * 180.0 / CV_PI;</p>
<p>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. </p>
<p>thanks very much</p>
http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?answer=17883#post-id-17883All docs on opencv.willowgarage.com are out of date and are not maintained by OpenCV dev team. I recommend you to use [official docs](http://docs.opencv.org/doc/tutorials/calib3d/table_of_content_calib3d/table_of_content_calib3d.html#table-of-content-calib3d).Wed, 31 Jul 2013 03:42:24 -0500http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?answer=17883#post-id-17883Answer by tenta4 for <p>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.</p>
<p>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).</p>
<p>calibrateCamera((geoPoints,imgPoints),width=pWidth, height=pHeight, useIntrinsicGuess=True, fixAspectRatio=True, zeroTangentDist=True, fixPrincipalPoint=False)</p>
<p>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. </p>
<p>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.</p>
<p>and finally- apertureWidth and apertureHeight. these i am stuck on. any guess as to how i would extract or calculate these values from calibrateCamera?</p>
<hr>
<p>in stepping through the source code for the calibrationMatrixValues function i find:</p>
<p>fovx = 2 * atan(imgWidth / (2 * alphax)) * 180.0 / CV_PI;
fovy = 2 * atan(imgHeight / (2 * alphay)) * 180.0 / CV_PI;</p>
<p>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. </p>
<p>thanks very much</p>
http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?answer=17703#post-id-17703What 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](http://docs.opencv.org/2.4/_images/math/7a7fe5e6ab0851a37c3e54b6da2f61b21c0ec0c6.png)
Mon, 29 Jul 2013 09:31:12 -0500http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?answer=17703#post-id-17703Answer by gardyll for <p>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.</p>
<p>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).</p>
<p>calibrateCamera((geoPoints,imgPoints),width=pWidth, height=pHeight, useIntrinsicGuess=True, fixAspectRatio=True, zeroTangentDist=True, fixPrincipalPoint=False)</p>
<p>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. </p>
<p>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.</p>
<p>and finally- apertureWidth and apertureHeight. these i am stuck on. any guess as to how i would extract or calculate these values from calibrateCamera?</p>
<hr>
<p>in stepping through the source code for the calibrationMatrixValues function i find:</p>
<p>fovx = 2 * atan(imgWidth / (2 * alphax)) * 180.0 / CV_PI;
fovy = 2 * atan(imgHeight / (2 * alphay)) * 180.0 / CV_PI;</p>
<p>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. </p>
<p>thanks very much</p>
http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?answer=17796#post-id-17796thanks very much!Tue, 30 Jul 2013 06:26:55 -0500http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?answer=17796#post-id-17796Comment by StevenPuttemans for <p>thanks very much!</p>
http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?comment=17815#post-id-17815Since you new, just a warning, please read the [FAQ](http://answers.opencv.org/faq)! Responses are placed in comments or by editing your original question. Please do not generated tons of answers when it isn't needed.Tue, 30 Jul 2013 08:00:53 -0500http://answers.opencv.org/question/17590/newbie-calibratecamera-and-calibrationmatrixvalues/?comment=17815#post-id-17815