堆栈溢出

我已经实现了OpenCV Mat格式的序列化,如下所述:序列化OpenCV Mat_ <Vec3f>

我现在遇到了将cv :: Mat的共享指针序列化的问题。 它给出了以下错误:

/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 / /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 :9:

从'void> boost :: serialization :: serialize_adl(存档&,T&,无符号整型)[with Archive => boost :: archive :: text_iarchive,T = boost :: shared_ptr>] / usr / include / boost / archive /detail/iserializer.hpp:188:5:

实例化从'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:从这里实例化

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

我试图使用BOOST_CLASS_TRACKING,但无法使它工作。 其实我并不是真的明白问题是什么,阅读boost文档并没有帮助解决这个问题。


我认为你不能通过shared_ptr序列化,除非指向的对象有一个vtable。 尝试使对象的析构函数为虚拟。

编辑:或者,将对象(OpenCV矩阵?)包装在具有虚拟析构函数的对象中。

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

上一篇: Stack Overflow

下一篇: boost serialization std::unique