rtabmap icon indicating copy to clipboard operation
rtabmap copied to clipboard

getMemoryUsed() CV_DbgAssert

Open triplehoon opened this issue 2 years ago • 1 comments

I am using Rtabmap with openCV 4.5.

I got an assertion when I try to run in debug mode.

Especially, in the function getMemoryUsed() in SensorData.cpp.

When calculating elemSize, the openCV assertion came out

inline
size_t Mat::elemSize() const
{
    size_t res = dims > 0 ? step.p[dims - 1] : 0;
   CV_DbgAssert(res != 0); // <<< assertion in here
    return res;
}

Is it by design? Or openCV version problem?

triplehoon avatar Jul 01 '22 04:07 triplehoon

Not sure, it probably means we are calling elemSize() on an empty cv::Mat(). Looking at this code: https://github.com/introlab/rtabmap/blob/aa3b71dbf663d884a0293da7eff7444064e341e1/corelib/src/SensorData.cpp#L812-L829 that is probably true! We would have to check cv::Mat::empty()? before calling elemSize()... Other locations where elemSize() is used: https://github.com/introlab/rtabmap/search?q=elemSize

matlabbe avatar Sep 14 '22 00:09 matlabbe

Fixed by https://github.com/introlab/rtabmap/commit/f1cd819673804e0c5beaad1f5b316b12c4dcf140

matlabbe avatar Sep 17 '23 08:09 matlabbe