{"data":{"logId":"151686949973381"},"error_code":216201,"error_msg":"image format error"}
我的代码 图片是jpg
imageBase64 = ImageUtil.getBase64FromFile(imgPath);
imageBase64 = URLEncoder.encode(imageBase64,"UTF-8");
new HttpBuilder("https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise")
.params("access_token", access_token)
.params("image", imageBase64)//base64
.params("templateSign", "0a2f99be773df5afb746244d4e8b26be")
// .contentType("application/x-www-form-urlencoded;charset=utf-8")
.ObPost()
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
你这是什么语言呀?
QQ群 570832882,在文档的下方也有的
我是在app中使用
public static String getBase64FromFile(String path) throws Exception {
File file = new File(path);
FileInputStream inputFile = null;
inputFile = new FileInputStream(file);
byte[] buffer = new byte[(int) file.length()];
inputFile.read(buffer);
inputFile.close();
return Base64.encodeToString(buffer, Base64.DEFAULT);
}
Map params = new HashMap<>();
params.put("access_token", access_token);
params.put("templateSign", "0a2f99be773df5afb746244d4e8b26be");
try {
imageBase64 = ImageUtil.getBase64FromFile(imgPath);
params.put(URLEncoder.encode("image", "UTF-8"), URLEncoder.encode(imageBase64, "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
String url = "https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise";
new HttpBuilder(url)
.params(params)
.ObPost()
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable throwable) {
}
@Override
public void onNext(String result) {
Log.e("OcrHelp", "登记证书识别:" + result);
}
});
文字识别群是多少呢
能贴一下完整的代码看一下吗?或者参照一下论坛里的例子
http://ai.baidu.com/forum/topic/show/497513
再或者,现在java有SDK可以使用