mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #22934 from alalek:fix_filestorage_binding
This commit is contained in:
commit
eace6adb6d
@ -3095,12 +3095,16 @@ public:
|
||||
|
||||
/** @brief Stores algorithm parameters in a file storage
|
||||
*/
|
||||
virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
|
||||
CV_WRAP virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
|
||||
|
||||
/** @brief simplified API for language bindings
|
||||
/**
|
||||
* @overload
|
||||
*/
|
||||
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
|
||||
CV_WRAP void write(FileStorage& fs, const String& name) const;
|
||||
#if CV_VERSION_MAJOR < 5
|
||||
/** @deprecated */
|
||||
void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
|
||||
#endif
|
||||
|
||||
/** @brief Reads algorithm parameters from a file storage
|
||||
*/
|
||||
|
@ -55,19 +55,27 @@ Algorithm::~Algorithm()
|
||||
CV_TRACE_FUNCTION();
|
||||
}
|
||||
|
||||
void Algorithm::write(const Ptr<FileStorage>& fs, const String& name) const
|
||||
void Algorithm::write(FileStorage& fs, const String& name) const
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
if(name.empty())
|
||||
{
|
||||
write(*fs);
|
||||
write(fs);
|
||||
return;
|
||||
}
|
||||
*fs << name << "{";
|
||||
write(*fs);
|
||||
*fs << "}";
|
||||
fs << name << "{";
|
||||
write(fs);
|
||||
fs << "}";
|
||||
}
|
||||
|
||||
#if CV_VERSION_MAJOR < 5
|
||||
void Algorithm::write(const Ptr<FileStorage>& fs, const String& name) const
|
||||
{
|
||||
CV_Assert(fs);
|
||||
write(*fs, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Algorithm::save(const String& filename) const
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
|
@ -212,7 +212,10 @@ public:
|
||||
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
|
||||
|
||||
// see corresponding cv::Algorithm method
|
||||
CV_WRAP inline void write(const Ptr<FileStorage>& fs, const String& name = String()) const { Algorithm::write(fs, name); }
|
||||
CV_WRAP inline void write(FileStorage& fs, const String& name) const { Algorithm::write(fs, name); }
|
||||
#if CV_VERSION_MAJOR < 5
|
||||
inline void write(const Ptr<FileStorage>& fs, const String& name) const { CV_Assert(fs); Algorithm::write(*fs, name); }
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Feature detectors in OpenCV have wrappers with a common interface that enables you to easily switch
|
||||
@ -1101,7 +1104,10 @@ public:
|
||||
|
||||
|
||||
// see corresponding cv::Algorithm method
|
||||
CV_WRAP inline void write(const Ptr<FileStorage>& fs, const String& name = String()) const { Algorithm::write(fs, name); }
|
||||
CV_WRAP inline void write(FileStorage& fs, const String& name) const { Algorithm::write(fs, name); }
|
||||
#if CV_VERSION_MAJOR < 5
|
||||
inline void write(const Ptr<FileStorage>& fs, const String& name) const { CV_Assert(fs); Algorithm::write(*fs, name); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -209,7 +209,8 @@ simple_argtype_mapping = {
|
||||
"int": ArgTypeInfo("int", FormatStrings.int, "0", True),
|
||||
"float": ArgTypeInfo("float", FormatStrings.float, "0.f", True),
|
||||
"double": ArgTypeInfo("double", FormatStrings.double, "0", True),
|
||||
"c_string": ArgTypeInfo("char*", FormatStrings.string, '(char*)""')
|
||||
"c_string": ArgTypeInfo("char*", FormatStrings.string, '(char*)""'),
|
||||
"UMat": ArgTypeInfo("UMat", FormatStrings.object, 'UMat()', True), # FIXIT: switch to CV_EXPORTS_W_SIMPLE as UMat is already a some kind of smart pointer
|
||||
}
|
||||
|
||||
# Set of reserved keywords for Python. Can be acquired via the following call
|
||||
@ -429,6 +430,7 @@ class ArgInfo(object):
|
||||
self.name += "_"
|
||||
self.defval = arg_tuple[2]
|
||||
self.isarray = False
|
||||
self.is_smart_ptr = self.tp.startswith('Ptr<') # FIXIT: handle through modifiers - need to modify parser
|
||||
self.arraylen = 0
|
||||
self.arraycvt = None
|
||||
self.inputarg = True
|
||||
@ -720,7 +722,21 @@ class FuncInfo(object):
|
||||
if any(tp in codegen.enums.keys() for tp in tp_candidates):
|
||||
defval0 = "static_cast<%s>(%d)" % (a.tp, 0)
|
||||
|
||||
arg_type_info = simple_argtype_mapping.get(tp, ArgTypeInfo(tp, FormatStrings.object, defval0, True))
|
||||
if tp in simple_argtype_mapping:
|
||||
arg_type_info = simple_argtype_mapping[tp]
|
||||
else:
|
||||
if tp in all_classes:
|
||||
tp_classinfo = all_classes[tp]
|
||||
cname_of_value = tp_classinfo.cname if tp_classinfo.issimple else "Ptr<{}>".format(tp_classinfo.cname)
|
||||
arg_type_info = ArgTypeInfo(cname_of_value, FormatStrings.object, defval0, True)
|
||||
assert not (a.is_smart_ptr and tp_classinfo.issimple), "Can't pass 'simple' type as Ptr<>"
|
||||
if not a.is_smart_ptr and not tp_classinfo.issimple:
|
||||
assert amp == ''
|
||||
amp = '*'
|
||||
else:
|
||||
# FIXIT: Ptr_ / vector_ / enums / nested types
|
||||
arg_type_info = ArgTypeInfo(tp, FormatStrings.object, defval0, True)
|
||||
|
||||
parse_name = a.name
|
||||
if a.py_inputarg:
|
||||
if arg_type_info.strict_conversion:
|
||||
|
Loading…
Reference in New Issue
Block a user