OpenCV bundle adjustment Assertion failed

asked 2019-01-21 03:56:13 -0600

I am stitching images using OpenCV 4.0.1 with C++ on Windows 10

Some images do not stitch and program stops with an error like this:

Assertion failed: !err.empty(), file C:\OpenCV\4\source\opencv-4.0.1\modules\calib3d\src\compat_ptsetreg.cpp, line 125

This error occurs when I try to do the bundle adjustment

if (ba_refine_mask[0] == 'x') refine_mask(0, 0) = 1;
if (ba_refine_mask[1] == 'x') refine_mask(0, 1) = 1;
if (ba_refine_mask[2] == 'x') refine_mask(0, 2) = 1;
if (ba_refine_mask[3] == 'x') refine_mask(1, 1) = 1;
if (ba_refine_mask[4] == 'x') refine_mask(1, 2) = 1;

adjuster->setRefinementMask(refine_mask);

if (!(*adjuster)(pair->features, pair->pairwise_matches, pair->cameras))
{
  LOG("Bundle Adjustment failed!");
  return EXIT_FAILURE;
}

How to know what is the error and how to handle such assertions properly without crashing my program?

edit retag flag offensive close merge delete