Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit a8b70a5

Browse files
committed
update read/write methods
1 parent e15f445 commit a8b70a5

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

modules/core/include/opencv2/core.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,13 +3098,13 @@ class CV_EXPORTS_W Algorithm
30983098
*
30993099
* must rename it as it is overloaded in e.g Feature2D
31003100
*/
3101-
CV_WRAP_AS(write2) void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
3101+
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
31023102

31033103
/** @brief Reads algorithm parameters from a file storage
31043104
*
31053105
* bindings: must rename it as it is overloaded in e.g Feature2D
31063106
*/
3107-
CV_WRAP_AS(read2) virtual void read(const FileNode& fn) { (void)fn; }
3107+
CV_WRAP virtual void read(const FileNode& fn) { (void)fn; }
31083108

31093109
/** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
31103110
*/

modules/features2d/include/opencv2/features2d.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,15 @@ class CV_EXPORTS_W Feature2D : public virtual Algorithm
210210

211211
virtual void write( FileStorage&) const;
212212

213-
virtual void read( const FileNode&);
213+
// see corresponding cv::Algorithm method
214+
CV_WRAP virtual void read( const FileNode&);
214215

215216
//! Return true if detector object is empty
216217
CV_WRAP virtual bool empty() const;
217218
CV_WRAP virtual String getDefaultName() const;
219+
220+
// see corresponding cv::Algorithm method
221+
CV_WRAP inline void write(const Ptr<FileStorage>& fs, const String& name = String()) const { Algorithm::write(fs, name); }
218222
};
219223

220224
/** Feature detectors in OpenCV have wrappers with a common interface that enables you to easily switch
@@ -985,7 +989,8 @@ class CV_EXPORTS_W DescriptorMatcher : public Algorithm
985989
read(fs.root());
986990
}
987991
// Reads matcher object from a file node
988-
virtual void read( const FileNode& );
992+
// see corresponding cv::Algorithm method
993+
CV_WRAP virtual void read( const FileNode& );
989994
// Writes matcher object to a file storage
990995
virtual void write( FileStorage& ) const;
991996

@@ -1012,6 +1017,10 @@ class CV_EXPORTS_W DescriptorMatcher : public Algorithm
10121017

10131018
CV_WRAP static Ptr<DescriptorMatcher> create( int matcherType );
10141019

1020+
1021+
// see corresponding cv::Algorithm method
1022+
CV_WRAP inline void write(const Ptr<FileStorage>& fs, const String& name = String()) const { Algorithm::write(fs, name); }
1023+
10151024
protected:
10161025
/**
10171026
* Class to work with descriptors from several images as with one merged matrix.

modules/python/test/test_algorithm_rw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class algorithm_rw_test(NewOpenCVTests):
1111
def test_algorithm_rw(self):
1212
# some arbitrary non-default parameters
1313
gold = cv2.AKAZE_create(descriptor_size=1, descriptor_channels=2, nOctaves=3, threshold=4.0)
14-
gold.write2(cv2.FileStorage("params.yml", 1), "AKAZE")
14+
gold.write(cv2.FileStorage("params.yml", 1), "AKAZE")
1515

1616
fs = cv2.FileStorage("params.yml", 0)
1717
algorithm = cv2.AKAZE_create()
18-
algorithm.read2(fs.getNode("AKAZE"))
18+
algorithm.read(fs.getNode("AKAZE"))
1919

2020
self.assertEqual(algorithm.getDescriptorSize(), 1)
2121
self.assertEqual(algorithm.getDescriptorChannels(), 2)

0 commit comments

Comments
 (0)