|
@@ -144,19 +144,23 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
// LocalDateTime l = LocalDateTime.parse("2019-02-03",dateTimeFormatter);
|
|
// LocalDateTime l = LocalDateTime.parse("2019-02-03",dateTimeFormatter);
|
|
Map<String, Object> picResultMap = CheckPicUtil.generalPicTextContentMap(path + filePath.substring("/upload/".length()), accessToken);
|
|
Map<String, Object> picResultMap = CheckPicUtil.generalPicTextContentMap(path + filePath.substring("/upload/".length()), accessToken);
|
|
- List<String> textContents = (List<String>) picResultMap.get("wordsList");
|
|
|
|
- screenshot.setPicContext((String) picResultMap.get("picContent"));
|
|
|
|
- Set<Object> members = new HashSet<>();
|
|
|
|
- if (redisUtil.existsKey(Constant.COMMON_SOFTWARE_KEYWORDS)) {
|
|
|
|
- members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
|
|
- } else {
|
|
|
|
- List<PicContentKeywords> picContentKeywords = picContentKeywordsMapper.selectList(null);
|
|
|
|
- for (PicContentKeywords keyWord : picContentKeywords) {
|
|
|
|
- redisUtil.sSetJsonString("keyWords", keyWord);
|
|
|
|
- }
|
|
|
|
- //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
|
|
|
|
- members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
|
|
|
|
+ List<String> textContents = new ArrayList<String>();
|
|
|
|
+ if (picResultMap != null) {
|
|
|
|
+ textContents = (List<String>) picResultMap.get("wordsList");
|
|
|
|
+ screenshot.setPicContext((String) picResultMap.get("picContent"));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// Set<Object> members = new HashSet<>();
|
|
|
|
+// if (redisUtil.existsKey(Constant.COMMON_SOFTWARE_KEYWORDS)) {
|
|
|
|
+// members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
|
|
+// } else {
|
|
|
|
+// List<PicContentKeywords> picContentKeywords = picContentKeywordsMapper.selectList(null);
|
|
|
|
+// for (PicContentKeywords keyWord : picContentKeywords) {
|
|
|
|
+// redisUtil.sSetJsonString("keyWords", keyWord);
|
|
|
|
+// }
|
|
|
|
+// //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
|
|
|
|
+// members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
|
|
+// }
|
|
File picFile = new File((String)fileMap.get("newFile"));
|
|
File picFile = new File((String)fileMap.get("newFile"));
|
|
if (isNovel(textContents)) {
|
|
if (isNovel(textContents)) {
|
|
screenshot.setPicType(6);
|
|
screenshot.setPicType(6);
|
|
@@ -290,7 +294,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
public static void main(String[] args) throws Exception {
|
|
-// String b = isDevelop(new File("C:\\Users\\seya\\Desktop\\proj.jpg"));
|
|
|
|
|
|
+// String b = isDevelop(new File("C:\\Users\\seya\\Desktop\\wtt.jpg"));
|
|
// System.out.println("结果:"+b);
|
|
// System.out.println("结果:"+b);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -409,7 +413,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
File[] targetFile = subFolder.listFiles();
|
|
File[] targetFile = subFolder.listFiles();
|
|
boolean isMatch = false;
|
|
boolean isMatch = false;
|
|
for (File targetPic : targetFile) {
|
|
for (File targetPic : targetFile) {
|
|
- System.out.println("targetPic==" + targetPic.getAbsolutePath());
|
|
|
|
|
|
+// System.out.println("targetPic==" + targetPic.getAbsolutePath());
|
|
boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
|
|
boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
|
|
if (matchPic) {
|
|
if (matchPic) {
|
|
isMatch = true;
|
|
isMatch = true;
|
|
@@ -425,7 +429,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //判断是否是浏览器
|
|
|
|
|
|
+ //判断是否是开发
|
|
private String isDevelop(File pic) {
|
|
private String isDevelop(File pic) {
|
|
File folder = new File(developFolder);
|
|
File folder = new File(developFolder);
|
|
// File folder = new File("C:\\picrecongnize\\develop\\");
|
|
// File folder = new File("C:\\picrecongnize\\develop\\");
|
|
@@ -440,7 +444,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
String toolName = null;
|
|
String toolName = null;
|
|
boolean isMatch = false;
|
|
boolean isMatch = false;
|
|
for (File targetPic : files) {
|
|
for (File targetPic : files) {
|
|
- System.out.println("targetPic==" + targetPic.getAbsolutePath());
|
|
|
|
|
|
+// System.out.println("targetPic==" + targetPic.getAbsolutePath());
|
|
boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
|
|
boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
|
|
if (matchPic) {
|
|
if (matchPic) {
|
|
toolName = targetPic.getName();
|
|
toolName = targetPic.getName();
|
|
@@ -487,8 +491,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
int height = img.getHeight();
|
|
int height = img.getHeight();
|
|
int minx = img.getMinX();
|
|
int minx = img.getMinX();
|
|
int miny = img.getMinY();
|
|
int miny = img.getMinY();
|
|
- System.out.println("width=" + width + ",height=" + height + ".");
|
|
|
|
- System.out.println("minx=" + minx + ",miniy=" + miny + ".");
|
|
|
|
|
|
+// System.out.println("width=" + width + ",height=" + height + ".");
|
|
|
|
+// System.out.println("minx=" + minx + ",miniy=" + miny + ".");
|
|
//统计出现最多的一个色值,计算所占比重
|
|
//统计出现最多的一个色值,计算所占比重
|
|
int totalPixl = 0;
|
|
int totalPixl = 0;
|
|
HashMap<Integer, Integer> colorCntMap = new HashMap<Integer, Integer>();
|
|
HashMap<Integer, Integer> colorCntMap = new HashMap<Integer, Integer>();
|
|
@@ -522,12 +526,12 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
Integer k2 = (Integer) it.next();
|
|
Integer k2 = (Integer) it.next();
|
|
Integer color1 = sMap.get(k1);
|
|
Integer color1 = sMap.get(k1);
|
|
Integer color2 = sMap.get(k2);
|
|
Integer color2 = sMap.get(k2);
|
|
- System.out.println("kkkk==" + k1 + "," + color1 + "," + k2 + "," + color2);
|
|
|
|
- System.out.println("最.." + maxCnt + ", key=" + key);
|
|
|
|
|
|
+// System.out.println("kkkk==" + k1 + "," + color1 + "," + k2 + "," + color2);
|
|
|
|
+// System.out.println("最.." + maxCnt + ", key=" + key);
|
|
rgb[0] = (key & 0xff0000) >> 16;
|
|
rgb[0] = (key & 0xff0000) >> 16;
|
|
rgb[1] = (key & 0xff00) >> 8;
|
|
rgb[1] = (key & 0xff00) >> 8;
|
|
rgb[2] = (key & 0xff);
|
|
rgb[2] = (key & 0xff);
|
|
- System.out.println("色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
|
|
|
|
|
|
+// System.out.println("色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
|
|
//计算比例, 应该不低于50%
|
|
//计算比例, 应该不低于50%
|
|
int colorPercent = maxCnt * 100 / totalPixl;
|
|
int colorPercent = maxCnt * 100 / totalPixl;
|
|
if (colorPercent < 50) {
|
|
if (colorPercent < 50) {
|
|
@@ -536,8 +540,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
rgb[0] = (color2 & 0xff0000) >> 16;
|
|
rgb[0] = (color2 & 0xff0000) >> 16;
|
|
rgb[1] = (color2 & 0xff00) >> 8;
|
|
rgb[1] = (color2 & 0xff00) >> 8;
|
|
rgb[2] = (color2 & 0xff);
|
|
rgb[2] = (color2 & 0xff);
|
|
- System.out.println("二级底色色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
|
|
|
|
- System.out.println("二级底色比例==" + secPercent);
|
|
|
|
|
|
+// System.out.println("二级底色色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
|
|
|
|
+// System.out.println("二级底色比例==" + secPercent);
|
|
colorPercent = (k1 + k2) * 100 / totalPixl;
|
|
colorPercent = (k1 + k2) * 100 / totalPixl;
|
|
}
|
|
}
|
|
System.out.println("总底色比例==" + colorPercent);
|
|
System.out.println("总底色比例==" + colorPercent);
|
|
@@ -554,9 +558,9 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- log.info("pureColorBlockCnt===" + pureColorBlockCnt);
|
|
|
|
|
|
+// log.info("pureColorBlockCnt===" + pureColorBlockCnt);
|
|
int pureColorBlackPercent = pureColorBlockCnt * 100 / totalBlockCnt;
|
|
int pureColorBlackPercent = pureColorBlockCnt * 100 / totalBlockCnt;
|
|
- log.info("pureColorBlackPercent===" + pureColorBlackPercent);
|
|
|
|
|
|
+// log.info("pureColorBlackPercent===" + pureColorBlackPercent);
|
|
if (colorPercent < 50 && pureColorBlackPercent < 30) {
|
|
if (colorPercent < 50 && pureColorBlackPercent < 30) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|