【发布时间】:2016-01-30 17:51:48
【问题描述】:
使用 open cv 我得到cv::Mat 格式的描述符。转换
cv::Mat 到 stringstream 正在发生这种方法:
/// Serialize a cv::Mat to a stringstream
stringstream serialize(Mat input)
{
// We will need to also serialize the width, height, type and size of the matrix
int width = input.cols;
int height = input.rows;
int type = input.type();
size_t size = input.total() * input.elemSize();
// Initialize a stringstream and write the data
stringstream ss;
ss.write((char*)(&width), sizeof(int));
ss.write((char*)(&height), sizeof(int));
ss.write((char*)(&type), sizeof(int));
ss.write((char*)(&size), sizeof(size_t));
// Write the whole image data
ss.write((char*)input.data, size);
return ss;
}
现在我想将此stringstream 转换为base64 编码。如何
以直接的方式使其成为可能。
【问题讨论】:
-
我通常使用this piece of code来进行base64编码/编码。但是你不能只发送 YAML/XML 吗?
-
另外,在您的序列化中,您应该注意图像不连续的情况。查看here 以供参考,
matwrite方法 -
但我提到了他们提到 base 64 是最佳选择的帖子。这就是为什么要转换.. 哪个是最好的.. xml 或 yaml 或 base64 ???
-
我只想将描述符(cv::Mat 格式)发送到网络服务器.. 请建议.. 我正在使用 opencv 3.0
-
您好,我只是想将 stringstream 格式转换为 base64 编码.. 但您提到了从字符串到 base64 的转换..
标签: c++ ios objective-c opencv