From 7ae4dcb92bf5323f9c24329d833aa1e77ba59358 Mon Sep 17 00:00:00 2001 From: lensferno Date: Sun, 22 Aug 2021 17:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E5=AD=97=E8=AF=86?= =?UTF-8?q?=E5=88=ABapi=E9=A2=9D=E5=BA=A6=E4=B8=8D=E5=A4=9F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=88=E7=B2=BE=E5=BA=A6=E9=99=8D=E4=BD=8E?= =?UTF-8?q?=E4=BA=86=E5=91=9C=E5=91=9C=E5=91=9C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/lensferno/dogename/utils/ocr/OcrTool.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java b/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java index d1ccf68..a2b76b8 100644 --- a/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java +++ b/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java @@ -1,7 +1,6 @@ package me.lensferno.dogename.utils.ocr; import com.baidu.aip.ocr.AipOcr; -import com.google.gson.Gson; import org.json.JSONArray; import org.json.JSONObject; @@ -18,16 +17,16 @@ public class OcrTool { String result; int resultNum=0; - public boolean requestOcrAPI(String imageFileLocation){ - JSONObject respondJSON=client.accurateGeneral(imageFileLocation, new HashMap<>()); + public void requestOcrAPI(String imageFileLocation){ + JSONObject respondJSON=client.basicGeneral(imageFileLocation, new HashMap<>()); if (respondJSON==null){ result="错误:返回了空的数据。"; - return false; + return; } if(!respondJSON.has("words_result")){ String errorCode=respondJSON.get("error_code").toString(); result=findErrorMsg(errorCode); - return false; + return; } resultNum=respondJSON.getInt("words_result_num"); System.out.println("total result:"+resultNum); @@ -39,9 +38,6 @@ public class OcrTool { stringBuffer.append(resultArray.getJSONObject(i).getString("words")).append("\n"); } result=stringBuffer.toString(); - - return true; - } public String getResult() {