OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 03 Sep 2014 01:59:58 -0500cv::undistort and values of distortion coefficenthttp://answers.opencv.org/question/19886/cvundistort-and-values-of-distortion-coefficent/Hi!
I'm porting to opencv a little script for lens distortion correction.
This program is doing the undistortion with the Brown normalization, and it uses some parameters that gets out of a (close source) software for camera calibration that has values in the so called photogrammetric representation.
The main difference I have noticed till now is that it express values of focal length and principal points in mm while opencv undistort function takes values in pixel. Ok, I have pixel dimension and I can do this conversion.
But.. Even after this conversion the cv::undistort function still gets me an image that is not correctly undistorted.
I think that there should be some scaling factor that I'm not considering. So I'm asking: what are the values of distortion coefficent units? Are they in radians? Or there is some other conversion that I have to do? Some advice?
EDIT: I report the name of the log and how I'm using it (referring to opencv [cv::undistort documentation](http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#undistort)):
Camera interior orientation: focal length (mm), principal point (mm).
Radial distortion parameters: k1, k2, k3
Decentring distortion parameters: p1, p2
Affinity, non-orthogonality parameters: b1, b2
I'm using focal length parameter (scaled in pixel) for fx anf fy, principal point (scaled in pixel as well) as cx, cy.
k1, k2, k3, p1, p2 as they are
b1, b2: not using those parameters.nkintFri, 30 Aug 2013 10:09:47 -0500http://answers.opencv.org/question/19886/PointsClouds Generated by Reporjectimageto3D is So Badhttp://answers.opencv.org/question/40945/pointsclouds-generated-by-reporjectimageto3d-is-so-bad/![image description](/upfiles/14097275063912099.jpg)
Disparity image seems well but Points Clouds is too bad, anyone catch the problem?
![image description](/upfiles/14097276257433197.jpg)
You can find that coordinate x,y are ok, while z is far from reality.jestshenWed, 03 Sep 2014 01:59:58 -0500http://answers.opencv.org/question/40945/Stereo calibration: problem with projection matrices and SGBMhttp://answers.opencv.org/question/27508/stereo-calibration-problem-with-projection-matrices-and-sgbm/I am trying to create a depth map from a disparity using SGBM. The resulting disparity map has almost no definition. So I set up sliders for the various SGBM values and can get very limited results - they are basically blank.
After calibrating the cameras individually followed by the stereo calibration I can rectify images which comes out rather well:
![rectified image](/upfiles/13911306844204794.jpg)
Something I've noticed is the projection matrices and the Q matrix have several NAN values. Also the ROI for each camera is all zeros which can['t be right. Below are the saved calibration setting that I am using showing the NAN values.
Since the RMS values for each single camera calibration are under 0.4 and the stereo RMS is less than 2.0 with a re-projection error of less then 4.0 I'm not sure what may be wrong at this point. Suggestions and help would be greatly appreciated.
Camera_0_Matrix<br>
8.2360702625110662e+002 0. 3.1410424020211406e+002<br>
0. 8.1860608380736392e+002 2.4384904263053622e+002<br>
0. 0. 1.<br>
Camera_1_Matrix<br>
8.1134698384868875e+002 0. 3.1328331721626449e+002<br>
0. 8.0724997468627953e+002 2.3930244099756220e+002<br>
0. 0. 1.<br>
Camera_0_Distortion_Coefficients<br>
2.6712887348238189e-002 -1.8664642728347297e-001<br>
-4.8596016262543446e-004 -1.4728080493686517e-003<br>
5.2687479496305778e-001 0. 0. 0.<br>
Camera_1_Distortion_Coefficients<br>
3.9590803660099684e-002 -1.8981006469293660e-001<br>
-6.4688587632222173e-003 -3.7797348771147284e-003<br>
2.7996253215102412e-001 0. 0. 0.<br>
Mat_R<br>
9.9922618707330479e-001 -1.4827571495127988e-002 -3.6430347109269276e-002<br>
1.4533977386417006e-002 9.9985983789215160e-001 -8.3107202823446188e-003<br>
3.6548468754191266e-002 7.7748114984945516e-003 9.9930163701351293e-001<br>
Mat_T<br>
-7.1373089613768613e+001 -6.5822496464438818e-001 -6.3515467302110000e+000<br>
Mat_E<br>
6.8256121992123484e-002 6.3455389090094831e+000 -7.1055121292732304e-001 <br>
-3.7380546856077390e+000 6.4909033105906033e-001 7.1554634341813454e+001<br>
-3.7961924878715458e-001 -7.1372845688807843e+001 5.6918241952876536e-001<br>
Mat_F<br>
7.2342254670288030e-008 6.7664989166222400e-006 -2.2929759854297700e-003 <br>
-3.9819395869095442e-006 6.9566352175857590e-007 6.3859013286650543e-002<br>
6.0378280400693674e-004 -6.4036046720140641e-002 1.<br>
Camera_0_Rotation_Matrix<br>
9.9862396895832117e-001 -4.8951125057362125e-003 5.2213087396614198e-002 <br>
5.1174999253298069e-003 9.9997839183290060e-001 -4.1263860459532032e-003<br>
-5.2191760043559916e-002 4.3879084815174659e-003 9.9862744126261294e-001<br>
Camera_1_Rotation_Matrix<br>
9.9602166255538394e-001 9.1856234214931377e-003 8.8636742058627288e-002 <br>
-9.5633854847882640e-003 9.9994690362209304e-001 3.8381759545177280e-003<br>
-8.8596779729730887e-002 -4.6705737278212095e-003 9.9605662307048315e-001<br>
Camera_0_Projection_Matrix<br>
.Nan 0. .Nan 0.<br>
0. .Nan .Nan 0.<br>
0. 0. 1. 0.<br>
Camera_1_Projection_Matrix<br>
.Nan 0. .Nan .Nan <br>
0. .Nan .Nan 0. <br>
0. 0. 1. 0.<br>
Mat_Q<br>
1. 0. 0. .Nan <br>
0. 1. 0. .Nan <br>
0. 0. 0. .Nan <br>
0. 0. 1.3955142868906164e-002 .Nan<br>
ROI_0<br>
0 0 0 0<br>
ROI_1<br>
0 0 0 0<br>
jim_73_mk1Thu, 30 Jan 2014 19:52:39 -0600http://answers.opencv.org/question/27508/Are distortion coefficients returned by cv::stereoCalibrate correct?http://answers.opencv.org/question/19716/are-distortion-coefficients-returned-by-cvstereocalibrate-correct/// This bug is fixed by Pritam Shete([http://code.opencv.org/projects/opencv/repository/revisions/a430abd02eaf38e0d42f075acbb47210c2b191c8](http://code.opencv.org/projects/opencv/repository/revisions/a430abd02eaf38e0d42f075acbb47210c2b191c8))
Hi,
I tried to use cv::stereoCalibrate to calibrate the cameras. However the distortion coefficients returned by cv::stereoCalibrate seemed to be wrong. I didn't set up the flag "CALIB_THIN_PRISM_MODEL"(I passed CV_CALIB_RATIONAL_MODEL as the flag), but I still got the nonzero s1, s2, s3, and s4 in returned array.
Is this correct result?
In [calibration.cpp - line#2038](https://github.com/Itseez/opencv/blob/b0933dd47381ca46612da42b66e337f7935c2c38/modules/calib3d/src/calibration.cpp#L2038), I thought distCoeffs->cols == 12, and Dist[k] had only 8 component. Why there is no code setting the last 4 components in distortion coefficients to zero?
The distortion coefficients I got are
distCoeffs1:[k_1_A, k_2_A, p_1_A, p_2_A, k_3_A, k_4_A, k_5_A, k_6_A, ***k_1_B, k_2_B, p_1_B, p_2_B***]
distCoeffs2:[k_1_B, k_2_B, p_1_B, p_2_B, k_3_B, k_4_B, k_5_B, k_6_B, ***?, ?, ?, ?***]
dumbDumbWed, 28 Aug 2013 10:48:27 -0500http://answers.opencv.org/question/19716/