mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #26937 from MaximSmolskiy:support-bool-type-for-filestorage-base64
Support bool type for FileStorage Base64 #26937 ### Pull Request Readiness Checklist OpenCV extra: https://github.com/opencv/opencv_extra/pull/1238 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:
@@ -605,6 +605,7 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo
|
||||
cv::Mat _2d_out_u32, _2d_in_u32;
|
||||
cv::Mat _2d_out_i64, _2d_in_i64;
|
||||
cv::Mat _2d_out_u64, _2d_in_u64;
|
||||
cv::Mat _2d_out_bool, _2d_in_bool;
|
||||
cv::Mat _nd_out, _nd_in;
|
||||
cv::Mat _rd_out(8, 16, CV_64FC1), _rd_in;
|
||||
|
||||
@@ -639,6 +640,10 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo
|
||||
/* a random mat */
|
||||
cv::randu(_rd_out, cv::Scalar(0.0), cv::Scalar(1.0));
|
||||
|
||||
/* a normal mat bool */
|
||||
_2d_out_bool = Mat(10, 20, CV_BoolC3);
|
||||
cv::randu(_2d_out_bool, 0U, 2U);
|
||||
|
||||
/* raw data */
|
||||
for (int i = 0; i < (int)rawdata_N; i++) {
|
||||
data_t tmp;
|
||||
@@ -660,6 +665,7 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo
|
||||
fs << "normal_2d_mat_u32" << _2d_out_u32;
|
||||
fs << "normal_2d_mat_i64" << _2d_out_i64;
|
||||
fs << "normal_2d_mat_u64" << _2d_out_u64;
|
||||
fs << "normal_2d_mat_bool" << _2d_out_bool;
|
||||
fs << "normal_nd_mat" << _nd_out;
|
||||
fs << "empty_2d_mat" << _em_out;
|
||||
fs << "random_mat" << _rd_out;
|
||||
@@ -702,7 +708,7 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo
|
||||
}
|
||||
}
|
||||
std::cout << "Storage size: " << sz << std::endl;
|
||||
EXPECT_LE(sz, (size_t)24000);
|
||||
EXPECT_LE(sz, (size_t)25000);
|
||||
}
|
||||
{ /* read */
|
||||
cv::FileStorage fs(name, cv::FileStorage::READ + (useMemory ? cv::FileStorage::MEMORY : 0));
|
||||
@@ -713,6 +719,7 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo
|
||||
fs["normal_2d_mat_u32"] >> _2d_in_u32;
|
||||
fs["normal_2d_mat_i64"] >> _2d_in_i64;
|
||||
fs["normal_2d_mat_u64"] >> _2d_in_u64;
|
||||
fs["normal_2d_mat_bool"] >> _2d_in_bool;
|
||||
fs["normal_nd_mat"] >> _nd_in;
|
||||
fs["random_mat"] >> _rd_in;
|
||||
|
||||
@@ -752,6 +759,7 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo
|
||||
EXPECT_MAT_NEAR(_2d_in_u32, _2d_out_u32, 0);
|
||||
EXPECT_MAT_NEAR(_2d_in_i64, _2d_out_i64, 0);
|
||||
EXPECT_MAT_NEAR(_2d_in_u64, _2d_out_u64, 0);
|
||||
EXPECT_MAT_NEAR(_2d_in_bool, _2d_out_bool, 0);
|
||||
|
||||
ASSERT_EQ(_nd_in.rows , _nd_out.rows);
|
||||
ASSERT_EQ(_nd_in.cols , _nd_out.cols);
|
||||
|
||||
Reference in New Issue
Block a user