From 24bc0db1b009e52145b49cee508fc01efbb63fe5 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Wed, 28 Mar 2012 09:57:31 +0000 Subject: [PATCH] fixed writing huge matrices (ticket #1439) --- modules/core/src/persistence.cpp | 2 +- modules/core/test/test_io.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 0746aafb2..e82958035 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -3410,7 +3410,7 @@ icvWriteMat( CvFileStorage* fs, const char* name, } for( y = 0; y < size.height; y++ ) - cvWriteRawData( fs, mat->data.ptr + y*mat->step, size.width, dt ); + cvWriteRawData( fs, mat->data.ptr + (size_t)y*mat->step, size.width, dt ); } cvEndWriteStruct( fs ); cvEndWriteStruct( fs ); diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 45390e590..40aab5365 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -376,3 +376,32 @@ protected: }; TEST(Core_InputOutput, write_read_consistency) { Core_IOTest test; test.safe_run(); } + +/*class CV_BigMatrixIOTest : public cvtest::BaseTest +{ +public: + CV_BigMatrixIOTest() {} + ~CV_BigMatrixIOTest() {} +protected: + void run(int) + { + try + { + RNG& rng = theRNG(); + int N = 1000, M = 1200000; + Mat mat(M, N, CV_32F); + rng.fill(mat, RNG::UNIFORM, 0, 1); + FileStorage fs("test.xml", FileStorage::WRITE); + fs << "mat" << mat; + fs.release(); + } + catch(...) + { + ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); + } + } +}; + +TEST(Core_InputOutput, huge) { CV_BigMatrixIOTest test; test.safe_run(); } +*/ +