Access violation when using cv::sum() on ROI of a Matrix

asked 2015-07-01 12:09:02 -0500

dvmc gravatar image
cv::Mat mask(45, 45, CV_32F, 0);

cv::Mat roi1(mask, cv::Rect(0, 0, 15, 15));

cv::Mat roi2(mask, cv::Rect(15, 0, 15, 15));

cv::sum(roi1); // no access violation
cv::sum(roi2); // access violation

Why is there an access violation when trying to get the sum of roi2? It seems that it's clearly inside the boundaries of mask.

Using Visual Studio 2010 and OpenCV 2.4.10

edit retag flag offensive close merge delete

Comments

1

nice test case (reproducable on win and linux, opencv 2.4 and 3.0), - looks like a valid bug, please make an official issue here

(it seems to call simd instructions, without checking, if the pointer to the roi data is properly aligned)

berak gravatar imageberak ( 2015-07-01 12:23:03 -0500 )edit

Thanks, I've reported the bug. Hope you don't mind that I've quoted you.

dvmc gravatar imagedvmc ( 2015-07-02 03:03:32 -0500 )edit

^^ well done, thanks, no problem.

berak gravatar imageberak ( 2015-07-02 03:34:24 -0500 )edit

As Alexander Alekhin points out in the bug tracker, it's merely the wrongly called constructor of mask.

dvmc gravatar imagedvmc ( 2015-07-02 10:35:30 -0500 )edit

oh, right, i did not see it earlier, sorry..

berak gravatar imageberak ( 2015-07-02 10:44:49 -0500 )edit