腾讯云提供的识别有两种方式:
1.ImageBase64
2.ImageUrl
两种都可以用,我们这里采用第一种方式:
首先写个方法,我们需要将上传的图片转换成base64格式:
public static String getBase64FromInputStream(InputStream in) {
// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
byte[] data = null;
// 读取图片字节数组
try {
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
while ((rc=in.read(buff, 0, 100)) > 0){
swapStream.write(buff, 0, rc);
}
data = swapStream.toByteArray();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return new String(Base64.encodeBase64(data));
}
然后,在controlle

本文介绍了如何使用腾讯云的身份证识别接口。通过ImageBase64的方式,将上传的图片转换为base64格式,并在后台controller层调用官方文档提供的方法。最终实现了在前端上传身份证照片并获取识别信息的功能。
最低0.47元/天 解锁文章
2597

被折叠的 条评论
为什么被折叠?



