Ask Your Question

Camera calibration tutorial: assertion failed

asked 2014-11-10 07:13:01 -0500

gtu gravatar image

updated 2014-11-14 08:40:50 -0500

Hi, I am developing an algorithm which measures dimensions of an object. I noticed that measurement error rises when moving out of image center. So I decided to calibrate my camera. I came across this tutorial.

The code I used is the same as in the tutorial AND in the openCV sample code directory (opencv\sources\samples\cpp\tutorial_code\calib3d\camera_calibration).

The program finds all needed files - the configuration file, list of image names, images. So that is not the problem.

When I run it, it throws an error:

Debug Assertion Failed!

Program: ---udio
File: f:\dd\vctools\crt\crtw32\misc\dbgheap.c
Line: 1424

Expression: _pFirstBlock==pHead

For information on how your program can cause an assertion failure, see the VisaulC++ documentation on asserts.

The error seems to happen in the following statement:

  if (mode == CAPTURING)
            if (s.showUndistorsed)
  (here)->      msg = format("%d/%d Undist", (int)imagePoints.size(), s.nrFrames);
                msg = format("%d/%d", (int)imagePoints.size(), s.nrFrames);

But it finds chessboard edges thou! image description

Then I commented it and the error showed up a little later.

The next thing I tried to create calibration all on my own. I wrote this program:

int main(){
Mat pic;
vector<Point2f> pointBuf;

pic = imread("images//f4.tiff");

findChessboardCorners(pic, Size(9, 6), pointBuf);
drawChessboardCorners(pic, Size(9, 6), Mat(pointBuf),true);
imshow("Rezultat", pic);


And again, same thing. All functions seem to work properly, finds corners, draws them on the image, shows them, only when I want to close window on waitKey(), the program throws same error again.

I am very confused. Please help.

Thank you!

edit retag flag offensive close merge delete


no one knows that?

gtu gravatar imagegtu ( 2014-11-13 00:13:19 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-05-26 12:36:29 -0500

stillNovice gravatar image

Hi there, I just came across this issue and after serious web trawling, found the answer.

you need to go to your visual studio project settings, to c/c++, to code generation and change the runtime library to Multi-threaded Debug DLL (/MDd).

It seems this error is from a single threaded DLL trying to run in a multi thread project.

good luck.

edit flag offensive delete link more


OK, that actually helped! Didn't expect such easy solution. Thanks.

gtusar gravatar imagegtusar ( 2015-05-28 07:31:21 -0500 )edit

what can I do if my configuration has been like that?

timial gravatar imagetimial ( 2016-01-20 19:49:38 -0500 )edit

Question Tools


Asked: 2014-11-10 07:13:01 -0500

Seen: 1,514 times

Last updated: May 26 '15