调用方法:
String accessToken = instance();
System.out.println(accessToken);
//接口地址
String iocrurl = "https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise";
//自定义模块templateSign
String templateSign = "ed7e75975a4205e4c769b873adc30e67";
//获取图片的base64数据 先获取图片的数组数据再进行base64 编码
byte[] imgaebinary;
try {
imgaebinary = ImageUtil.readImageFile("/text/test.png");
String imagebase64 = Base64Util.encode(imgaebinary);
//拼接接口所需参数 image参数需要urlencode哦
String param = "image="+URLEncoder.encode(imagebase64,"UTF-8")+"&templateSign="+templateSign;
//开始请求接口
String result = BaiDuHttpUtil.post(iocrurl, accessToken, param);
//输出接口返回的内容
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
返回数据如下展示:
{
"data":{
"isStructured":false,
"logId":"152471158188325"
},
"error_code":2,
"error_msg":"Service temporarily unavailable"
}
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
+1 这个问题PHP也出现了,还没解决吗
你好,谢谢反馈。
最近服务不稳定的问题,我们已经观察到,并且已经反馈给技术团队,他们正在全力解决这个问题。