1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #26399 from dkurt:dk/file_storage_new_data

int64 data type in FileStorage #26399

### Pull Request Readiness Checklist

resolves #23333

Proposed approach is not perfect in terms of complexity and potential bugs. Instead of changing `INT` raw size from `4` to `8`, we check int64 value can be fitted to int32 or not.

Collections such as cv::Mat rely on data type symbol.

This PR is addressed to 5.x branch first to cover `CV_64S` Mat. Later, it can be backported to 4.x

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Dmitry Kurtaev
2024-11-08 08:27:59 +03:00
committed by GitHub
parent 3fac9a9d69
commit a7bb17b092
9 changed files with 143 additions and 20 deletions
+21
View File
@@ -2066,6 +2066,27 @@ TEST_P(FileStorage_exact_type, mat_1d)
testExactMat(Mat({1}, CV_32S, Scalar(8)), GetParam());
}
TEST_P(FileStorage_exact_type, long_int)
{
for (const int64_t expected : std::vector<int64_t>{INT64_MAX, INT64_MIN, -1, 1, 0})
{
int64_t value = fsWriteRead(expected, GetParam());
EXPECT_EQ(value, expected);
}
}
TEST_P(FileStorage_exact_type, long_int_mat)
{
Mat src(2, 4, CV_64SC(3));
int64_t* data = src.ptr<int64_t>();
for (size_t i = 0; i < src.total() * src.channels(); ++i)
{
data[i] = INT64_MAX - static_cast<int64_t>(std::rand());
}
Mat dst = fsWriteRead(src, GetParam());
EXPECT_EQ(cv::norm(src, dst, NORM_INF), 0.0);
}
INSTANTIATE_TEST_CASE_P(Core_InputOutput,
FileStorage_exact_type, Values(".yml", ".xml", ".json")
);