车牌识别业务测试

master
Miku 1 year ago
parent 043108188c
commit 48aa0beea3

@ -75,5 +75,32 @@ public class BaiDuUtils {
} }
} }
public static void main(String[] args) {
try {
// 使用配置文件中的AppID、API Key和Access Key Secret创建AipOcr客户端
AipOcr client = new AipOcr("37831547", "znwWRqlIGRC8wbD3VhhQtojo", "zseU22B9XbhESFXm5UYGEtEGGLVokGfW");
// 设置连接超时时间为2秒
client.setConnectionTimeoutInMillis(2000);
// 设置Socket超时时间为60秒
client.setSocketTimeoutInMillis(60000);
HashMap<String, String> options = new HashMap<>();
String image = "C:\\Users\\Re11a\\Desktop\\车牌\\ganyu.jpg";
/**
* false
* true
*/
options.put("multi_detect", "true");
// 忽略SSL证书验证
SslUtils.ignoreSsl();
// 调用百度智能AI的车牌识别接口获取识别结果
JSONObject res = client.plateLicense(image, options);
Object result = res.get("words_result");
JSONArray array = JSON.parseArray(result.toString());
com.alibaba.fastjson.JSONObject object = JSON.parseObject(array.get(0).toString());
Object number = object.get("number");
System.out.println("车牌:" + number);
} catch (Exception e) {
e.printStackTrace();
}
}
} }

Loading…
Cancel
Save