3 Star 1 Fork 2

zpfly/devices

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
demo_idcard.cc 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
Ming Wang 提交于 2023-05-26 20:44 . idcard and demo
#include "devices.h"
#include "idcard/idcard.h"
#include <fstream>
using namespace std;
int main()
{
char buf[512];
const char *info = idcard::getInfo();
printf("%s\n", info);
idcard::init();
int n = idcard::getIDCardData(0, buf, 512);
if (0 != n)
printf ("Error: %d\n", n);
else
printf("%s\n", buf);
idcard::getIDCardData(1, buf, 64);
printf("姓名: %s\n", buf);
idcard::getIDCardData(2, buf, 16);
printf("性别: %s\n", buf);
idcard::getIDCardData(3, buf, 128);
printf("民族: %s\n", buf);
idcard::getIDCardData(4, buf, 16);
printf("出生年: %s\n", buf);
idcard::getIDCardData(5, buf, 16);
printf("出生月: %s\n", buf);
idcard::getIDCardData(6, buf, 16);
printf("出生日: %s\n", buf);
idcard::getIDCardData(7, buf, 256);
printf("住址: %s\n", buf);
idcard::getIDCardData(8, buf, 64);
printf("公民身份号码: %s\n", buf);
idcard::getIDCardData(9, buf, 256);
printf("签发机关: %s\n", buf);
idcard::getIDCardData(10, buf, 16);
printf("起始年: %s\n", buf);
idcard::getIDCardData(11, buf, 16);
printf("起始月: %s\n", buf);
idcard::getIDCardData(12, buf, 16);
printf("起始日: %s\n", buf);
idcard::getIDCardData(13, buf, 16);
printf("截止年: %s\n", buf);
idcard::getIDCardData(14, buf, 16);
printf("截止月: %s\n", buf);
idcard::getIDCardData(15, buf, 16);
printf("截止日: %s\n", buf);
idcard::getIDCardData(16, buf, 64);
printf("芯片序列号: %s\n", buf);
const char *fpath = "/tmp/id.bmp.b64";
char *buff = nullptr;
int len = 0;
n = idcard::getIDCardImages(1, &buff, len);
ofstream out(fpath, ios::out);
if (out.is_open()) {
out << buff << endl;
out.close();
}
delete [] buff;
printf("base64 data in file %s , lenngth: %d\n", fpath, len);
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zpflying/devices.git
git@gitee.com:zpflying/devices.git
zpflying
devices
devices
master

搜索帮助