Ask Your Question

OpenCV camera calibration error: OpenCV Error: Unknown error code -49 (Input file is empty) in cvOpenFileStorage

asked 2017-10-09 04:44:00 -0600

MaxWell gravatar image

I'm trying to calibrate my PICamera with the camera_calibration.cpp sample. I have taken 6 images from the sample chessboard. cmake and make work, but after running camera_calibration got the following error:

./camera_calibration default.xml
This is a camera calibration sample.
Usage: calibration configurationFile
Near the sample file you'll find the configuration file, which has detailed help of how to edit it.  It may be any OpenCV supported file format XML/YAML.
OpenCV Error: Unknown error code -49 (Input file is empty) in cvOpenFileStorage, file /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/core/src/persistence.cpp, line 4422
terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/core/src/persistence.cpp:4422: error: (-49) Input file is empty in function cvOpenFileStorage

Aborted (core dumped)

Google doesn't want to give me an answer this time, hope someone else does. I used this guide.

I have all the files, images,... in 1 folder. default.xml

<?xml version="1.0"?>
  <!-- Number of inner corners per a item row and column. (square, circle) -->
  <BoardSize_Width> 9</BoardSize_Width>

  <!-- 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.-->



<style type="text/css" id="night-mode-pro-style"/>
<link type="text/css" rel="stylesheet" id="night-mode-pro-link"/>
57.jpg ...
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-10-09 05:17:46 -0600

berak gravatar image

updated 2017-10-09 05:41:09 -0600

those lines don't make any sense, and should be deleted:

<style type="text/css" id="night-mode-pro-style"/>
<link type="text/css" rel="stylesheet" id="night-mode-pro-link"/>

this is not a webpage, and the calibration code tries to read the first toplevel node, which is "style" in your case ;)

just curious, how did that mess end up in your file ?

edit flag offensive delete link more



I have no idea where it came from :) But removing both lines, inserting <?xml version="1.0"?> and using the full path of the images made it work! Thank you sir!

MaxWell gravatar imageMaxWell ( 2017-10-09 06:53:18 -0600 )edit

Question Tools

1 follower


Asked: 2017-10-09 04:44:00 -0600

Seen: 5,383 times

Last updated: Oct 09 '17