Stack Overflow

I've implemented serialization for OpenCVs Mat format as described here: Serializing OpenCV Mat_<Vec3f>

I now got the problem to serialize a shared pointer to a cv::Mat. It gives the following errors:

/usr/include/boost/serialization/shared_ptr.hpp: In function 'void boost::serialization::serialize(Archive&, boost::shared_ptr<U>&, unsigned int) [with Archive = boost::archive::text_iarchive, T = boost::shared_ptr<cv::Mat>]': /usr/include/boost/serialization/serialization.hpp:128:9 :

instantiated from 'void >boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = >boost::archive::text_iarchive, T = boost::shared_ptr >]' /usr/include/boost/archive/detail/iserializer.hpp:188:5:

instantiated from 'void >boost::archive::detail::iserializer::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned int) const [with Archive = boost::archive::text_iarchive, T = boost::shared_ptr >]' recognition2d3d.cpp:227:1: instantiated from here

/usr/include/boost/serialization/shared_ptr.hpp:167:5: error: static assertion failed: "boost::serialization::tracking_level< T >::value != boost::serialization::track_never"`

I tried to use BOOST_CLASS_TRACKING, but could not get it working. Actually i don't really understand what the problem is, reading the boost documentation didn't help to solve this issue.


I think you can't serialize through a shared_ptr unless the object pointed to has a vtable. Try making the object's destructor virtual.

Edit: alternatively, wrap the object (an OpenCV matrix?) in an object that has a virtual destructor.

链接地址: http://www.djcxy.com/p/62918.html

上一篇: boost序列化未定义的参考

下一篇: 堆栈溢出