CameraCalibration example computes NAN

asked 2018-11-15 12:21:54 -0600

hayley gravatar image

updated 2018-11-20 16:00:23 -0600

I am using OpenCV 3.2.0's example project for achieving CameraCalibration. I have a chessboard checker printed which I use to check for a 4 x 6 pattern of checkers.

For the sample image, I use the following: C:\fakepath\pattern.png

The sample project is provided with the OpenCV Android SDK libraries directly from the OpenCV page: https://opencv.org/releases.html or simply download the version (3.2.0) that I am using: https://sourceforge.net/projects/open...

To locate the sample project, select: opencv-3.2.0-android-sdk.zip > OpenCV-android-sdk > samples > camera-calibration import the project camera-calibration. I have also attached the checkerboard sample images that I used with the project.

When I run the project, it computes NAN for (fx and fy) of the CameraMatrix as well as (k1 and k2) of the DistortionCoefficients.

edit retag flag offensive close merge delete

Comments

OpenCV 3.0's example

first: please update to a more recent 3.4 or such. problems with 4 year old 3.0 no more matter to anyone.

berak gravatar imageberak ( 2018-11-16 00:45:42 -0600 )edit

still the same problem. if you want ppl to reproduce it, you need a RECENT codebase

berak gravatar imageberak ( 2018-11-16 03:30:26 -0600 )edit

I have tested with OpenCV 3.2.0 Library and the problem still persists.

In the meantime I also downloaded OpenCV 3.4.3 Library (released earlier this year) and will try also that CameraCalibration example code.

Please let me know if you have any idea why some variables of the CameraMatrix and DistortionCoefficients could be producing NAN.

hayley gravatar imagehayley ( 2018-11-16 03:52:51 -0600 )edit

Please include sample image(s) and the code in your question. Thanks!

opalmirror gravatar imageopalmirror ( 2018-11-16 11:14:13 -0600 )edit

@opalmirror thank you for the suggestion. I have uploaded the project and the library that generate the issue. @berak I hear you. Working on debugging and upgrading my hardware to be able to test the sample project with the 3.4.0 library.

hayley gravatar imagehayley ( 2018-11-19 12:37:34 -0600 )edit

@hayley, no. 3.4.0 is still an outdated release (you seem to confuse it with the current 3.4 github) branch

btw, where is the upload ? (link ?)

berak gravatar imageberak ( 2018-11-19 15:07:48 -0600 )edit
1

@berak, OpenCV site says that 3.4.3 was updated on 2018-08-29: https://opencv.org/releases.html The later versions (4.xx) are beta versions that I rather steer clear off for the moment. By the way, I just updated the note with my links. The attachment option did not like zipped files.

hayley gravatar imagehayley ( 2018-11-20 04:12:00 -0600 )edit

yea, good enough ;)

berak gravatar imageberak ( 2018-11-20 04:12:46 -0600 )edit

The CameraCalibrationActivity.java source file has a header comment:

// It uses standard OpenCV asymmetric circles grid pattern 11x4:
// https://github.com/opencv/opencv/blob/2.4/doc/acircles_pattern.png.
// The results are the camera matrix and 5 distortion coefficients.

This makes me wonder if you should try with an 11x4 asymmetric circles grid pattern?

Probably best to read the entire header comment on that source file (too large to copy here)

opalmirror gravatar imageopalmirror ( 2018-11-20 15:57:46 -0600 )edit

Thanks @opalmirror, that is a good point. In CameraCalibrator.java (line 126), I have tried both options: Calib3d.findCirclesGrid() and showed the circle grid pattern, but also tried Calib3d.findChessboardCorners() and showed the checkerboard grid pattern. In both cases, I can see that I end up with the same NAN result. In CameraCalibrator.java (line 66), I can see that mCameraMatrix and mDistortionCoefficients are not updated. Any ideas why the OpenCV calibrateCamera() does not update these output arrays?

hayley gravatar imagehayley ( 2018-11-22 03:30:26 -0600 )edit