Parcourir la source

娱乐电影识别

seyason il y a 5 ans
Parent
commit
60da4f982b

+ 58 - 162
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -56,8 +56,10 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
 
     @Value(value = "${upload.path}")
     private String path;
-    @Value(value = "${picrecongnize.path}")
-    private String picrecongnizeFolder;
+    @Value(value = "${picrecongnize.browser}")
+    private String browserFolder;
+    @Value(value = "${picrecongnize.develop}")
+    private String developFolder;
 
     @Value("classpath:novel_words.data")
     private org.springframework.core.io.Resource novelWords;
@@ -155,61 +157,33 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
             members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
         }
-
+        File picFile = new File((String)fileMap.get("newFile"));
         if (isNovel(textContents)) {
             screenshot.setPicType(6);
         } else if (isDocument(textContents)) {
             screenshot.setPicType(2);//看文档
-        } else {
-            List<String> exeprocessList = new ArrayList<String>();
-            if ("Q_OS_WIN".equals(screenshotvo.getOsType())) {
-                exeprocessList = ProcessUtil.getWinExeprocessListfromProcessStr(screenshotvo.getProcessList());
-            } else if ("Q_OS_LINUX".equals(screenshotvo.getOsType())
-                        ||"Q_OS_MAC".equals(screenshotvo.getOsType())) {
-                exeprocessList = ProcessUtil.getWinExeprocessListfromProcessStr(screenshotvo.getProcessList());
-            } else {
-                HttpRespMsg msg = new HttpRespMsg();
-                msg.setError("请求缺少操作系统类型, 只支持Q_OS_WIN,Q_OS_LINUX, Q_OS_MAC ");
-                return msg;
-            }
-
-            boolean derail = false;//判断是否匹配的开关
-            Integer lastType = null;
-            for (String textContent : textContents) {
-                for (Object member : members) {
-                    //由于redis里存储的member是一个PicContentKeywords类型的json字符串,所以取出关键字内容比较
-                    JSONObject jsonMember = JSON.parseObject((String) member);
-                    if (textContent.toLowerCase().contains(jsonMember.getString("content").toLowerCase())) {
-                        log.info("图片文字中包含了关键词--->" + jsonMember.getString("content"));
-                        log.info("图片文字识别出的类型--->" + jsonMember.getInteger("type"));
-                        //找到对应关键字,确定图片是哪个类型的图片
-                        //结合进程判断
-                        if (exeprocessList.contains(jsonMember.getString("processName").toLowerCase())) {
-                            if (!derail) {
-                                //判断是否是第一次匹配
-                                log.info("图片中关键字对应的进程名--->" + jsonMember.getString("processName"));
-                                screenshot.setPicType(jsonMember.getInteger("type"));
-                                lastType = jsonMember.getInteger("type");
-                                derail = true;
-                            } else {
-                                if (0 == lastType) {
-                                    //软件开发为主
-                                    break;
-                                } else {
-                                    screenshot.setPicType(jsonMember.getInteger("type"));
-                                    lastType = jsonMember.getInteger("type");
-                                }
-                            }
-                        }
-                    }
-                }
-            }
+        } else if (isDevelop(picFile) != null) {//开发
+            screenshot.setPicType(7);
         }
         screenshot.setIsHandle(1);
         if (screenshot.getPicType() == null) {
             //判断是否是娱乐:看电影, 打游戏
-            if (isEntertainment(new File((String)fileMap.get("newFile")))) {
-                screenshot.setPicType(7);
+            String uid = screenshotvo.getUid();
+            Screenshot preShot = screenshotMapper.selectOne(new QueryWrapper<Screenshot>().eq("uid", uid).orderByDesc("indate").last("limit 1"));
+            if (preShot != null) {
+                String prePath = path + preShot.getPicUrl().substring(preShot.getPicUrl().lastIndexOf("/"));
+                File f = new File(prePath);
+                if (f.exists()) {
+                    ImageCompare comp = new ImageCompare();
+                    if (comp.isMoviePlay((String)fileMap.get("newFile"), prePath)) {
+                        screenshot.setPicType(7);
+                        //前面那条也更新
+                        if (preShot.getPicType() != null && preShot.getPicType() != 7) {
+                            preShot.setPicType(7);
+                            screenshotMapper.updateById(preShot);
+                        }
+                    }
+                }
             }
         }
         if (screenshot.getPicType() == null) {
@@ -315,117 +289,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         return Pattern.matches(pattern, str.trim());
     }
 
-    public static void main(String[] args) {
-//        boolean find = matchCategory("第22 重生");
-//        System.out.println(find);
-//        String str = "中文";
-//        System.out.println(str.toCharArray().length);
-//        isEntertainment(new File("C://Users/seya/Desktop/1.jpg"));
-//        String browserName = null;
-//        try {
-//            browserName = isBrowser(new File("C://Users/seya/Desktop/chrome.jpg"));
-//            System.out.println(
-//                    "找到浏览器==" + browserName
-//            );
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-    }
-
-    //娱乐类: 电影+游戏; 画面比较丰富的
-    public static boolean isEntertainment(File pic) {
-        try {
-            int[] rgb = new int[3];
-            if (!pic.exists()) {
-                System.err.println("文件不存在" + pic.getAbsolutePath());
-            } else {
-                System.out.println("找到文件"  + pic.getAbsolutePath());
-            }
-            BufferedImage img = ImageIO.read(pic);
-            int width = img.getWidth();
-            int height = img.getHeight();
-            int minx = img.getMinX();
-            int miny = img.getMinY();
-            System.out.println("width=" + width + ",height=" + height + ".");
-            System.out.println("minx=" + minx + ",miniy=" + miny + ".");
-            //统计出现最多的一个色值,计算所占比重
-            int totalPixl = 0;
-            HashMap<Integer, Integer> colorCntMap = new HashMap<Integer, Integer>();
-
-
-            for (int i = minx; i < width; i++) {
-                for (int j = miny; j < height; j++) {
-                    totalPixl++;
-                    int pixel = img.getRGB(i, j); // 下面三行代码将一个数字转换为RGB数字
-                    if (colorCntMap.get(pixel) == null) {
-                        colorCntMap.put(pixel, 1);
-                    } else {
-                        colorCntMap.put(pixel, colorCntMap.get(pixel) + 1);
-                    }
-                }
-            }
-
-            Map<Integer, Integer> sMap = new TreeMap<Integer, Integer>();
-            int maxCnt = 0;
-            int key = 0;
-            Set<Map.Entry<Integer, Integer>> entry2 = colorCntMap.entrySet();
-            for (Map.Entry<Integer, Integer> temp : entry2) {
-//                System.out.println("sortedMap:"+temp.getKey()+" 值"+temp.getValue());
-                if (temp.getValue() > maxCnt) {
-                    maxCnt = temp.getValue();
-                    key = temp.getKey();
-                }
-                sMap.put(temp.getValue(), temp.getKey());
-            }
-            sMap = ((TreeMap) sMap).descendingMap();
-            Iterator it = sMap.keySet().iterator();
-            Integer k1 = (Integer) it.next();
-            Integer k2 = (Integer) it.next();
-            Integer color1 = sMap.get(k1);
-            Integer color2 = sMap.get(k2);
-            System.out.println("kkkk==" + k1 + "," + color1 + "," + k2 + "," + color2);
-            System.out.println("最.." + maxCnt + ", key=" + key);
-            rgb[0] = (key & 0xff0000) >> 16;
-            rgb[1] = (key & 0xff00) >> 8;
-            rgb[2] = (key & 0xff);
-            System.out.println("色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
-            //计算比例, 应该不低于50%
-            int colorPercent = maxCnt * 100 / totalPixl;
-            if (colorPercent < 50) {
-                //可能存在2中底色, 大布局的底色和小模块的底色,都算底色。
-                int secPercent = k2 * 100 / totalPixl;
-                rgb[0] = (color2 & 0xff0000) >> 16;
-                rgb[1] = (color2 & 0xff00) >> 8;
-                rgb[2] = (color2 & 0xff);
-                System.out.println("二级底色色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
-                System.out.println("二级底色比例==" + secPercent);
-                colorPercent = (k1 + k2) * 100 / totalPixl;
-            }
-            System.out.println("总底色比例==" + colorPercent);
-            //计算底色是否是连续分布的
-            int windowSize = 50;
-            int pureColorBlockCnt = 0;
-            int totalBlockCnt = 0;
-            for (int i = minx; i < width - windowSize; i += windowSize) {
-                for (int j = miny; j < height - windowSize; j += windowSize) {
-                    totalBlockCnt++;
-                    BufferedImage rect = img.getSubimage(i, j, windowSize, windowSize);
-                    if (isPureColor(rect, key)) {
-                        pureColorBlockCnt++;
-                    }
-                }
-            }
-            log.info("pureColorBlockCnt===" + pureColorBlockCnt);
-            int pureColorBlackPercent = pureColorBlockCnt * 100 / totalBlockCnt;
-            log.info("pureColorBlackPercent===" + pureColorBlackPercent);
-            if (colorPercent < 50 && pureColorBlackPercent < 30) {
-                return true;
-            }
-        } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return false;
+    public static void main(String[] args) throws Exception {
+//        isDevelop(new File("C:\\Users\\seya\\Desktop\\3.jpg"));
     }
 
     private static boolean isPureColor(BufferedImage img, int colorPixel) {
@@ -531,8 +396,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
 
     //判断是否是浏览器
     private String isBrowser(File pic) throws Exception {
-        System.out.println("picrecongnizeFolder=="+picrecongnizeFolder);
-        File folder = new File(picrecongnizeFolder);
+        System.out.println("picrecongnizeFolder=="+browserFolder);
+        File folder = new File(browserFolder);
         if (!folder.exists()) {
             throw new Exception("没有设置图片上传的浏览器比对模板库");
         } else {
@@ -558,6 +423,37 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         }
     }
 
+    //判断是否是浏览器
+    private String isDevelop(File pic) {
+        File folder = new File(developFolder);
+//        File folder = new File("C:\\picrecongnize\\develop\\");
+        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.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
+                if (matchPic) {
+                    isMatch = true;
+                    break;
+                }
+                if (isMatch) {
+                    toolName = targetPic.getName();
+                    break;
+                }
+            }
+            return toolName;
+        }
+        return null;
+    }
+
     /**
      * 判断是否是看文档, 具体类型为word, excel, pdf, ppt
      *

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

@@ -0,0 +1,296 @@
+package com.management.platform.util;
+
+import java.awt.HeadlessException;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import org.opencv.core.*;
+import org.opencv.imgcodecs.Imgcodecs;
+import org.opencv.imgproc.Imgproc;
+import org.opencv.utils.Converters;
+
+public class ImageCompare {
+    static {
+        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
+        //注意程序运行的时候需要在VM option添加该行 指明opencv的dll文件所在路径
+        //-Djava.library.path=$PROJECT_DIR$\opencv\x64
+    }
+    private boolean compareResult = false;
+    private String mark = "_compareResult";
+    /**
+     * 通过两张图对比,判断是否是游戏电影类型
+     * @param imagePath1 图片1的路径
+     * @param imagePath2 图片2的路径
+     */
+    public boolean isMoviePlay(String imagePath1, String imagePath2)
+    {
+        Mat mat1 = readMat(imagePath1);
+        Mat mat2 = readMat(imagePath2);
+        mat1 = Imgcodecs.imdecode(mat1, Imgcodecs.IMREAD_UNCHANGED);
+        mat2 = Imgcodecs.imdecode(mat2, Imgcodecs.IMREAD_UNCHANGED);
+        if(mat1.cols() == 0 || mat2.cols() == 0 || mat1.rows() == 0 || mat2.rows() == 0)
+        {
+            System.out.println("图片文件路径异常,获取的图片大小为0,无法读取");
+            return false;
+        }
+        if(mat1.cols() != mat2.cols() || mat1.rows() != mat2.rows())
+        {
+            System.out.println("两张图片大小不同,无法比较");
+            return false;
+        }
+        mat1.convertTo(mat1, CvType.CV_8UC1);
+        mat2.convertTo(mat2, CvType.CV_8UC1);
+        Mat mat1_gray = new Mat();
+        Imgproc.cvtColor(mat1, mat1_gray, Imgproc.COLOR_BGR2GRAY);
+        Mat mat2_gray = new Mat();
+        Imgproc.cvtColor(mat2, mat2_gray, Imgproc.COLOR_BGR2GRAY);
+        mat1_gray.convertTo(mat1_gray, CvType.CV_32F);
+        mat2_gray.convertTo(mat2_gray, CvType.CV_32F);
+        double result = Imgproc.compareHist(mat1_gray, mat2_gray, Imgproc.CV_COMP_CORREL);
+        if(result == 1)
+        {
+            return false;
+        }
+//        System.out.println("相似度数值为:"+result);
+        Mat mat_result = new Mat();
+        //计算两个灰度图的绝对差值,并输出到一个Mat对象中
+        Core.absdiff(mat1_gray, mat2_gray, mat_result);
+        //将灰度图按照阈值进行绝对值化
+        mat_result.convertTo(mat_result, CvType.CV_8UC1);
+        List<MatOfPoint> mat2_list = new ArrayList<MatOfPoint>();
+        Mat mat2_hi = new Mat();
+        //寻找轮廓图
+        Imgproc.findContours(mat_result, mat2_list, mat2_hi, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
+        Mat mat_result1 = mat1;
+        Mat mat_result2 = mat2;
+        //使用红色标记不同点
+        System.out.println(mat2_list.size());
+        List<Point> allPoints = new ArrayList<Point>();
+        //按照目标区域的面积大小, 长宽不低于480*480
+        Point leftTop = null;
+        Point rightTop = null;
+        Point leftBottom = null;
+        Point rightBottom = null;
+        for (MatOfPoint matOfPoint : mat2_list)
+        {
+            Rect rect = Imgproc.boundingRect(matOfPoint);
+            if (rect.width >= 280 && rect.height >= 280) {
+//                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);
+                allPoints = matOfPoint.toList();
+                leftTop = new Point(rect.x, rect.y);
+                rightTop = new Point(rect.x + rect.width -1, rect.y);
+                leftBottom = new Point(rect.x, rect.y + rect.height -1);
+                rightBottom = new Point(rect.x + rect.width -1, rect.y + rect.height -1);
+                break;
+            }
+        }
+        for (Point p : allPoints) {
+            Imgproc.drawMarker(mat_result1, p, new Scalar(0, 255, 0),2);
+        }
+        //找到四个顶点
+        System.out.println("allPoints size=="+allPoints.size());
+        if (allPoints.size() == 0) {
+            return false;
+        }
+        System.out.println(leftTop);
+        System.out.println(rightTop);
+        System.out.println(leftBottom);
+        System.out.println(rightBottom);
+        //统计在矩形边上的点数量
+        int hitCount = 0;
+        for (Point p : allPoints) {
+            if ((Math.abs(p.x - leftTop.x) <= 6 || Math.abs(p.y - leftTop.y) <= 6)
+                    || (Math.abs(p.x - rightBottom.x) <= 6 || Math.abs(p.y - rightBottom.y) <= 6)) {
+                hitCount++;
+            }
+        }
+        System.out.println("hitCount="+hitCount+", percent="+(100*hitCount/allPoints.size())+"%");
+        int percent = (100*hitCount/allPoints.size());
+        //分析占比
+        if (percent > 80) {
+            return true;//
+        } else {
+            return false;
+        }
+    }
+
+    private void writeImage(Mat mat, String outPutFile)
+    {
+        MatOfByte matOfByte = new MatOfByte();
+        Imgcodecs.imencode(".png", mat, matOfByte);
+        byte[] byteArray = matOfByte.toArray();
+        BufferedImage bufImage = null;
+        try {
+            InputStream in = new ByteArrayInputStream(byteArray);
+            bufImage = ImageIO.read(in);
+            ImageIO.write(bufImage, "png", new File(outPutFile));
+        } catch (IOException | HeadlessException e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private String getFileName(String filePath)
+    {
+        File f = new File(filePath);
+        return f.getName();
+    }
+
+    private String getParentDir(String filePath)
+    {
+        File f = new File(filePath);
+        return f.getParent();
+    }
+
+    private Mat readMat(String filePath)
+    {
+        try {
+            File file = new File(filePath);
+            FileInputStream inputStream = new FileInputStream(filePath);
+            byte[] byt = new byte[(int) file.length()];
+            int read = inputStream.read(byt);
+            List<Byte> bs = convert(byt);
+            Mat mat1 = Converters.vector_char_to_Mat(bs);
+            return mat1;
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return new Mat();
+    }
+
+    private List<Byte> convert(byte[] byt)
+    {
+        List<Byte> bs = new ArrayList<Byte>();
+        for (int i = 0; i < byt.length; i++)
+        {
+            bs.add(i, byt[i]);
+        }
+        return bs;
+    }
+
+    public boolean test(String imagePath1, String imagePath2)
+    {
+        Mat mat1 = readMat(imagePath1);
+        Mat mat2 = readMat(imagePath2);
+        mat1 = Imgcodecs.imdecode(mat1, Imgcodecs.IMREAD_UNCHANGED);
+        mat2 = Imgcodecs.imdecode(mat2, Imgcodecs.IMREAD_UNCHANGED);
+        /*Mat mat1 = Imgcodecs.imread(imagePath1, Imgcodecs.IMREAD_UNCHANGED);
+        Mat mat2 = Imgcodecs.imread(imagePath2, Imgcodecs.IMREAD_UNCHANGED);*/
+        if(mat1.cols() == 0 || mat2.cols() == 0 || mat1.rows() == 0 || mat2.rows() == 0)
+        {
+            System.out.println("图片文件路径异常,获取的图片大小为0,无法读取");
+            return false;
+        }
+        if(mat1.cols() != mat2.cols() || mat1.rows() != mat2.rows())
+        {
+            System.out.println("两张图片大小不同,无法比较");
+            return false;
+        }
+        mat1.convertTo(mat1, CvType.CV_8UC1);
+        mat2.convertTo(mat2, CvType.CV_8UC1);
+        Mat mat1_gray = new Mat();
+        Imgproc.cvtColor(mat1, mat1_gray, Imgproc.COLOR_BGR2GRAY);
+        Mat mat2_gray = new Mat();
+        Imgproc.cvtColor(mat2, mat2_gray, Imgproc.COLOR_BGR2GRAY);
+        mat1_gray.convertTo(mat1_gray, CvType.CV_32F);
+        mat2_gray.convertTo(mat2_gray, CvType.CV_32F);
+        double result = Imgproc.compareHist(mat1_gray, mat2_gray, Imgproc.CV_COMP_CORREL);
+        if(result == 1)
+        {
+            compareResult = true;//此处结果为1则为完全相同
+            return false;
+        }
+        System.out.println("相似度数值为:"+result);
+        Mat mat_result = new Mat();
+        //计算两个灰度图的绝对差值,并输出到一个Mat对象中
+        Core.absdiff(mat1_gray, mat2_gray, mat_result);
+        //将灰度图按照阈值进行绝对值化
+        mat_result.convertTo(mat_result, CvType.CV_8UC1);
+        List<MatOfPoint> mat2_list = new ArrayList<MatOfPoint>();
+        Mat mat2_hi = new Mat();
+        //寻找轮廓图
+        Imgproc.findContours(mat_result, mat2_list, mat2_hi, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
+        Mat mat_result1 = mat1;
+        Mat mat_result2 = mat2;
+        //使用红色标记不同点
+        System.out.println(mat2_list.size());
+        List<Point> allPoints = new ArrayList<Point>();
+        //按照目标区域的面积大小, 长宽不低于480*480
+        Point leftTop = null;
+        Point rightTop = null;
+        Point leftBottom = null;
+        Point rightBottom = null;
+        for (MatOfPoint matOfPoint : mat2_list)
+        {
+            Rect rect = Imgproc.boundingRect(matOfPoint);
+            if (rect.width >= 280 && rect.height >= 280) {
+                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);
+                allPoints = matOfPoint.toList();
+                leftTop = new Point(rect.x, rect.y);
+                rightTop = new Point(rect.x + rect.width -1, rect.y);
+                leftBottom = new Point(rect.x, rect.y + rect.height -1);
+                rightBottom = new Point(rect.x + rect.width -1, rect.y + rect.height -1);
+                break;
+            }
+        }
+        for (Point p : allPoints) {
+            Imgproc.drawMarker(mat_result1, p, new Scalar(0, 255, 0),2);
+        }
+        String fileName1 = getFileName(imagePath1);
+        String targetPath1 = getParentDir(imagePath2)+File.separator+fileName1.replace(".", mark+".");
+        String fileName2 = getFileName(imagePath2);
+        String targetPath2 = getParentDir(imagePath2)+File.separator+fileName2.replace(".", mark+".");
+        System.out.println(targetPath1);
+        System.out.println(targetPath2);
+        writeImage(mat_result1, targetPath1);
+        writeImage(mat_result2, targetPath2);
+        //找到四个顶点
+        System.out.println("allPoints size=="+allPoints.size());
+        System.out.println(leftTop);
+        System.out.println(rightTop);
+        System.out.println(leftBottom);
+        System.out.println(rightBottom);
+        //检测其他点,是否都在矩形边上
+        int hitCount = 0;
+        for (Point p : allPoints) {
+            if ((Math.abs(p.x - leftTop.x) <= 6 || Math.abs(p.y - leftTop.y) <= 6)
+                    || (Math.abs(p.x - rightBottom.x) <= 6 || Math.abs(p.y - rightBottom.y) <= 6)) {
+                hitCount++;
+            } else {
+//                System.out.println("失效点:"+p.x + "," + p.y);
+            }
+        }
+        System.out.println("hitCount="+hitCount+", percent="+(100*hitCount/allPoints.size())+"%");
+        int percent = (100*hitCount/allPoints.size());
+
+
+        if (percent > 80) {
+            return true;//
+        } else {
+            return false;
+        }
+    }
+
+    public static void main(String[] args) {
+        String img1 = "C:\\Users\\seya\\Desktop\\m1.jpg";
+        String img2 = "C:\\Users\\seya\\Desktop\\m2.jpg";
+        ImageCompare ip = new ImageCompare();
+        System.out.println("是电影娱乐吗?"+ip.test(img1, img2));
+    }
+}
+

+ 3 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ImageReconizeUtil.java

@@ -7,6 +7,7 @@ import org.opencv.imgproc.Imgproc;
 import java.io.File;
 
 import static java.lang.Math.E;
+import static org.opencv.imgproc.Imgproc.*;
 
 public class ImageReconizeUtil {
     public static final double YUZHI = 5*Math.pow(0.1, 11);
@@ -16,8 +17,8 @@ public class ImageReconizeUtil {
         //-Djava.library.path=$PROJECT_DIR$\opencv\x64
     }
     public static void main(String[] args) {
-        boolean match = isTemplateMatch("C:\\upload\\98529fd7931b412cb740237d4bb6ff24.jpg",
-                "C:\\\\picrecongnize\\\\360\\\\1.jpg");
+        boolean match = isTemplateMatch("C:\\upload\\c6889ab6dea949a8a8d5d89fb677a421.jpg",
+                "C:\\picrecongnize\\browser\\360\\2.jpg");
 //        match = isTemplateMatch("C:\\Users\\seya\\Desktop\\chrome_gray.jpg",
 //                "C:\\\\picrecongnize\\\\Chrome\\\\4-125.jpg");
 //        match = isTemplateMatch("C:\\Users\\seya\\Desktop\\chrome_gray.jpg",

+ 4 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ProcessUtil.java

@@ -104,11 +104,12 @@ public class ProcessUtil {
         String[] list = processStr.toLowerCase().split("\\n");
         System.out.println("list.length=="+list.length);
         for (int i = 1; i < list.length; i++) {
-            if (list[i].length() > 79) {
-                String procName = list[i].substring(79, list[i].length()).trim();
+            if (list[i].length() > 79 && list[i].contains(".app")) {
+                String procName = list[i].substring(79, list[i].indexOf(".app") + 4).trim();
                 if (procName.lastIndexOf('/') != -1) {
                     procName = procName.substring(procName.lastIndexOf('/') + 1);
                 }
+                System.out.println("应用名称==" + procName);
                 exeprocessList.add(procName); // 进程名
             }
         }
@@ -213,18 +214,6 @@ public class ProcessUtil {
                 "quyueting         7123   0.0  0.3  4601620  21944   ??  Ss   11:13AM   0:01.26 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/CoreParsec.framework/parsecd\n" +
                 "quyueting         6414   0.0  0.0  4296240    956 s000  S+   10:50AM   0:00.64 -bash\n" +
                 "root              6413   0.0  0.0  4304432    276 s000  Ss   10:50AM   0:00.02 login -pf quyueting";
-        List<String> exeprocessList = new ArrayList<>();
-        String[] list = processStr.toLowerCase().split("\\n");
-        System.out.println("list.length=="+list.length);
-        //从第三行开始才是系统的.exe进程
-        for (int i = 1; i < list.length; i++) {
-         if (list[i].length() > 79) {
-                String procName = list[i].substring(79, list[i].length()).trim();
-                if (procName.lastIndexOf('/') != -1) {
-                    procName = procName.substring(procName.lastIndexOf('/') + 1);
-                }
-                exeprocessList.add(procName); // 进程名
-            }
-        }
+        List<String> exeprocessList = getMacExeprocessListfromProcessStr(processStr);
     }
 }

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

@@ -82,6 +82,8 @@ mybatis:
 upload:
   path: /www/staticproject/timesheet/upload/
 picrecongnize:
-  path: /www/webapps/worktime/picrecongnize/
+  browser: /www/webapps/worktime/picrecongnize/browser/
+  develop: /www/webapps/worktime/picrecongnize/develop/
+
 
 

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

@@ -82,6 +82,7 @@ mybatis:
 upload:
   path: C:/upload/
 picrecongnize:
-  path: C:/picrecongnize/
+  browser: C:/picrecongnize/browser/
+  develop: C:/picrecongnize/develop/
 
 

+ 6 - 6
fhKeeper/formulahousekeeper/mywork/home.cpp

@@ -141,12 +141,12 @@ void Home::captureScreen() {
     multiPart->append(textPart2);
 
 
-    QString processList = getProcessList();
-    qDebug() << processList;
-    QHttpPart textPart3;
-    textPart3.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"processList\""));
-    textPart3.setBody(processList.toUtf8());
-    multiPart->append(textPart3);
+//    QString processList = getProcessList();
+//    qDebug() << processList;
+//    QHttpPart textPart3;
+//    textPart3.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"processList\""));
+//    textPart3.setBody(processList.toUtf8());
+//    multiPart->append(textPart3);
 
     //add os infomation
     QString osType = "";

+ 2 - 2
fhKeeper/formulahousekeeper/mywork/httpapi.h

@@ -6,8 +6,8 @@
 #include <QPair>
 #include <QJsonObject>
 #include "baseapi.h"
-//const QString SERVER_URL = QString("http://127.0.0.1:10010");
-const QString SERVER_URL = QString("http://47.100.37.243:10010");
+const QString SERVER_URL = QString("http://127.0.0.1:10010");
+//const QString SERVER_URL = QString("http://47.100.37.243:10010");
 class HttpAPI: public BaseAPI
 {
 public: