1.首先购买阿里云ocr识别接口.
2.控制台中点击 [api网关]
3.点击应用名称进入
4.以身份证ocr为例子在购买页面查看代码示例链接如下:
阿里云身份证ocr代码示例
即可看见对应语言的代码示例
5.本人代码示例
public Result<?> requestAlibaba(String host, String path, AliYunOcrCommonDto entityDTO, Object entityObj) {
try {
// 请根据线上文档修改configure字段
JSONObject configObj = new JSONObject();
configObj.put(OCR_SIDE, entityDTO.getFaceOrBack());
String configStr = configObj.toString();
Map<String, String> headers = requestHeaderMap();
Map<String, String> query = new HashMap<String, String>(1);
// 对图像进行base64编码
String imgBase64 = imgBase64(entityDTO.getImgFile());
// 拼装请求body的json字符串
JSONObject requestObj = new JSONObject();
try {
requestObj.put(OCR_IMAGE, imgBase64);
if (configStr.length() > 0) {
requestObj.put