|
@ -8,7 +8,6 @@ import java.util.List;
|
8
|
8
|
import java.util.Map;
|
9
|
9
|
|
10
|
10
|
import com.ai.bss.monitorManage.utils.*;
|
11
|
|
import com.sun.javafx.collections.MappingChange;
|
12
|
11
|
import org.apache.commons.lang.StringUtils;
|
13
|
12
|
import org.apache.logging.log4j.util.Strings;
|
14
|
13
|
import org.slf4j.Logger;
|
|
@ -146,6 +145,8 @@ public class KafkaProcessImpl implements KafkaProcess {
|
146
|
145
|
List<Map> resourceToolInfoList = getResourceToolAllInfo(deviceCode);
|
147
|
146
|
boolean isHuman=aiworkHumanDetect(filePath);
|
148
|
147
|
|
|
148
|
Map<String,Integer> imageParam=AiIdentifyUtils.getImageParam(filePath);
|
|
149
|
|
149
|
150
|
for (Map resourceToolInfoMap : resourceToolInfoList) {
|
150
|
151
|
if (resourceToolInfoMap.get("aiTaskId") != null ) {
|
151
|
152
|
String aiIdenModel = resourceToolInfoMap.get("aiIdenModel") == null ? ""
|
|
@ -163,22 +164,22 @@ public class KafkaProcessImpl implements KafkaProcess {
|
163
|
164
|
|
164
|
165
|
if (MonitorManageConsts.AI_MODEL_FACE.equals(aiIdenModel)) {
|
165
|
166
|
if (isHuman){
|
166
|
|
aiIdenLogDto = faceAiRecog(aiIdenLogDto, filePath);
|
|
167
|
aiIdenLogDto = faceAiRecog(aiIdenLogDto, filePath,imageParam);
|
167
|
168
|
}
|
168
|
169
|
|
169
|
170
|
} else if (MonitorManageConsts.AI_MODEL_SAFETY_HELMET.equals(aiIdenModel)) {
|
170
|
171
|
if (isHuman) {
|
171
|
|
aiIdenLogDto = aiHelmetDetect(aiIdenLogDto, filePath);
|
|
172
|
aiIdenLogDto = aiHelmetDetect(aiIdenLogDto, filePath,imageParam);
|
172
|
173
|
}
|
173
|
174
|
|
174
|
175
|
}else if (MonitorManageConsts.AI_MODEL_SMOKE.equals(aiIdenModel)) {
|
175
|
176
|
if (isHuman){
|
176
|
|
aiIdenLogDto = smokingDetect(aiIdenLogDto, filePath);//吸烟识别
|
|
177
|
aiIdenLogDto = smokingDetect(aiIdenLogDto, filePath,imageParam);//吸烟识别
|
177
|
178
|
}
|
178
|
179
|
|
179
|
180
|
}else if (MonitorManageConsts.AI_MODEL_CLOTHING_CODE.equals(aiIdenModel)) {
|
180
|
181
|
if (isHuman){
|
181
|
|
aiIdenLogDto=workClothesDetect(aiIdenLogDto, filePath);//工作服识别
|
|
182
|
aiIdenLogDto=workClothesDetect(aiIdenLogDto, filePath,imageParam);//工作服识别
|
182
|
183
|
}
|
183
|
184
|
}
|
184
|
185
|
|
|
@ -186,7 +187,9 @@ public class KafkaProcessImpl implements KafkaProcess {
|
186
|
187
|
aiIdenLogDto=instrumentDetect(aiIdenLogDto,filePath);//仪表识别
|
187
|
188
|
|
188
|
189
|
} else if (MonitorManageConsts.AI_MODEL_STRANGER.equals(aiIdenModel)){
|
189
|
|
aiIdenLogDto=strangerDetect(aiIdenLogDto,filePath);//陌生人识别
|
|
190
|
if (isHuman) {
|
|
191
|
aiIdenLogDto = strangerDetect(aiIdenLogDto, filePath, imageParam);//陌生人识别
|
|
192
|
}
|
190
|
193
|
|
191
|
194
|
} else {
|
192
|
195
|
|
|
@ -293,7 +296,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
293
|
296
|
* @param aiIdenLogDto
|
294
|
297
|
* @return
|
295
|
298
|
*/
|
296
|
|
private AiIdenLogDto aiHelmetDetect(AiIdenLogDto aiIdenLogDto, String aifilePath) {
|
|
299
|
private AiIdenLogDto aiHelmetDetect(AiIdenLogDto aiIdenLogDto, String aifilePath,Map<String,Integer> imageParam) {
|
297
|
300
|
try {
|
298
|
301
|
log.info("开始AI帽子识别处理...");
|
299
|
302
|
// 安全帽识别
|
|
@ -318,7 +321,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
318
|
321
|
idenResultDto.setAlarmType(aiClassName);
|
319
|
322
|
idenResultDto.setAlarmMemo(aiClassName);
|
320
|
323
|
Map resultMap = (Map)jsonoArray.get(i);
|
321
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray)resultMap.get("box"));
|
|
324
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray)resultMap.get("box"),imageParam);
|
322
|
325
|
idenResultDto.setBox(boxIntArr);
|
323
|
326
|
|
324
|
327
|
idenResultDtoList.add(idenResultDto);
|
|
@ -334,7 +337,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
334
|
337
|
idenResultDto.setAlarmMemo("未戴安全帽");
|
335
|
338
|
|
336
|
339
|
Map resultMap = (Map)jsonoArray.get(i);
|
337
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray)resultMap.get("box"));
|
|
340
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray)resultMap.get("box"),imageParam);
|
338
|
341
|
idenResultDto.setBox(boxIntArr);
|
339
|
342
|
|
340
|
343
|
aiIdenLogDto.setIdenResultType(MonitorManageConsts.AI_IDENTIFY_RESULT_ALARM);
|
|
@ -407,7 +410,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
407
|
410
|
* @param aifilePath
|
408
|
411
|
* @return
|
409
|
412
|
*/
|
410
|
|
private AiIdenLogDto faceAiRecog(AiIdenLogDto aiIdenLogDto, String aifilePath) {
|
|
413
|
private AiIdenLogDto faceAiRecog(AiIdenLogDto aiIdenLogDto, String aifilePath,Map<String,Integer> imageParam) {
|
411
|
414
|
try {
|
412
|
415
|
log.info("开始AI人脸识别处理...");
|
413
|
416
|
// 人脸识别
|
|
@ -440,7 +443,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
440
|
443
|
resultDto.setSimi(score.setScale(4,BigDecimal.ROUND_HALF_UP).floatValue());
|
441
|
444
|
resultDto.setIsMatch(0);
|
442
|
445
|
|
443
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray) resultMap.get("box"));
|
|
446
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray) resultMap.get("box"),imageParam);
|
444
|
447
|
resultDto.setBox(boxIntArr);
|
445
|
448
|
|
446
|
449
|
aiIdenLogDto.setIdenResultType(MonitorManageConsts.AI_IDENTIFY_RESULT);
|
|
@ -450,7 +453,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
450
|
453
|
resultDto.setSimi(score.setScale(4,BigDecimal.ROUND_HALF_UP).floatValue());
|
451
|
454
|
resultDto.setIsMatch(1);
|
452
|
455
|
|
453
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray) resultMap.get("box"));
|
|
456
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray) resultMap.get("box"),imageParam);
|
454
|
457
|
resultDto.setBox(boxIntArr);
|
455
|
458
|
|
456
|
459
|
aiIdenLogDto.setRelateEmployeeRoleId(faceId);
|
|
@ -474,7 +477,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
474
|
477
|
* @param aifilePath
|
475
|
478
|
* @return
|
476
|
479
|
*/
|
477
|
|
private AiIdenLogDto strangerDetect(AiIdenLogDto aiIdenLogDto, String aifilePath) {
|
|
480
|
private AiIdenLogDto strangerDetect(AiIdenLogDto aiIdenLogDto, String aifilePath,Map<String,Integer> imageParam) {
|
478
|
481
|
try {
|
479
|
482
|
log.info("开始AI陌生人识别处理...");
|
480
|
483
|
// 人脸识别
|
|
@ -508,7 +511,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
508
|
511
|
idenResultDto.setAlarmType(MonitorManageConsts.AI_ALARM_TYPE_STA);
|
509
|
512
|
idenResultDto.setAlarmMemo("陌生人");
|
510
|
513
|
|
511
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray) resultMap.get("box"));
|
|
514
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray) resultMap.get("box"),imageParam);
|
512
|
515
|
idenResultDto.setBox(boxIntArr);
|
513
|
516
|
|
514
|
517
|
idenResultDtoList.add(idenResultDto);
|
|
@ -538,7 +541,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
538
|
541
|
* AI吸烟检测
|
539
|
542
|
*
|
540
|
543
|
*/
|
541
|
|
private AiIdenLogDto smokingDetect(AiIdenLogDto aiIdenLogDto, String aifilePath){
|
|
544
|
private AiIdenLogDto smokingDetect(AiIdenLogDto aiIdenLogDto, String aifilePath,Map<String,Integer> imageParam){
|
542
|
545
|
try{
|
543
|
546
|
log.info("开始AI抽烟识别处理...");
|
544
|
547
|
//抽烟识别
|
|
@ -564,7 +567,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
564
|
567
|
idenResultDto.setAlarmMemo("违规吸烟");
|
565
|
568
|
|
566
|
569
|
Map resultMap = (Map) jsonArray.get(i);
|
567
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray) resultMap.get("box"));
|
|
570
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray) resultMap.get("box"),imageParam);
|
568
|
571
|
idenResultDto.setBox(boxIntArr);
|
569
|
572
|
|
570
|
573
|
log.info("检测到违规吸烟");
|
|
@ -595,7 +598,7 @@ public class KafkaProcessImpl implements KafkaProcess {
|
595
|
598
|
*
|
596
|
599
|
*
|
597
|
600
|
* */
|
598
|
|
private AiIdenLogDto workClothesDetect(AiIdenLogDto aiIdenLogDto, String aifilePath){
|
|
601
|
private AiIdenLogDto workClothesDetect(AiIdenLogDto aiIdenLogDto, String aifilePath,Map<String,Integer> imageParam){
|
599
|
602
|
try{
|
600
|
603
|
log.info("开始服装识别处理...");
|
601
|
604
|
//工作服识别
|
|
@ -618,7 +621,7 @@ private AiIdenLogDto workClothesDetect(AiIdenLogDto aiIdenLogDto, String aifileP
|
618
|
621
|
idenResultDto.setAlarmMemo("未穿工作服");
|
619
|
622
|
log.info("未穿工作服");
|
620
|
623
|
|
621
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray) resultList.get(i).get("box"));
|
|
624
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray) resultList.get(i).get("box"),imageParam);
|
622
|
625
|
idenResultDto.setBox(boxIntArr);
|
623
|
626
|
|
624
|
627
|
aiIdenLogDto.setIdenResultType(MonitorManageConsts.AI_IDENTIFY_RESULT_ALARM);
|
|
@ -631,7 +634,7 @@ private AiIdenLogDto workClothesDetect(AiIdenLogDto aiIdenLogDto, String aifileP
|
631
|
634
|
idenResultDto.setAlarmType(aiClassName);
|
632
|
635
|
idenResultDto.setAlarmMemo(aiClassName);
|
633
|
636
|
|
634
|
|
int[] boxIntArr = ArrayUtils.JsonToArray((JSONArray) resultList.get(i).get("box"));
|
|
637
|
int[] boxIntArr = AiIdentifyUtils.getBoxArray((JSONArray) resultList.get(i).get("box"),imageParam);
|
635
|
638
|
idenResultDto.setBox(boxIntArr);
|
636
|
639
|
|
637
|
640
|
idenResultDtoList.add(idenResultDto);
|