Browse Source

增加聊天类型

seyason 5 năm trước cách đây
mục cha
commit
57f372692f

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

@@ -55,6 +55,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     private String browserFolder;
     @Value(value = "${picrecongnize.develop}")
     private String developFolder;
+    @Value(value = "${picrecongnize.im}")
+    private String imFolder;
 
     @Value("classpath:novel_words.data")
     private org.springframework.core.io.Resource novelWords;
@@ -292,7 +294,9 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
 //        }
         File picFile = new File((String)fileMap.get("newFile"));
         System.out.println("File:"+picFile.getAbsolutePath());
-        if (isNovel(textContents)) {
+        if (isIM(picFile) != null) {
+            screenshot.setPicType(9);//聊天
+        } if (isNovel(textContents)) {
             screenshot.setPicType(6);
         } else if (isDocument(textContents)) {
             screenshot.setPicType(2);//看文档
@@ -443,7 +447,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     }
 
     public static void main(String[] args) throws Exception {
-//        String b = isDevelop(new File("C:\\Users\\seya\\Desktop\\wtt.jpg"));
+//        String b = isIM(new File("C:\\Users\\seya\\Desktop\\im.jpg"));
 //        System.out.println("结果:"+b);
     }
 
@@ -540,6 +544,33 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         return null;
     }
 
+    //判断是否是聊天
+    private String isIM(File pic) {
+        File folder = new File(imFolder);
+//        File folder = new File("C:\\picrecongnize\\im\\");
+        if (!folder.exists()) {
+            try {
+                throw new Exception("没有设置图片上传的聊天比对模板库");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        } else {
+            File[] files = folder.listFiles();
+            String toolName = null;
+            boolean isMatch = false;
+            for (File targetPic : files) {
+//                System.out.println("targetPic==" + targetPic.getAbsolutePath());
+                boolean matchPic = ImageReconizeUtil.isWholeTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
+                if (matchPic) {
+                    toolName = targetPic.getName();
+                    break;
+                }
+            }
+            return toolName;
+        }
+        return null;
+    }
+
     /**
      * 判断是否是看文档, 具体类型为word, excel, pdf, ppt
      *

+ 19 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ImageReconizeUtil.java

@@ -35,7 +35,18 @@ public class ImageReconizeUtil {
     }
 
     public static boolean isTemplateMatch(String sourcePic, String targetPic) {
-        double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic);
+        double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic,true);
+        if (Math.abs(matchVal) < YUZHI) {
+            System.out.println("找到啦");
+            return true;
+        } else {
+            System.out.println("没匹配上");
+            return false;
+        }
+    }
+
+    public static boolean isWholeTemplateMatch(String sourcePic, String targetPic) {
+        double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic, false);
         if (Math.abs(matchVal) < YUZHI) {
             System.out.println("找到啦");
             return true;
@@ -59,14 +70,16 @@ public class ImageReconizeUtil {
      * @return: void
      * @date: 2019年5月7日12:16:55
      */
-    public static double templete(int method, String sourcePic, String targetPic) {
+    public static double templete(int method, String sourcePic, String targetPic, boolean cutMatch) {
         // 1 获取待匹配图片
 //        System.out.println("sourcePic="+sourcePic+", targetPic="+targetPic);
         Mat templete=Imgcodecs.imread(sourcePic);
-        //先裁减,左上角1/4的截图,提高比对速度。
-        Rect rect = new Rect(0,0,templete.width()/4, templete.height()/4);
-        Mat subMat = new Mat(templete, rect);
-        subMat.copyTo(templete);
+        if (cutMatch) {
+            //先裁减,左上角1/4的截图,提高比对速度。
+            Rect rect = new Rect(0,0,templete.width()/4, templete.height()/4);
+            Mat subMat = new Mat(templete, rect);
+            subMat.copyTo(templete);
+        }
 
         //将rgb灰化处理
 //        Imgproc.cvtColor(templete, templete,Imgproc.COLOR_BGR2GRAY);

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-dev.yml

@@ -83,7 +83,7 @@ upload:
 picrecongnize:
   browser: E:/picrecongnize/browser/
   develop: E:/picrecongnize/develop/
-
+  im: E:/picrecongnize/im/
 
 
 

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-prod.yml

@@ -84,6 +84,7 @@ upload:
 picrecongnize:
   browser: /www/webapps/worktime/picrecongnize/browser/
   develop: /www/webapps/worktime/picrecongnize/develop/
+  im: /www/webapps/worktime/picrecongnize/im/
 
 
 

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml

@@ -84,5 +84,6 @@ upload:
 picrecongnize:
   browser: C:/picrecongnize/browser/
   develop: C:/picrecongnize/develop/
+  im: C:/picrecongnize/im/