OpenCV Persistance Operations (C++ Gurus?)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenCV Persistance Operations (C++ Gurus?)

Kai Ritterbusch
Hey all,

I planned to adapt the way OpenCV stores its parameters to YML/XML for my application. I have classes that consist of OpenCV data types, and I want to be able to write and read them using the operator<< / operator>>.

I came up with defining a function

static inline cv::FileStorage& operator<<( cv::FileStorage& fs, const MyType& MyData);

but this way I loose some nice features, like

std::vector<MyType> MyVector;

fs << "[" << MyVector << "]";

doesnt work.

Anybody here able to help? The internals of the OpenCV persitance operators confuse me a bit.

Thx in advance

Reply | Threaded
Open this post in threaded view
|

Re: OpenCV Persistance Operations (C++ Gurus?)

stackframe@ymail.com


I have been trying to get persistence to work with a class I defined myself. I haven't had much luck. However, from what I can tell, you don't need to create your own operator << method. Create a method with this signature:

void write(cv::FileSToreage&, std::string&, const MyClass&)


OpenCV will call this method.
Of course, you will also need a read method to read it back in.

--- In [hidden email], "kairitterbusch" <phen@...> wrote:

>
> Hey all,
>
> I planned to adapt the way OpenCV stores its parameters to YML/XML for my application. I have classes that consist of OpenCV data types, and I want to be able to write and read them using the operator<< / operator>>.
>
> I came up with defining a function
>
> static inline cv::FileStorage& operator<<( cv::FileStorage& fs, const MyType& MyData);
>
> but this way I loose some nice features, like
>
> std::vector<MyType> MyVector;
>
> fs << "[" << MyVector << "]";
>
> doesnt work.
>
> Anybody here able to help? The internals of the OpenCV persitance operators confuse me a bit.
>
> Thx in advance
>


Reply | Threaded
Open this post in threaded view
|

Re: OpenCV Persistance Operations (C++ Gurus?)

Francisco Ares
Hi

I hope this might be of use:

http://opencv.itseez.com/modules/core/doc/xml_yaml_persistence.html

Best regards
Francisco

--
"If you have an apple and I have an apple and we exchange apples then you
and I will still each have one apple. But if you have an idea and I have
one idea and we exchange these ideas, then each of us will have two ideas."
- George Bernard Shaw
Reply | Threaded
Open this post in threaded view
|

Re: OpenCV Persistance Operations (C++ Gurus?)

Kai Ritterbusch
In reply to this post by stackframe@ymail.com
thanks for that, will try :)



--- In [hidden email], "stackframe@..." <stackframe@...> wrote:

>
>
>
> I have been trying to get persistence to work with a class I defined myself. I haven't had much luck. However, from what I can tell, you don't need to create your own operator << method. Create a method with this signature:
>
> void write(cv::FileSToreage&, std::string&, const MyClass&)
>
>
> OpenCV will call this method.
> Of course, you will also need a read method to read it back in.
>
> --- In [hidden email], "kairitterbusch" <phen@> wrote:
> >
> > Hey all,
> >
> > I planned to adapt the way OpenCV stores its parameters to YML/XML for my application. I have classes that consist of OpenCV data types, and I want to be able to write and read them using the operator<< / operator>>.
> >
> > I came up with defining a function
> >
> > static inline cv::FileStorage& operator<<( cv::FileStorage& fs, const MyType& MyData);
> >
> > but this way I loose some nice features, like
> >
> > std::vector<MyType> MyVector;
> >
> > fs << "[" << MyVector << "]";
> >
> > doesnt work.
> >
> > Anybody here able to help? The internals of the OpenCV persitance operators confuse me a bit.
> >
> > Thx in advance
> >
>