Eigen - 如何创建最小的序列化 MatrixXf
Eigen - How to create the smallest serialized MatrixXf
我正在通过与此类似的代码将相对较大的MatrixXf序列化为文件 - https://github.com/github188/vidy_old/blob/01c0aa4242299f7f1056edf0aa60b92177dfcfe6/3rdparty/openbr/core/eigenutils.h
当我使用 Qt 执行此操作时,它会根据矩阵创建 3-30MB 的文件。
如果节省空间是我的#1目标,我可以考虑做哪些事情?
- 是否有另一种形式的序列化,我希望看到更小的文件大小? (我可能会尝试提升以查看其有何不同 - https://gist.github.com/ShigekiKarita/4db2b0ffb207322c1324(
- 似乎序列化矩阵可以压缩一点,如果我能忍受浮点精度的小数位较少,这样它就不必在磁盘上存储那么多。 有谁知道这样的技术?
谢谢,
饶
Boost 序列化与压缩一起使用 Boost 的 iostream 过滤应该会为您提供一个灵活的解决方案,文件大小较小。
Boost 序列化的binary_archive非常紧凑,并允许文件版本控制,这可能很方便。
独立于您使用的序列化,boost 提供过滤流,其工作方式与常规 istream 和 ostream 完全相同,但会动态添加压缩。您可以简单地将示例中的流替换为过滤后的流,并且应该具有工作压缩。
http://www.boost.org/doc/libs/1_64_0/libs/iostreams/doc/classes/gzip.html
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
int main()
{
using namespace std;
ifstream file("hello.gz", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(gzip_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}
相关文章:
- 如何在C++中序列化结构数据
- 序列化,没有库的整数,得到奇怪的结果
- 如何知道QDataStream不能反序列化某些内容
- 如何使用Python从C++中读取谷物序列化数据
- 如何使用boost::具有嵌套结构和最小代码更改的序列化
- 带有Protobuf序列化的C++Hazelcast:字符串不是UTF-8格式的
- 自定义对象的dlib序列化在gcc中失败
- C++boost序列化多态性问题
- 增强基于 XML class_id的反序列化
- 提升反序列化对象具有 nan 或 -nan 值
- 在 cpp 中的平面缓冲区中序列化对象
- 每次进行继承时都需要提升::序列化::base_object吗?
- 如何在 c++ 非托管代码中反序列化 byte[] 的 json 字符串?
- 提升序列化 1:73 的向后兼容性问题
- 将 boost 序列化对象的 asio::streambuf 表示转换为 Beast 的 DynamicBody req.body()
- 为什么 nlohmann/json 序列化 "null" 而不是在 double 上"0"?
- 如何反序列化数组?
- 如何使用提升序列化?
- 序列化多晶型接口
- Eigen - 如何创建最小的序列化 MatrixXf