Ask Your Question

OpenCV Camera Calibration Parsing Error. How to solve it?

asked 2017-06-06 22:36:20 -0500

astronaut gravatar image

updated 2017-06-06 23:38:55 -0500

Im using the camera calibration source code from OpenCV in this link (

In the configuration file may choose to use camera as an input, a video file or an image list.So I choose camera. So I tried to create a configuration file. Here’s my xml configuration file

<?xml version="1.0"?>
<!-- Number of inner corners per a item row and column. (square, circle) -->
<!-- The size of a square in some user defined metric system (pixel, millimeter)-->
<!-- The type of input used for camera calibration. One of: CHESSBOARD CIRCLES_GRID ASYMMETRIC_CIRCLES_GRID -->
<!-- The input to use for calibration. To use an input camera -> give the ID of the camera, like "1" To use an input video -> give the path of the input video, like "/tmp/x.avi" To use an image list -> give the path to the XML or YAML file containing the list of the images, like "/tmp/circles_list.xml" -->
<!-- If true (non-zero) we flip the input images around the horizontal axis.-->
<!-- Time delay between frames in case of camera. -->
<!-- How many frames to use, for calibration. -->
<!-- Consider only fy as a free parameter, the ratio fx/fy stays the same as in the input cameraMatrix. Use or not setting. 0 - False Non-Zero - True-->
<Calibrate_FixAspectRatio> 1 </Calibrate_FixAspectRatio>
<!-- If true (non-zero) tangential distortion coefficients are set to zeros and stay zero.-->
<!-- If true (non-zero) the principal point is not changed during the global optimization.-->
<Calibrate_FixPrincipalPointAtTheCenter> 1 </Calibrate_FixPrincipalPointAtTheCenter>
<!-- The name of the output log file. -->
<!-- If true (non-zero) we write to the output file the feature points.-->
<!-- If true (non-zero) we write to the output file the extrinsic camera parameters.-->
<!-- If true (non-zero) we show after calibration the undistorted images.-->

The camera Id is 3. When run the code I got this error: OpenCV Error: Parsing error <C:/Calibration/CameraCalibration/config1.xml<16>: Preliminary end of the stream> in icvXMLParseTag

I dont understand what is the problem . Is it the chesssboard size? How should I chose the BoardSize_Width and BoardSize_Height? Any help? Or is there any bug in the code. In the cameraCalibration code im using this to read the settings:

Settings s;
const string inputSettingsFile = argc > 1 ? argv[1] :"C:/Calibration/Clibration/CameraCalibration1/config1.xml";
FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings

I try to solve this problem for two days and still stuck as Im new in Camera Calibration and never done it before. Would really appreciate the help . Thanks

edit retag flag offensive close merge delete


please show the whole file. it complained about Preliminary end of the stream

berak gravatar imageberak ( 2017-06-06 23:11:17 -0500 )edit

ok edit it. I show the whole file now. Please check

astronaut gravatar imageastronaut ( 2017-06-06 23:16:28 -0500 )edit

-<opencv_storage> <-- the minus sign is real ?

berak gravatar imageberak ( 2017-06-06 23:35:58 -0500 )edit

no. Its not real, I changed it. Now I got this: Inexistent input: Invalid input detected. But I can see my camera is working and showing that ID is 3

astronaut gravatar imageastronaut ( 2017-06-06 23:40:44 -0500 )edit

ok, different error now. but i get same problem.

berak gravatar imageberak ( 2017-06-06 23:46:59 -0500 )edit

Yes. Because didnt save the whole config file. When I use the whole file got that Inexistent input: Invalid input detected.. Any help???

astronaut gravatar imageastronaut ( 2017-06-06 23:51:50 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2017-06-07 00:01:30 -0500

berak gravatar image

updated 2017-06-07 00:07:40 -0500

To use an input camera -> give the ID of the camera, like "1"

that is meant literally, it's trying to read a string, not a number, so you have to write:


apart from that, using images from a live webcam is probably a bad idea here, you'll end uf with a lot of badly adjusted, unsharp, under/over illuminated images and such. better prerecord the images, see, that you have the whole field of view covered, all your images are clear, and use an image list in the calibration config. if you get a bad rms from the calibration, replace the worst images, and try again.

edit flag offensive delete link more


Ok. now giving no error. Its ok by <input>"0"</input>. But its open Image View , but then do nothing. Image view is all grey. Doesnt show the chessboard. Whts is the problem?

astronaut gravatar imageastronaut ( 2017-06-07 00:19:31 -0500 )edit

sorry, i do not understand, what you're saying, so - no idea.

berak gravatar imageberak ( 2017-06-07 00:27:16 -0500 )edit

Image View shows nothing. Program start but then nothing is doing.

astronaut gravatar imageastronaut ( 2017-06-07 01:50:35 -0500 )edit

Should I post new question regarding this problem?

astronaut gravatar imageastronaut ( 2017-06-07 01:50:54 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-06-06 22:36:20 -0500

Seen: 774 times

Last updated: Jun 07 '17