mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +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:
@@ -1876,6 +1876,9 @@ char *FileStorage::Impl::parseBase64(char *ptr, int indent, FileNode &collection
|
||||
case CV_8S:
|
||||
ival = (char) base64decoder.getUInt8();
|
||||
break;
|
||||
case CV_Bool:
|
||||
ival = base64decoder.getUInt8() != 0;
|
||||
break;
|
||||
case CV_16U:
|
||||
ival = base64decoder.getUInt16();
|
||||
break;
|
||||
|
||||
@@ -202,6 +202,7 @@ int base64::icvCalcStructSize(const char *dt, int initial_size) {
|
||||
switch ( *type )
|
||||
{
|
||||
case 'u': { elem_max_size = std::max( elem_max_size, sizeof(uchar ) ); break; }
|
||||
case 'b': { elem_max_size = std::max( elem_max_size, sizeof(uchar ) ); break; }
|
||||
case 'c': { elem_max_size = std::max( elem_max_size, sizeof(schar ) ); break; }
|
||||
case 'w': { elem_max_size = std::max( elem_max_size, sizeof(ushort) ); break; }
|
||||
case 's': { elem_max_size = std::max( elem_max_size, sizeof(short ) ); break; }
|
||||
@@ -333,6 +334,10 @@ size_t base64::RawDataToBinaryConvertor::make_to_binary_funcs(const std::string
|
||||
size = sizeof(uchar);
|
||||
pack.func = to_binary<uchar>;
|
||||
break;
|
||||
case 'b':
|
||||
size = sizeof(uchar);
|
||||
pack.func = to_binary<bool>;
|
||||
break;
|
||||
case 'w':
|
||||
case 's':
|
||||
size = sizeof(ushort);
|
||||
|
||||
@@ -68,6 +68,11 @@ to_binary(_uint_t val, uchar * cur)
|
||||
return sizeof(_uint_t);
|
||||
}
|
||||
|
||||
template<> inline size_t to_binary(bool val, uchar * cur)
|
||||
{
|
||||
return to_binary(static_cast<uchar>(val), cur);
|
||||
}
|
||||
|
||||
template<> inline size_t to_binary(double val, uchar * cur)
|
||||
{
|
||||
Cv64suf bit64;
|
||||
|
||||
Reference in New Issue
Block a user