Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

boost serialization of opencv types

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/libs/serialization/doc/serialization.html

#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