diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/changqing/controller/TenSafeVideoController.java b/shapelight-admin/src/main/java/net/shapelight/modules/changqing/controller/TenSafeVideoController.java index eaa9bef..fa954d3 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/changqing/controller/TenSafeVideoController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/changqing/controller/TenSafeVideoController.java @@ -96,10 +96,4 @@ public class TenSafeVideoController { tenSafeVideoService.removeByIds(Arrays.asList(ids)); return R.ok(); } - - @GetMapping("/camara") - public R watchStart(String cellId) { - rtspFrameGrabber.startGrabber(cellId); - return R.ok(); - } } \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java b/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java index 8eaca43..d3e9cbd 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java @@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; @@ -157,55 +158,8 @@ public class RtspFrameGrabber { // 转换为byte数组 byte[] imageBytes = baos.toByteArray();*/ - if (bytes != null && bytes.length > 0) { - ImageInfo imageInfo = ImageFactory.getRGBData(bytes); - List faceInfoList = faceEngineService.detectFaces(imageInfo); - if (CollectionUtil.isNotEmpty(faceInfoList)) { - faceInfoList.forEach(faceInfo -> { - FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO(); - faceRecognitionResDTO.setRect(faceInfo.getRect()); - byte[] featureBytes = faceEngineService.extractFaceFeature(imageInfo, faceInfo, ExtractType.REGISTER); - if (featureBytes != null) { - List userInfoList = UserRamGroup.getUserList(cellId); - List userCompareInfoList = faceEngineService.faceRecognition(featureBytes,userInfoList,Float.parseFloat(globalValue.getRecFaceThd())); - if(!userCompareInfoList.isEmpty()) { - UserCompareInfo userCompareInfo = userCompareInfoList.get(0); - TenPersonEntity tenPerson = personService.getOne(new LambdaQueryWrapper() - .eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId())); - Map personnelTypeMap = new HashMap<>(); - personnelTypeMap.put(Constant.PERSON_TYPE_OWNER,"2");//内部人员 - personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商 - personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商 - Map params = new HashMap<>(); - params.put("pmWatchVideoRecordId",""); - params.put("orgId",tenPerson.getOrgId()); - params.put("orgName",""); - params.put("personnelName",tenPerson.getName()); - params.put("personnelId",tenPerson.getOpenId()); - params.put("personnelCardId",tenPerson.getIdCard()); - params.put("personnelType",personnelTypeMap.get(tenPerson.getPersonType())); - params.put("dictSex",tenPerson.getGender()==0?"女":"男"); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); - params.put("watchVideoTime",sdf.format(System.currentTimeMillis())); - JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params); - if(jsonObject.getBool("success")!=null&&jsonObject.getBool("success")) { - personService.update(new LambdaUpdateWrapper() - .set(TenPersonEntity::getIsWatchSafeVideo,1) - .eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId())); - } - } + imageRecognition(bytes,cellId); - - } else { - log.error("图片不合格,未检测到人脸"); - } - }); - - } else { - log.error("图片不合格,未检测到人脸"); - } - - } } else { log.error("解码失败"); if (grabber != null) { @@ -241,6 +195,67 @@ public class RtspFrameGrabber { } + public void recognition(MultipartFile file,String cellId) { + try { + byte[] bytes = file.getBytes(); + imageRecognition(bytes,cellId); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private void imageRecognition(byte[] bytes,String cellId) { + if (bytes != null && bytes.length > 0) { + ImageInfo imageInfo = ImageFactory.getRGBData(bytes); + List faceInfoList = faceEngineService.detectFaces(imageInfo); + if (CollectionUtil.isNotEmpty(faceInfoList)) { + faceInfoList.forEach(faceInfo -> { + FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO(); + faceRecognitionResDTO.setRect(faceInfo.getRect()); + byte[] featureBytes = faceEngineService.extractFaceFeature(imageInfo, faceInfo, ExtractType.REGISTER); + if (featureBytes != null) { + List userInfoList = UserRamGroup.getUserList(cellId); + List userCompareInfoList = faceEngineService.faceRecognition(featureBytes,userInfoList,Float.parseFloat(globalValue.getRecFaceThd())); + if(!userCompareInfoList.isEmpty()) { + UserCompareInfo userCompareInfo = userCompareInfoList.get(0); + TenPersonEntity tenPerson = personService.getOne(new LambdaQueryWrapper() + .eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId())); + Map personnelTypeMap = new HashMap<>(); + personnelTypeMap.put(Constant.PERSON_TYPE_OWNER,"2");//内部人员 + personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商 + personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商 + Map params = new HashMap<>(); + params.put("pmWatchVideoRecordId",""); + params.put("orgId",tenPerson.getOrgId()); + params.put("orgName",""); + params.put("personnelName",tenPerson.getName()); + params.put("personnelId",tenPerson.getOpenId()); + params.put("personnelCardId",tenPerson.getIdCard()); + params.put("personnelType",personnelTypeMap.get(tenPerson.getPersonType())); + params.put("dictSex",tenPerson.getGender()==0?"女":"男"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + params.put("watchVideoTime",sdf.format(System.currentTimeMillis())); + /*JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params); + if(jsonObject.getBool("success")!=null&&jsonObject.getBool("success")) { + personService.update(new LambdaUpdateWrapper() + .set(TenPersonEntity::getIsWatchSafeVideo,1) + .eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId())); + }*/ + } + + + } else { + log.error("图片不合格,未检测到人脸"); + } + }); + + } else { + log.error("图片不合格,未检测到人脸"); + } + + } + } + /** * 图片转字节数组 * diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/feignClient/CxFeignClient.java b/shapelight-admin/src/main/java/net/shapelight/modules/feignClient/CxFeignClient.java index 15a78cc..f936214 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/feignClient/CxFeignClient.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/feignClient/CxFeignClient.java @@ -6,6 +6,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import java.util.Map; @@ -24,19 +25,19 @@ public interface CxFeignClient { 同步安全视频观看记录 */ @PostMapping("/ExternalService/SavePmWatchVideoRecord") - JSONObject savePmWatchVideoRecord(@RequestParam Map params); + JSONObject savePmWatchVideoRecord(@RequestBody Map params); /* 同步进出场记录 */ @PostMapping("/ExternalService/SavePmEntryExitRecord") - JSONObject savePmEntryExitRecord(@RequestParam Map params); + JSONObject savePmEntryExitRecord(@RequestBody Map params); /* 同步访客记录 */ @PostMapping("/ExternalService/SavePmVisitorPersonnel") - JSONObject savePmVisitorPersonnel(@RequestParam Map params); + JSONObject savePmVisitorPersonnel(@RequestBody Map params); /* 获取内部人员信息 diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java index e9c8e9f..83d4543 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java @@ -2,12 +2,12 @@ package net.shapelight.modules.iCq.controller.video; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.plugin.oss.service.OssTemplate; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import net.shapelight.common.config.MinioConfig; import net.shapelight.common.utils.R; +import net.shapelight.modules.face.rtsp.RtspFrameGrabber; import net.shapelight.modules.iCq.controller.video.dto.UpdateVideoDto; import net.shapelight.modules.iCq.controller.video.dto.UploadVideoDto; import net.shapelight.modules.iCq.controller.video.vo.Unit; @@ -15,6 +15,7 @@ import net.shapelight.modules.iCq.dal.dataobject.video.File; import net.shapelight.modules.iCq.dal.dataobject.video.TenSafeVideoEntity; import net.shapelight.modules.iCq.dal.mysql.video.CqFileMapper; import net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -34,14 +35,15 @@ public class CqSafeVideoController { private static String BUCKET_NAME = "cqyt"; - private final OssTemplate template; - private final MinioConfig minioConfig; private final CqSafeVideoMapper cqSafeVideoMapper; private final CqFileMapper cqFileMapper; + @Autowired + private RtspFrameGrabber rtspFrameGrabber; + @GetMapping("/getTopUnits") @ApiOperation(value = "获取单位列表") public R getTopUnits() { @@ -183,6 +185,19 @@ public class CqSafeVideoController { return R.ok(); } + @GetMapping("/camara") + public R watchStart(String cellId) { + rtspFrameGrabber.startGrabber(cellId); + return R.ok(); + } + + + @GetMapping("/face/recognition") + public R aWatchStart(@RequestParam("image") MultipartFile image,@RequestParam String cellId) { + rtspFrameGrabber.recognition(image,cellId); + return R.ok(); + } + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java index 4dabe00..ce193c4 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java @@ -266,11 +266,13 @@ public class TenPersonEntity extends BaseEntity implements Serializable { * 临时身份证正面照片 */ @ApiModelProperty("临时身份证正面照片") + @TableField(exist = false) private String idFrontImageTemp; /** * 临时身份证反面照片 */ @ApiModelProperty("临时身份证反面照片") + @TableField(exist = false) private String idBackImageTemp;