diff --git a/src/main/java/com/smart/module/car/util/BaiDuUtils.java b/src/main/java/com/smart/module/car/util/BaiDuUtils.java index 6bb208c..ac6b9f7 100644 --- a/src/main/java/com/smart/module/car/util/BaiDuUtils.java +++ b/src/main/java/com/smart/module/car/util/BaiDuUtils.java @@ -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 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(); + } + } }