Result different between opencv 3.3 and opencv 4.1

I have two systems:

  1. Ubuntu with Opencv 3.3
  2. Windows with Opencv 4.1

I found the output of estimateNewCameraMatrixForUndistortRectify from the same input are different between the two systems. Why?

both 3.3 and 4.1 are years old and outdated

if you think, you have found a regression,
please at least update that system to current 4.5.x and check again
(then it may be time to raise an issue here )

also, can you show some example input/output ?

@berak Thank you for your reply.

Here is the code:

fisheye::estimateNewCameraMatrixForUndistortRectify(_Kmat, _Dmat, oldSize, Matx33d::eye(), _newKmat, balance, newSize);

Here is the output:

Ubuntu opencv 3.3:

_newKmat = (232.72, 0, 233.076, 0, 233.979, 246.974, 0.0, 0.0, 1.0);

Windows: Opencv 4.1:

_newKmat = (136.75358477913400, 0.0, 468.25649224937445, 0.0, 137.49362656177013, 250.19162967081587, 0.0, 0.0, 1.0);

i you give us the complete input data, we could try to repeat it

_Kmat = (238.2775569220771, 0.0, 333.4472958102587, 0.0, 239.56699550075558, 243.93441548309076, 0.0, 0.0, 1.0)
D = (-0.017895948523542635, -0.11236456139509969, 0.1512045667679157, -0.06372236316052718 )

oldSize = newSize, row = 480, col = 640

balance = 0.0

1 Like

Hi @berak, did you get a chance to look into this?

sorry for late, using:

cv::Mat_<double>  _Kmat(3,3);
_Kmat << 238.2775569220771, 0.0, 333.4472958102587,
         0.0, 239.56699550075558, 243.93441548309076,
         0.0, 0.0, 1.0;
cv::Mat_<double> D(1,4);
D << -0.017895948523542635, -0.11236456139509969, 0.1512045667679157, -0.06372236316052718;

cv::Size oldSize(640,480);
cv::Size newSize(oldSize);
double balance = 0.01;
cv::Mat _newKmat;

cv::fisheye::estimateNewCameraMatrixForUndistortRectify(_Kmat, D, oldSize, cv::Matx33d::eye(), _newKmat, balance, newSize);
cout << CV_VERSION << endl;
cout << newSize << endl;
cout << _newKmat << endl;

i get:

4.1.0-dev
[640 x 480]
[135.8781091743231, 0, 467.3073767842933;
 0, 136.6134133222692, 250.1263844111433;
 0, 0, 1]

and (!!!)

4.5.3-dev
[640 x 480]
[0.000641802933620525, 0, 639.1742875591813;
 0, 0.0006452760490629078, 562.6380509428207;
 0, 0, 1]

(yea, looks way off to me !)
(but, unfortunately NO idea about fisheye calibration here ;( )

edit:

test here is passing fine

@autocar , can you check ?
also, how / where did you get your calibration data ?

you could lobby for some regression tests on that module (open an issue on the github). those, if they existed, should have caught that, assuming it’s a specific bug someone introduced, instead of numerical issues. the parameters look obvious enough that I think the usage here is probably correct.