boost serialization of opencv types

asked 2020-10-22 11:27:19 -0600

JT3D gravatar image

Hi guys,

I have the following members of a class (v1 & v2) that I need to serialize to file using boost serialization and then read back in at a later stage.

see this link for what I am following https://www.boost.org/doc/libs/1_55_0...

#include this in the class header 
#include <boost/serialization/vector.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>

//private member variables
std::vector< std::vector<cv::Point3f> > v1;
std::vector< std::vector<cv::Vec6f> > v2;


template<class Archive>
  void serialize(Archive & ar, const unsigned int version)
  {
    ar & v1;
    ar & v2;

  }

In main I have this but I get an error saying I have added a serialize for types cv::Point3f + cv::Vec6f

std::ofstream ofs("test1.txt");
boost::archive::binary_oarchive oa(ofs);
oa << v1;

I'm not sure what to provide for the serialize template part for the types cv::Point3f + cv::Vec6f

Any help or points in the right direction would be appreciated

edit retag flag offensive close merge delete

Comments

get an error saying I have added a serialize for types cv::Point3f + cv::Vec6f

the exact error msg, please

berak gravatar imageberak ( 2020-10-23 02:04:06 -0600 )edit

do you absolutely HAVE TO use boost here ? it'll be a nightmare.

berak gravatar imageberak ( 2020-10-23 06:54:34 -0600 )edit