opencv编解码base64字符串

cpp-base64代码地址:
https://github.com/ReneNyffenegger/cpp-base64

下载仓库,并将base64.h,Base64.cpp 加入代码中,

将Mat对象编码为base64字符串

cpp 复制代码
Mat img= imread("xxx.png");
std::vector<uchar> buf;
cv::imencode(".png", img, buf);
auto *data_ptr = reinterpret_cast<unsigned char*>(buf.data());
std::string encode_str = base64_encode(data_ptr, buf.size());
std::cout <<"base64: " encode_str << std::endl;

将base64解码为Mat对象

cpp 复制代码
string dec_str = base64_decode(encode_str);
std::vector<uchar> data(dec_str.begin(), dec_str.end());
cv::Mat image = cv::imdecode(cv::Mat(data), 1);

参考:
https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp/

相关推荐
kkce25 分钟前
vsping 推出海外检测节点的核心目的
大数据·网络·人工智能
bin915325 分钟前
当AI优化搜索引擎算法:Go初级开发者的创意突围实战指南
人工智能·算法·搜索引擎·工具·ai工具
人工智能技术咨询.35 分钟前
深度学习—卷积神经网络
人工智能
机器之心36 分钟前
Manus被收购,智谱也定了8天后上市
人工智能·openai
王中阳Go1 小时前
手把手教你用 Go + Eino 搭建一个企业级 RAG 知识库(含代码与踩坑)
人工智能·后端·go
Coder个人博客1 小时前
Llama.cpp 整体架构分析
人工智能·自动驾驶·llama
江上鹤.1481 小时前
Day 50 CBAM 注意力机制
人工智能·深度学习
deephub1 小时前
大规模向量检索优化:Binary Quantization 让 RAG 系统内存占用降低 32 倍
人工智能·大语言模型·向量检索·rag
人工智能培训1 小时前
深度学习—卷积神经网络(1)
人工智能·深度学习·神经网络·机器学习·cnn·知识图谱·dnn
ㄣ知冷煖★1 小时前
【Google系列】AI智能体技术白皮书
人工智能·agent