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/

相关推荐
Blossom.11811 小时前
把AI“绣”进丝绸:生成式刺绣神经网络让古装自带摄像头
人工智能·pytorch·python·深度学习·神经网络·机器学习·fpga开发
大力财经11 小时前
百度搜索开启公测AI短剧平台,将投入亿元基金、百亿流量扶持创作者
人工智能
RPA中国11 小时前
谷雨互动赵乾坤 | AI答案时代生存法则:从流量变迁到GEO实践
人工智能
paopaokaka_luck11 小时前
基于SpringBoot+Vue的数码交流管理系统(AI问答、协同过滤算法、websocket实时聊天、Echarts图形化分析)
vue.js·人工智能·spring boot·websocket·echarts
arron889912 小时前
Visual Studio 2017(VS2017)可以编译 OpenCV 4.5.5 为 32 位(x86)版本
ide·opencv·visual studio
youngfengying12 小时前
身体活动(physical activity)---深度学习
人工智能·深度学习
START_GAME12 小时前
语音合成系统---IndexTTS2:环境配置与实战
人工智能·语音识别
2501_9307992412 小时前
访答知识库#Pdf转word#人工智能#Al编辑器#访答RAG#企业知识库,个人知识库,本地知识库,访答编辑器,访答浏览器……
人工智能
max50060012 小时前
多GPU数据并行训练中GPU利用率不均衡问题深度分析与解决方案
人工智能·机器学习·分类·数据挖掘