修复文字识别api额度不够的问题(精度降低了呜呜呜)

main
lensfrex 3 years ago
parent 22d7efb968
commit 7ae4dcb92b
Signed by: lensfrex
GPG Key ID: 947ADABD8533C476
  1. 12
      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() {

Loading…
Cancel
Save