mirror of
https://github.com/zebrajr/opencv.git
synced 2026-01-15 12:15:17 +00:00
Merge pull request #17436 from vpisarev:fix_python_io
* fixed #17044 1. fixed Python part of the tutorial about using OpenCV XML-YAML-JSON I/O functionality from C++ and Python. 2. added startWriteStruct() and endWriteStruct() methods to FileStorage 3. modifed FileStorage::write() methods to make them work well inside sequences, not only mappings. * try to fix the doc builder * added Python regression test for FileStorage I/O API ([TODO] iterating through long sequences can be very slow) * fixed yaml testing
This commit is contained in:
@@ -29,12 +29,12 @@ class MyData:
|
||||
return s
|
||||
|
||||
## [inside]
|
||||
def write(self, fs):
|
||||
fs.write('MyData','{')
|
||||
def write(self, fs, name):
|
||||
fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)
|
||||
fs.write('A', self.A)
|
||||
fs.write('X', self.X)
|
||||
fs.write('name', self.name)
|
||||
fs.write('MyData','}')
|
||||
fs.endWriteStruct()
|
||||
|
||||
def read(self, node):
|
||||
if (not node.empty()):
|
||||
@@ -74,25 +74,26 @@ def main(argv):
|
||||
## [writeNum]
|
||||
|
||||
## [writeStr]
|
||||
s.write('strings', '[')
|
||||
s.write('image1.jpg','Awesomeness')
|
||||
s.write('../data/baboon.jpg',']')
|
||||
s.startWriteStruct('strings', cv.FileNode_SEQ)
|
||||
for elem in ['image1.jpg', 'Awesomeness', '../data/baboon.jpg']:
|
||||
s.write('', elem)
|
||||
s.endWriteStruct()
|
||||
## [writeStr]
|
||||
|
||||
## [writeMap]
|
||||
s.write ('Mapping', '{')
|
||||
s.write ('One', 1)
|
||||
s.write ('Two', 2)
|
||||
s.write ('Mapping', '}')
|
||||
s.startWriteStruct('Mapping', cv.FileNode_MAP)
|
||||
s.write('One', 1)
|
||||
s.write('Two', 2)
|
||||
s.endWriteStruct()
|
||||
## [writeMap]
|
||||
|
||||
## [iomatw]
|
||||
s.write ('R_MAT', R)
|
||||
s.write ('T_MAT', T)
|
||||
s.write('R_MAT', R)
|
||||
s.write('T_MAT', T)
|
||||
## [iomatw]
|
||||
|
||||
## [customIOw]
|
||||
m.write(s)
|
||||
m.write(s, 'MyData')
|
||||
## [customIOw]
|
||||
## [close]
|
||||
s.release()
|
||||
|
||||
Reference in New Issue
Block a user