stringstream到base64进行编码并将其发送到服务器ios
stringstream to base64 encode and send it to the server ios
使用打开的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编码的。如何使之成为可能的直接方法。
您可以对stringstream
获得的string
进行编码,如:
Mat m;
...
std::string s = serialize(m).str();
std::string encoded = base64_encode(s.c_str());
// send "encoded" to server
例如,可以在此处找到base64_encode
的代码。
相关文章:
- 使用ios:ate写入到流会覆盖现有文件
- "unknown ca"自生成的 CA、证书和客户端/服务器
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 如何通过套接字将文本文件的内容从服务器发送到客户端
- 有没有办法知道Tracer是否成功地完全连接到了jaegerclientcpp中的jaeger后端服务器
- 从服务器传输到客户端的消息不会出现
- 如何访问RTCVideoRenderer的帧?(ios)
- QTcpSocket在不阻塞GUI的情况下重新连接到服务器
- OpenSSL TLS服务器-使用客户端证书白名单
- 我正在开发服务器,ip作为参数传递不起作用
- ios::fmtflags 在 C++ 中是如何工作的?setf() 是如何工作的?
- 我可以与 python 服务器而不是 c++ 客户端建立 tcp/ip 套接字吗?
- 提升 Asio TCP 服务器 处理多个客户端
- 我可以在 iOS 或 mac 应用程序中使用C++代码吗?
- 如何在 Minecraft 服务器上执行命令
- 调试编译的服务器在数据库打开时崩溃
- "string.h"在构建适用于iOS的qt应用程序中找不到消息
- 使用C++创建UDP服务器以嵌入跨平台iOS和Android应用程序中
- 将移动设备(iOS和Android)连接到带有QT / C++和镜像显示的VNC服务器
- stringstream到base64进行编码并将其发送到服务器ios