Преглед изворни кода

修改百度识别接口,提高娱乐的算法识别率

seyason пре 5 година
родитељ
комит
54a3298e71

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -528,9 +528,10 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     public static boolean isDocument(List<String> textContents) {
         boolean find = false;
         for (int i = 0; i < textContents.size() && i <= 2; i++) {//出现在前三行
-            String text = textContents.get(i);
+            String text = textContents.get(i).trim();
             if (text.endsWith("Word")
                     || text.endsWith("Excel")
+                    || text.endsWith("Ecel")
                     || text.endsWith("Power Point")
                     || text.endsWith("Adobe Reader")) {
                 find = true;

+ 9 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/CheckPicUtil.java

@@ -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);

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ImageCompare.java

@@ -83,7 +83,7 @@ public class ImageCompare {
         for (MatOfPoint matOfPoint : mat2_list)
         {
             Rect rect = Imgproc.boundingRect(matOfPoint);
-            if (rect.width >= 280 && rect.height >= 280) {
+            if ((rect.width >= 640 && rect.height >= 480) || (rect.width >= 480 && rect.height >= 640)) {
 //                System.out.println("位置==["+rect.x +","+ rect.y+"], 大小=" +rect.width+"x"+rect.height+", 包含点=" + matOfPoint.toList().size());
                 Imgproc.rectangle(mat_result1, rect.tl(), rect.br(), new Scalar(0, 0, 255),2);
                 Imgproc.rectangle(mat_result2, rect.tl(), rect.br(), new Scalar(0, 0, 255),2);