Ask Your Question

Revision history [back]

I think the problem can be the mask object's size.

I guess the number of rows of mask is ok, but the number of columns is zero. You can check it by printing mask.cols and mask.rows. So you may have something like this: cv::Mat mask(100,0,CV_...

That would explains why it fails when summing over columns, but not when summing over rows.

Anyway, I have just noticed that the ouput of cv::reduce cannot be of type uint8_t, since it has not enough capacity to store the whole sums. So, for instance, the output needs to be of type int or larger for an input of type uint8_t.

I think the problem can be the size of mask object's size..

I guess the number of rows of mask is ok, but the number of columns is zero. You can check it by printing mask.cols and mask.rows. So you may have erroneously initialized it with something like this: cv::Mat mask(100,0,CV_...

That would explains why it fails when summing over columns, but not when summing over rows.

Anyway, I have just noticed that the ouput of cv::reduce cannot be of type uint8_t, since it has not enough capacity to store the whole sums. So, for instance, the output needs to be of type int or larger for an input of type uint8_t.