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/

相关推荐
亚马逊云开发者1 天前
Q CLI 助力合合信息实现 Aurora 的升级运营
人工智能
全栈胖叔叔-瓜州1 天前
关于llamasharp 大模型多轮对话,模型对话无法终止,或者输出角色标识User:,或者System等角色标识问题。
前端·人工智能
坚果派·白晓明1 天前
AI驱动的命令行工具集x-cmd鸿蒙化适配后通过DevBox安装使用
人工智能·华为·harmonyos
GISer_Jing1 天前
前端营销技术实战:数据+AI实战指南
前端·javascript·人工智能
Dekesas96951 天前
【深度学习】基于Faster R-CNN的黄瓜幼苗智能识别与定位系统,农业AI新突破
人工智能·深度学习·r语言
大佐不会说日语~1 天前
Spring AI Alibaba 的 ChatClient 工具注册与 Function Calling 实践
人工智能·spring boot·python·spring·封装·spring ai
CeshirenTester1 天前
Playwright元素定位详解:8种定位策略实战指南
人工智能·功能测试·程序人生·单元测试·自动化
棒棒的皮皮1 天前
【OpenCV】Python图像处理几何变换之翻转
图像处理·python·opencv·计算机视觉
无能者狂怒1 天前
YOLO C++ Onnx Opencv项目配置指南
c++·opencv·yolo
劈星斩月1 天前
OpenCV 学习9-灰度转黑白二值图像
opencv·转二值图像·threshold函数