Updated by Andrey Kamaev over 12 years ago
@Mat::isContinuous()@ Mat::isContinuous() gives an erroneous result on 64-bit systems.
The attached file testBigMat.cpp checks whether @Mat::isContinuous()@ Mat::isContinuous() gives the same result than @myCheckMatContinuity()@ myCheckMatContinuity() function defined in the documentation, here:
http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-iscontinuous
It tries to allocate a big matrix (you need a machine with 16Go of memory to test it).
On Windows 7, with Visual C++ 2010 Express, compiled in 32-bit and linked with precompiled OpenCV 2.4.1 (ia32),
it gives the following error message:
<pre>
"OpenCV Error: One of arguments' values is out of range (The total matrix size does not fit to "size_t" type) in unknown function,
file C:\slave\WinInstallerMegaPack\src\opencv\modules\core\src\matrix.cpp, line 125"
This is ok (as size_t is 32bits here).
</pre>
On linux (Fedora 14 x86_64), with g++ 4.5.1, compiled in 64-bit and linked with OpenCV 2.3.1 & 2.4.1 compiled in 64-bit,
I get no error (size_t is 64bits here) however the created matrix is marked as not continuous.
This is not ok.
This is problematic as other methods depend on this check (Mat::reshape() for example).
I have found that there is the following test :
@if( if( j <= i && t == (int)t )@ )
in modules/core/src/matrix.cpp: updateContinuityFlag(Mat& m)
I don't totally understand why there is this test "t == (int)t", but changing it to "t == (size_t)t" might solve the problem.
This is what the patch bigMat.patch does.
On linux 64-bit, the test is now ok: the allocated big matrix is continuous (with OpenCV 2.3.1 & 2.4.1).
I believe this patch will not change the behavior on Windows in 32-bit as size_t is 32-bit there... but I have not tested.
The attached file testBigMat.cpp checks whether @Mat::isContinuous()@ Mat::isContinuous() gives the same result than @myCheckMatContinuity()@ myCheckMatContinuity() function defined in the documentation, here:
http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-iscontinuous
It tries to allocate a big matrix (you need a machine with 16Go of memory to test it).
On Windows 7, with Visual C++ 2010 Express, compiled in 32-bit and linked with precompiled OpenCV 2.4.1 (ia32),
it gives the following error message:
<pre>
"OpenCV Error: One of arguments' values is out of range (The total matrix size does not fit to "size_t" type) in unknown function,
file C:\slave\WinInstallerMegaPack\src\opencv\modules\core\src\matrix.cpp, line 125"
This is ok (as size_t is 32bits here).
</pre>
On linux (Fedora 14 x86_64), with g++ 4.5.1, compiled in 64-bit and linked with OpenCV 2.3.1 & 2.4.1 compiled in 64-bit,
I get no error (size_t is 64bits here) however the created matrix is marked as not continuous.
This is not ok.
This is problematic as other methods depend on this check (Mat::reshape() for example).
I have found that there is the following test :
@if( if( j <= i && t == (int)t )@ )
in modules/core/src/matrix.cpp: updateContinuityFlag(Mat& m)
I don't totally understand why there is this test "t == (int)t", but changing it to "t == (size_t)t" might solve the problem.
This is what the patch bigMat.patch does.
On linux 64-bit, the test is now ok: the allocated big matrix is continuous (with OpenCV 2.3.1 & 2.4.1).
I believe this patch will not change the behavior on Windows in 32-bit as size_t is 32-bit there... but I have not tested.