port base64 encoding from 3.4#20143
Conversation
72651b4 to
2d17b0f
Compare
| emitter->write("type_id", type_name, false); | ||
| } | ||
| } | ||
| if (fmt != FileStorage::FORMAT_JSON && !FileNode::isFlow(s.flags)) |
There was a problem hiding this comment.
This somehow fixes JSON indentation mismatch with 3.4, but looks fragile.
f9a281e to
430a3ee
Compare
| #include "persistence_impl.hpp" | ||
| #include "base64_encoding.hpp" | ||
|
|
||
| class base64::Base64ContextEmitter |
There was a problem hiding this comment.
- license header
- namespace cv
persistence_prefix in filename
There was a problem hiding this comment.
Thank you for review. Fixed
modules/core/src/base64_encoding.cpp
Outdated
| class base64::Base64ContextEmitter | ||
| { | ||
| public: | ||
| explicit Base64ContextEmitter(cv::FileStorage::Impl * fs) |
There was a problem hiding this comment.
We need to add NULL check or prefer to pass as reference (C has pointers only):
cv::FileStorage::Impl& fs
There was a problem hiding this comment.
As you suggested, I replaced pointer to reference.
modules/core/src/base64_encoding.cpp
Outdated
| if (src_cur != src_beg) | ||
| flush(); /* encode the rest binary data to base64 buffer */ | ||
|
|
||
| if ( file_storage->fmt == cv::FileStorage::Mode::FORMAT_JSON ) |
There was a problem hiding this comment.
JSON
In general, generic classes should not know about used format.
There was a problem hiding this comment.
I removed JSON-specific actions from constructor and destructor( writing "$base64 and " to buffer) and added need_indent field instead.
modules/core/src/base64_encoding.cpp
Outdated
| void base64::Base64Writer::check_dt(const char* dt) | ||
| { | ||
| if ( dt == 0 ) | ||
| CV_Error( CV_StsBadArg, "Invalid \'dt\'." ); |
There was a problem hiding this comment.
CV_Sts...
Avoid using of legacy C API constants. Use Error::Sts... enum
| #ifndef OPENCV_CORE_PERSISTENCE_IMPL_HPP | ||
| #define OPENCV_CORE_PERSISTENCE_IMPL_HPP | ||
|
|
||
| #include "precomp.hpp" |
There was a problem hiding this comment.
precomp.hpp
must be used in .cpp files only (as unconditional first include)
| def get_normal_2d_mat(): | ||
| rows = 10 | ||
| cols = 20 | ||
| ch = 3 |
There was a problem hiding this comment.
ch
cn is usually used in OpenCV code.
9a28098 to
e7cae25
Compare
|
Is this PR still in WIP status? (as per PR title) |
I squashed commits, changed the title, it's ready for merge. |
issue #14977
Test data is at opencv/opencv_extra#877