Ask Your Question
3

Problem with OpenCV calibration module

asked 2013-04-22 03:25:16 -0600

alfa_80 gravatar image

updated 2013-04-22 04:53:22 -0600

I have been spending some time to get my camera calibration working using OpenCV module as documented here. In particular, I have 3 questions regarding this issue:

  1. When using camera input by setting certain value in XML configuration file, I got it working but after the calibration, I got a worse(than the original input) output remapped image. Are there any configuration that I am not aware of?

    Is the following configuration important, if so, should I measure in mm scale:

    <!-- The size of a square in some user defined metric system (pixel, millimeter)-->
    <Square_Size>50</Square_Size>
    
  2. When using image list or recorded video stream, I didn't get any working? Is there any trick, perhaps? It didn't even detect the corners in my chessboard calibration target. When using image list, it runs the image sequences, however, without detecting corners and eventually I received the following error:

    OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules/core/src/matrix.cpp, line 697 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules/core/src/matrix.cpp:697: error: (-5) Unknown array type in function cvarrToMat

  3. When using recorded video stream, I always get the following error:

    OpenCV Error: Parsing error (output.avi(0): Too long string or a last string w/o newline) in icvXMLSkipSpaces
    

Thanks in advance.

edit retag flag offensive close merge delete

Comments

Hi Alfa_80, can I ask how you have used a list of images for calibration? I am having the same errors as you. i have followed the answer below with no luck. any help would be great. Thanks

Geophotologist gravatar imageGeophotologist ( 2013-06-09 20:10:56 -0600 )edit

It's long ago, I hope still remember. Actually, you just need to define some parameters in the default.xml. There is an image list there that you can set.

alfa_80 gravatar imagealfa_80 ( 2013-07-10 11:48:53 -0600 )edit

did anyone find a solution to this, i'm having similar issues. I've been able to successfully calibrate a camera with mild distortion but when using the ar drones wide angle lens it throws the following error: OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /home/james-tt/Dropbox/Term_2/Final_Project/OpenCv/opencv-2.4.9/modules/core/src/matrix.cpp, line 698 terminate called after throwing an instance of 'cv::Exception' what(): /home/james-tt/Dropbox/Term_2/Final_Project/OpenCv/opencv-2.4.9/modules/core/src/matrix.cpp:698: error: (-5) Unknown array type in function cvarrToMat

albertJ gravatar imagealbertJ ( 2015-10-13 11:12:18 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
1

answered 2013-04-22 05:43:30 -0600

NightLife gravatar image

1) The number of images that you use to make the calibration matrix is important. Try to make at least 10 image from chessboard in different situation. Also be carefull about the condition of photographing, they should be the same, specially "Focal Lengths" and "Resolution".

It seems that problem "2" and "3" will be solved if you manage problem number one.

I strongly suggest you to read and implement the camera calibration part from Learning OpenCV book.

edit flag offensive delete link more

Comments

Thanks for the answer, what do you mean by "Also be carefull about the condition of photographing, they should be the same, specially 'Focal Lengths' and 'Resolution'"? Do you mean while recording the video or image sequences, I should be using the same camera and with fixed lighting condition?

alfa_80 gravatar imagealfa_80 ( 2013-04-22 06:04:40 -0600 )edit

Regarding "It seems that problem "2" and "3" will be solved if you manage problem number one.", why is it complained in the first place, not even trying to take the recorded video input.

alfa_80 gravatar imagealfa_80 ( 2013-04-22 06:16:20 -0600 )edit

As I told you : 'Focal Lengths' and 'Resolution' Infact, these parameters will be changed the .xml file, so when you make the .xml file parameters with specific conditions, you have to calibrate the images(photographing) and videos (live camera) by considering those condition.

NightLife gravatar imageNightLife ( 2013-04-22 06:18:15 -0600 )edit

Is that really mandatory to set "The size of a square in some user defined metric system (pixel, millimeter)", in the XML config file? I leave it as 50, how to benefit from it?

alfa_80 gravatar imagealfa_80 ( 2013-04-22 06:43:42 -0600 )edit

With what you pointed out, I did it, but still getting the re-projection error about 4.44602, which is pretty high.

alfa_80 gravatar imagealfa_80 ( 2013-04-22 06:53:16 -0600 )edit

I do not know about it, but as I have implemented, the number of squares were enough to have a very good calibration. For example for a 6-by-8 chessboard , the number of squares should be 5-by-7 or less :)

NightLife gravatar imageNightLife ( 2013-04-22 06:56:38 -0600 )edit
1

It's now working out of the box taking into consideration your thoughts..thanks anyway.

alfa_80 gravatar imagealfa_80 ( 2013-04-22 13:32:33 -0600 )edit

BTW, is it OK to use PNG images? or won't be compatible..I'm just curious..

alfa_80 gravatar imagealfa_80 ( 2013-04-24 08:47:25 -0600 )edit

I am experiencing the same issue using a list of images. Did you manage to work it out alfa_80? I have 12 images using the same camera with the same settings (using gopro3). It keeps on coming up with the error you mentioned. And I have looked over and over through the book.

Geophotologist gravatar imageGeophotologist ( 2013-05-12 02:14:17 -0600 )edit

Well, I dont have any idea about it right now, my friend.

NightLife gravatar imageNightLife ( 2013-05-12 10:53:28 -0600 )edit
0

answered 2016-11-15 09:41:23 -0600

mannyglover gravatar image

Switch length and width. I ended up just switching the length and width numbers in the input xml file, and it ended up working. Initially, I was getting a funky undistorted image, but I set all the following constraints to zero (false):

  <!-- 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.-->
  <Calibrate_AssumeZeroTangentialDistortion>1</Calibrate_AssumeZeroTangentialDistortion>
  <!-- If true (non-zero) the principal point is not changed during the global optimization.-->
  <Calibrate_FixPrincipalPointAtTheCenter> 1 </Calibrate_FixPrincipalPointAtTheCenter>

and then it worked correctly.

edit flag offensive delete link more
0

answered 2015-10-13 17:06:48 -0600

albertJ gravatar image

In case anyone is still not sure about this, there's a working example of a calibration setup here for the ar drone 2.0. The camera used is a wide angle lens and he uses 11 images to produce a rough calibration. As far as for the original three questions:

  1. i haven't found the <squaresize> to have any real effect it looks like this is likely just to document the calibration template used in the results xml.
  2. I've had this as well and have noticed that the input pictures can influence this significantly. Taking the images on a dark (used a black table), background seems to allow for the chessboard pattern to be recognised more consistently. Also keeping the centre of the board roughly in the centre of the image when imaging at different angles/rotations ect, seems to help to an extent as well, these are largely just from my experience however.
  3. I'm not sure why it works with a videostream(1) but not a saved video file, i've also had trouble with this.

Anyway hope this helps. I'll update this if i find anything else which is relevant.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-04-22 03:25:16 -0600

Seen: 4,135 times

Last updated: Nov 15 '16