Opencv: CPP Camera Calibration example does not work

Created on 4 May 2016  路  3Comments  路  Source: opencv/opencv

Hi, I'd first ask on the Q&A page but since it is down I'm posting here first.

When running the given C++ tutorial on camera calibration I encounter the following error on both Windows (3.1.0 binaries) and Linux (recent clone of github repo, on default Ubuntu 14.04). I have used the calibration images available in the sample data. Using the same images and as far as I know identical settings I did not encounter errors when using the similar python tutorial ($OPENCV_DIR/samples/python/calibrate.py).

Please state the information for your system

  • OpenCV version: 3.1.0
  • Host OS: Linux (Ubuntu 14.04) [built from recent github source] & Windows 10 [sourceforge binaries]

    In which part of the OpenCV library you got the issue?

Camera calibration, core.

Expected behaviour

Write camera data to path/file given in settings.xml

Actual behaviour

$ ./camera_calibration settings.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: Assertion failed (src.size == dst.size && src.channels() == dst.channels()) in cvConvertScale, file $OPENCV_DIR/modules/core/src/convert.cpp, line 5474
terminate called after throwing an instance of 'cv::Exception'
  what():  $OPENCV_DIR/modules/core/src/convert.cpp:5474: error: (-215) src.size == dst.size && src.channels() == dst.channels() in function cvConvertScale


Aborted (core dumped)

Code example to reproduce the issue / Steps to reproduce the issue

Please try to give a full example which will compile as is.

  1. Placed the sample calibration images from $OPENCV_DIR/samples/data in a folder images
  2. Copied sample code from $OPENCV_DIR/samples/cpp/tutorial_code/calib3d/camera_calbration to working directory
  3. Compiled using cmake . followed by make. CMakeLists.txt is based on the example given in http://docs.opencv.org/3.1.0/db/df5/tutorial_linux_gcc_cmake.html#gsc.tab=0
  4. Run with ./camera_calibration settings.xml, alternatively for windows camera_calibration.exe settings.xml
  5. Receive error message

Using the series of calibration images available in $OPENCV_DIR/samples/data (left1-14.jpg and right1-14.jpg) as listed in image_list.xml

Relevant files

Rename from .txt to get xml if needed.
settings.xml.txt
image_list.xml.txt
CMake:
CMakeLists.txt

invalid

Most helpful comment

Your image_list.xml contains wrong image paths, they should be as follows:

images/left01.jpg
images/left02.jpg
images/left03.jpg
...

All 3 comments

Your image_list.xml contains wrong image paths, they should be as follows:

images/left01.jpg
images/left02.jpg
images/left03.jpg
...

I have same this bug.

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.0.0-pre) /opt/opencv/modules/core/src/convert_c.cpp:112: error: (-215:Assertion failed) src.size == dst.size && src.channels() == dst.channels() in function 'cvConvertScale'

in_VID5.xml

...
        <BoardSize_Width>9</BoardSize_Width>
        <BoardSize_Height>13</BoardSize_Height>
...
<Input>"/home/monxarat/projects/test/image/calibration/img/VID5.xml"</Input>
...

VID5.ml

<?xml version="1.0"?>
<opencv_storage>
    <images>
      /home/monxarat/projects/test/image/calibration/img/chess_6.jpg
       /home/monxarat/projects/test/image/calibration/img/chess_6.jpg
    </images>
</opencv_storage>

image
chess_6

Run is OK if set config size_width and size_height with n - 1 and m - 1(n is number of columns in real board-size, m is number of rows in real board-size)

<BoardSize_Width>12</BoardSize_Width>
<BoardSize_Height>8</BoardSize_Height>
Was this page helpful?
0 / 5 - 0 ratings