| 
						
						
						
					 | 
					 | 
					@ -1,7 +1,6 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package me.lensferno.dogename.utils.ocr; | 
					 | 
					 | 
					 | 
					package me.lensferno.dogename.utils.ocr; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.baidu.aip.ocr.AipOcr; | 
					 | 
					 | 
					 | 
					import com.baidu.aip.ocr.AipOcr; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.google.gson.Gson; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.json.JSONArray; | 
					 | 
					 | 
					 | 
					import org.json.JSONArray; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.json.JSONObject; | 
					 | 
					 | 
					 | 
					import org.json.JSONObject; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -18,16 +17,16 @@ public class OcrTool { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    String result; | 
					 | 
					 | 
					 | 
					    String result; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int resultNum=0; | 
					 | 
					 | 
					 | 
					    int resultNum=0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public boolean requestOcrAPI(String imageFileLocation){ | 
					 | 
					 | 
					 | 
					    public void requestOcrAPI(String imageFileLocation){ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        JSONObject respondJSON=client.accurateGeneral(imageFileLocation, new HashMap<>()); | 
					 | 
					 | 
					 | 
					        JSONObject respondJSON=client.basicGeneral(imageFileLocation, new HashMap<>()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (respondJSON==null){ | 
					 | 
					 | 
					 | 
					        if (respondJSON==null){ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            result="错误:返回了空的数据。"; | 
					 | 
					 | 
					 | 
					            result="错误:返回了空的数据。"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return false; | 
					 | 
					 | 
					 | 
					            return; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if(!respondJSON.has("words_result")){ | 
					 | 
					 | 
					 | 
					        if(!respondJSON.has("words_result")){ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            String errorCode=respondJSON.get("error_code").toString(); | 
					 | 
					 | 
					 | 
					            String errorCode=respondJSON.get("error_code").toString(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            result=findErrorMsg(errorCode); | 
					 | 
					 | 
					 | 
					            result=findErrorMsg(errorCode); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return false; | 
					 | 
					 | 
					 | 
					            return; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        resultNum=respondJSON.getInt("words_result_num"); | 
					 | 
					 | 
					 | 
					        resultNum=respondJSON.getInt("words_result_num"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        System.out.println("total result:"+resultNum); | 
					 | 
					 | 
					 | 
					        System.out.println("total result:"+resultNum); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -39,9 +38,6 @@ public class OcrTool { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            stringBuffer.append(resultArray.getJSONObject(i).getString("words")).append("\n"); | 
					 | 
					 | 
					 | 
					            stringBuffer.append(resultArray.getJSONObject(i).getString("words")).append("\n"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        result=stringBuffer.toString(); | 
					 | 
					 | 
					 | 
					        result=stringBuffer.toString(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return true; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public String getResult() { | 
					 | 
					 | 
					 | 
					    public String getResult() { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |