From b6c195d44ced676762fad805aa10ea0a6b9e06f9 Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Wed, 1 Jun 2011 10:05:11 +0000 Subject: [PATCH] Fixed reading of the user class from *.xml (ticket #840). --- modules/core/include/opencv2/core/operations.hpp | 5 ++++- samples/cpp/filestorage.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 87e6ad8..71329db 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -2828,7 +2828,10 @@ FileNodeIterator& operator >> (FileNodeIterator& it, vector<_Tp>& vec) } template static inline void operator >> (const FileNode& n, _Tp& value) -{ FileNodeIterator it = n.begin(); it >> value; } +{ read( n, value, _Tp()); } + +template static inline void operator >> (const FileNode& n, vector<_Tp>& vec) +{ FileNodeIterator it = n.begin(); it >> vec; } static inline bool operator == (const FileNodeIterator& it1, const FileNodeIterator& it2) { diff --git a/samples/cpp/filestorage.cpp b/samples/cpp/filestorage.cpp index b7c8575..0dffef8 100644 --- a/samples/cpp/filestorage.cpp +++ b/samples/cpp/filestorage.cpp @@ -59,7 +59,7 @@ void read(const FileNode& node, MyData& x, const MyData& default_value = MyData( if(node.empty()) x = default_value; else - x = (MyData)node; + x.read(node); } ostream& operator<<(ostream& out, const MyData& m){ -- 2.7.4