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/

相关推荐
xfddlm2 分钟前
边缘计算_ubuntu环境下使用瑞芯微RK3576NPU推理LLM
人工智能·ubuntu·边缘计算
日晨难再20 分钟前
DSO.ai:基于AI的搜索优化型EDA工具介绍
人工智能·数字ic
机器学习之心HML20 分钟前
多光伏电站功率预测新思路:当GCN遇见LSTM,解锁时空预测密码,python代码
人工智能·python·lstm
JarryStudy26 分钟前
HCCL与PyTorch集成 hccl_comm.cpp DDP后端注册全流程
人工智能·pytorch·python·cann
大闲在人39 分钟前
10. 配送中心卡车卸货流程分析:产能利用率与利特尔法则的实践应用
人工智能·供应链管理·智能制造·工业工程
woshikejiaih39 分钟前
**播客听书与有声书区别解析2026指南,适配不同场景的音频
大数据·人工智能·python·音视频
qq74223498441 分钟前
APS系统与OR-Tools完全指南:智能排产与优化算法实战解析
人工智能·算法·工业·aps·排程
兜兜转转了多少年43 分钟前
从脚本到系统:2026 年 AI 代理驱动的 Shell 自动化
运维·人工智能·自动化
LLWZAI1 小时前
十分钟解决朱雀ai检测,AI率为0%
人工智能
无忧智库1 小时前
某市“十五五“智慧气象防灾减灾精准预报系统建设方案深度解读 | 从“看天吃饭“到“知天而作“的数字化转型之路(WORD)
大数据·人工智能