Skip to content

handle huge matrices correctly - #11505

Merged
vpisarev merged 8 commits into
opencv:3.4from
vpisarev:huge_img_handling
May 14, 2018
Merged

vpisarev merged 8 commits into
opencv:3.4from
vpisarev:huge_img_handling

Conversation

@vpisarev

@vpisarev vpisarev commented May 11, 2018 •

Copy link
Copy Markdown
Contributor

make sure that the matrix with more than INT_MAX elements is marked as non-continuous, and thus all the pixel-wise functions process it correctly (i.e. row-by-row, not as a single row, where integer overflow may occur when computing the total number of elements).

resolves #10211

force_builders=Custom
docker_image:Custom=ubuntu-cuda:16.04

…s non-continuous, and thus all the pixel-wise functions process it correctly (i.e. row-by-row, not as a single row, where integer overflow may occur when computing the total number of elements)
@vpisarev

vpisarev commented May 11, 2018 •

Copy link
Copy Markdown
Contributor Author

yes, definitely. And it's not a mess at all. On small images (like 20x20) this trick with

Size size = mat.size();
if( mat.isContinuous() ) { size.width *= size.height; size.height = 1; }

can accelerate processing by 10-20% in the case of simple functions. And it's put in many places of the library and in the user code as well. Obviously, this trick can only be done with size.width * size.height not bigger than INT_MAX. And it's also obviously that it only needs to be checked during matrix construction (just few places in the library), not when you process the matrix (many places in the library and in the user code). We attempted to implement such check in updateContinuityFlag() function, but 1) it contained a bug and 2) it was not used everywhere.

@alalek

alalek commented May 14, 2018

Copy link
Copy Markdown
Member

@vpisarev
vpisarev merged commit e0dbe5c into opencv:3.4 May 14, 2018
@hrnr

hrnr commented May 14, 2018

Copy link
Copy Markdown
Contributor

Do I understand correctly that huge arrays (matrix 1xN) are still not supported by cv::Mat? Or is it somehow solved too?

This was referenced May 15, 2018
@vpisarev
vpisarev deleted the huge_img_handling branch June 27, 2018 10:06
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
* make sure that the matrix with more than INT_MAX elements is marked as non-continuous, and thus all the pixel-wise functions process it correctly (i.e. row-by-row, not as a single row, where integer overflow may occur when computing the total number of elements)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants