interactive calibration application fails assertion when compiled for debug

asked 2018-08-10 13:25:34 -0600

mdresser gravatar image

Environment: openCV 3.4.2, Windows 10, VS2017

I have recompiled the interactive calibration application in debug mode (After modifying parts of main.cpp and calibPipeline.cpp to work with Spinnaker library from FLIR). Everything is more-or-less working up to when the maximum number of frames are collected and the filterFrames function in calibController.cpp starts removing poor frames from the queue. (I haven't made any changes to this code)

At this point the debugger halts, reporting a debug assertion failure as shown below in mat.inl.hpp:

template<typename _Tp> inline
_Tp* Mat::ptr(int y)
{
    CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) );
    return (_Tp*)(data + step.p[0] * y);
}

after some debugging I've traced the offending line of code in calibController.cpp to:

std::copy(mCalibData->perViewErrors.ptr<double>((int)worstElemIndex + 1), mCalibData->perViewErrors.ptr<double>((int)numberOfFrames),newErrorsVec.ptr<double>((int)worstElemIndex));

I'm simultaneously trying to get up to speed with openCV, C++, and VS 2017 and have reached (or maybe exceeded) the limits of my knowledge so I'm not sure where to go next.

The code seems to make sense and when compiled for release, the code executes without crashing but I've always heard that it's a bad idea to assume that asserts are false alarms...

edit retag flag offensive close merge delete

Comments

In debug mode when assertion is set use stack trace to get context at line https://github.com/opencv/opencv/blob... then you can display values of mCalibData, numberOfFrames,.... something must be wrong

LBerger gravatar imageLBerger ( 2018-08-10 15:14:57 -0600 )edit

looks like a valid bug to me.

what if worstElemIndex happens to be the last one ? the code does not check.

berak gravatar imageberak ( 2018-08-11 07:25:23 -0600 )edit