|
@@ -92,7 +92,7 @@ public class CheckPicUtil {
|
|
|
*/
|
|
|
public static Map<String,Object> generalPicTextContentMap (String path,String token) {
|
|
|
// 请求url
|
|
|
- String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general";
|
|
|
+ String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic";
|
|
|
try {
|
|
|
// 本地文件路径
|
|
|
String filePath = path;
|
|
@@ -109,12 +109,15 @@ public class CheckPicUtil {
|
|
|
List<String> wordsList = new ArrayList<>();
|
|
|
JSONObject object = JSONArray.parseObject(result);
|
|
|
JSONArray resultArray = object.getJSONArray("words_result");
|
|
|
- for (int i = 0; i < resultArray.size(); i++) {
|
|
|
- JSONObject json = resultArray.getJSONObject(i);
|
|
|
- String words = (String)json.get("words");
|
|
|
- System.out.println("words"+i+":"+words);
|
|
|
- wordsList.add(words);
|
|
|
+ if (resultArray != null) {//超过上限会返回错误json数据,{"error_code":17,"error_msg":"Open api daily request limit reached"}
|
|
|
+ for (int i = 0; i < resultArray.size(); i++) {
|
|
|
+ JSONObject json = resultArray.getJSONObject(i);
|
|
|
+ String words = (String)json.get("words");
|
|
|
+ System.out.println("words"+i+":"+words);
|
|
|
+ wordsList.add(words);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
System.out.println(wordsList);
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("wordsList",wordsList);
|