| | |
| | | import com.ard.utils.mqtt.MqttProducer; |
| | | import com.ard.utils.util.IdUtils; |
| | | import com.sun.jna.Pointer; |
| | | import javafx.scene.Camera; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.*; |
| | |
| | | if (camera == null && ardEquipExternal == null) { |
| | | return false; |
| | | } |
| | | CameraEventInfo info; |
| | | CameraEventInfo cameraEventInfo; |
| | | SuperBrainEventInfo superBrainEventInfo; |
| | | String alarmName = "";//æ¥è¦åç§° |
| | | String alarmTime;//äºä»¶æ¶é´ |
| | | String alarmType = "";//æ¥è¦ç±»å |
| | | String picUrl = "";//äºä»¶å¾ç |
| | | String facePicUrl = "";//人è¸å¾ç |
| | | String facePicUrl = "";//äººè¸ææå¾ç |
| | | String faceLibUrl = "";//人è¸åºå¾ç |
| | | int dwPicDataLen;//å¾çæ°æ®é¿åº¦ |
| | | //lCommandæ¯ä¼ çæ¥è¦ç±»å |
| | | log.debug("ã" + sDeviceIP + ":" + wLinkPort + "ãæ¥è¦äºä»¶ç±»å:lCommand:" + Integer.toHexString(lCommand)); |
| | | switch (lCommand) { |
| | | case COMM_ALARM_V30: |
| | | log.debug("ç§»å¨ä¾¦æµæ¥è¦ä¿¡æ¯ä¸æ¥"); |
| | | if (camera == null) { |
| | | return false; |
| | | } |
| | | log.debug("ç§»å¨ä¾¦æµä¿¡æ¯ä¸æ¥"); |
| | | //region ç§»å¨ä¾¦æµãè§é¢ä¸¢å¤±ã鮿¡ãIOä¿¡å·éçæ¥è¦ä¿¡æ¯(V3.0以ä¸çæ¬æ¯æç设å¤) |
| | | HCNetSDK.NET_DVR_ALARMINFO_V30 netDvrAlarminfoV30 = new HCNetSDK.NET_DVR_ALARMINFO_V30(); |
| | | netDvrAlarminfoV30.write(); |
| | |
| | | netDvrAlarminfoV30.read(); |
| | | switch (netDvrAlarminfoV30.dwAlarmType) { |
| | | case 3: |
| | | info = new CameraEventInfo(); |
| | | info.setAlarmName("ç§»å¨ä¾¦æµ"); |
| | | info.setAlarmTime(fmt.format(new Date())); |
| | | info.setCameraName(camera.getName()); |
| | | info.setCameraId(camera.getId()); |
| | | info.setCameraIp(camera.getIp()); |
| | | info.setCameraPort(camera.getPort()); |
| | | info.setCameraType(camera.getGdType()); |
| | | info.setCameraChannel(Integer.valueOf(netDvrAlarminfoV30.byChannel[0])); |
| | | info.setLongitude(camera.getLongitude()); |
| | | info.setLatitude(camera.getLatitude()); |
| | | info.setAlarmType("ç§»å¨ä¾¦æµ"); |
| | | //å¾çåå
¥minio |
| | | picUrl = snapPicture(info); |
| | | info.setPicUrl(picUrl); |
| | | publishMqtt(info, "camera"); |
| | | if (camera != null) { |
| | | cameraEventHandler(camera, "ç§»å¨ä¾¦æµ", "ç§»å¨ä¾¦æµæ¥è¦", fmt.format(new Date()), ""); |
| | | } |
| | | break; |
| | | } |
| | | //endregion |
| | | break; |
| | | case COMM_VCA_ALARM: |
| | | log.debug("æºè½æ£æµéç¨ä¿¡æ¯ä¸æ¥(æä¸è§£æ)"); |
| | | case COMM_ALARM_RULE: |
| | | log.debug("å¼å¸¸è¡ä¸ºè¯å«ä¿¡æ¯æ¥è¦ä¿¡æ¯ä¸æ¥"); |
| | | log.debug("å¼å¸¸è¡ä¸ºè¯å«ä¿¡æ¯ä¸æ¥"); |
| | | //region å¼å¸¸è¡ä¸ºè¯å«ä¿¡æ¯ |
| | | HCNetSDK.NET_VCA_RULE_ALARM strVcaAlarm = new HCNetSDK.NET_VCA_RULE_ALARM(); |
| | | strVcaAlarm.write(); |
| | |
| | | Integer ruleID = Integer.valueOf(strVcaAlarm.struRuleInfo.byRuleID); |
| | | alarmTime = DateUtils.parseTime(strVcaAlarm.dwAbsTime);//äºä»¶æ¶é´ |
| | | Integer channel = Integer.valueOf(strVcaAlarm.struDevInfo.byChannel);//éé |
| | | info = new CameraEventInfo(); |
| | | info.setAlarmName("人åè¡ä¸ºåæ"); |
| | | info.setAlarmTime(alarmTime); |
| | | info.setCameraName(camera.getName()); |
| | | info.setCameraId(camera.getId()); |
| | | info.setCameraIp(camera.getIp()); |
| | | info.setCameraPort(camera.getPort()); |
| | | info.setCameraType(camera.getGdType()); |
| | | info.setCameraChannel(channel); |
| | | info.setLongitude(camera.getLongitude()); |
| | | info.setLatitude(camera.getLatitude()); |
| | | info.setRuleId(ruleID); |
| | | switch (strVcaAlarm.struRuleInfo.wEventTypeEx) { |
| | | case 1: //regionç©¿è¶è¦æé¢ (è¶ç侦æµ) |
| | | info.setAlarmType("è¶çä¾¦æµæ¥è¦"); |
| | | strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_TRAVERSE_PLANE.class); |
| | | //å¾çåå
¥minio |
| | | picUrl = snapPicture(info); |
| | | info.setPicUrl(picUrl); |
| | | publishMqtt(info, "camera"); |
| | | alarmType = "è¶çä¾¦æµæ¥è¦"; |
| | | //endregion |
| | | break; |
| | | // case 2: //region ç®æ è¿å
¥åºå |
| | | // info.setAlarmType("ç®æ è¿å
¥åºåæ¥è¦"); |
| | | // strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); |
| | | // //endregion |
| | | // break; |
| | | // case 3: //region ç®æ 离å¼åºå |
| | | // info.setAlarmType("ç®æ 离å¼åºåæ¥è¦"); |
| | | // strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); |
| | | // //endregion |
| | | // break; |
| | | case 2: //region ç®æ è¿å
¥åºå |
| | | alarmType = "ç®æ è¿å
¥åºåæ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 3: //region ç®æ 离å¼åºå |
| | | alarmType = "ç®æ 离å¼åºåæ¥è¦"; |
| | | //strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); |
| | | //endregion |
| | | break; |
| | | case 4: //region å¨çå
¥ä¾µ |
| | | info.setAlarmType("å¨çå
¥ä¾µæ¥è¦"); |
| | | strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_INTRUSION.class); |
| | | //å¾çåå
¥minio |
| | | picUrl = snapPicture(info); |
| | | info.setPicUrl(picUrl); |
| | | publishMqtt(info, "camera"); |
| | | alarmType = "å¨çå
¥ä¾µæ¥è¦"; |
| | | //endregion |
| | | break; |
| | | // case 5: //region å¾å¾ |
| | | // info.setAlarmType("å¾å¾äºä»¶æ¥è¦"); |
| | | // //endregion |
| | | // break; |
| | | // case 8: //region å¿«éç§»å¨(å¥è·) |
| | | // info.setAlarmType("å¿«éç§»å¨(å¥è·)äºä»¶æ¥è¦"); |
| | | // //endregion |
| | | // break; |
| | | // case 13: //region ç©åéçäºä»¶ |
| | | // info.setAlarmType("ç©åéçäºä»¶æ¥è¦"); |
| | | // //endregion |
| | | // break; |
| | | // case 14: //region ç©åæ¿åäºä»¶ |
| | | // info.setAlarmType("ç©åæ¿åäºä»¶äºä»¶æ¥è¦"); |
| | | // //endregion |
| | | // break; |
| | | // case 20: //region åå°æ£æµ |
| | | // info.setAlarmType("åå°äºä»¶è§¦å"); |
| | | // //endregion |
| | | // break; |
| | | // case 44: //region ç©ææº |
| | | // info.setAlarmType("ç©ææºæ¥è¦äºä»¶"); |
| | | // //endregion |
| | | // break; |
| | | case 5: //region å¾å¾ |
| | | alarmType = "å¾å¾äºä»¶æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 8: //region å¿«éç§»å¨(å¥è·) |
| | | alarmType = "å¿«éç§»å¨æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 9: //region 人åèéæ¥è¦ |
| | | alarmType = "人åè鿥è¦"; |
| | | //endregion |
| | | break; |
| | | case 13: //region ç©åéçäºä»¶ |
| | | alarmType = "ç©åéçäºä»¶æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 14: //region ç©åæ¿åäºä»¶ |
| | | alarmType = "ç©åæ¿åäºä»¶æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 15: //region 离å²äºä»¶ |
| | | strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_LEAVE_POSITION.class); |
| | | int byMode = strVcaAlarm.struRuleInfo.uEventParam.struLeavePos.byMode; |
| | | switch (byMode) { |
| | | case 0: |
| | | alarmType = "离å²äºä»¶æ¥è¦"; |
| | | break; |
| | | case 1: |
| | | alarmType = "ç¡å²äºä»¶æ¥è¦"; |
| | | break; |
| | | } |
| | | //endregion |
| | | break; |
| | | case 20: //region åå°æ£æµ |
| | | alarmType = "åå°æ£æµäºä»¶æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 35: //region åå°æ£æµ |
| | | alarmType = "人æ°ååäºä»¶æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 41: //region æ»çæ£æµ |
| | | alarmType = "æ»çæ£æµäºä»¶æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | case 44: //region ç©ææº |
| | | alarmType = "ç©ææºäºä»¶æ¥è¦"; |
| | | //endregion |
| | | break; |
| | | default: |
| | | log.debug("æªç¥å¼å¸¸è¡ä¸ºäºä»¶ç±»å:" + strVcaAlarm.struRuleInfo.wEventTypeEx); |
| | | break; |
| | | } |
| | | //å¾çæ¥æ¶ |
| | | int byPicType = strVcaAlarm.byPicType; |
| | | dwPicDataLen = strVcaAlarm.dwPicDataLen; |
| | | int byPicTransType = strVcaAlarm.byPicTransType; |
| | | if (dwPicDataLen > 0 && strVcaAlarm.pImage != null && byPicTransType == 0) { |
| | | //å°åèåå
¥æä»¶ |
| | | long offset = 0; |
| | | ByteBuffer buffers = strVcaAlarm.pImage.getByteBuffer(offset, dwPicDataLen); |
| | | byte[] bytes = new byte[dwPicDataLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | InputStream input = new ByteArrayInputStream(bytes); |
| | | try { |
| | | String bucketName = "pic"; |
| | | String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg"; |
| | | boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG"); |
| | | if (uploadObject) { |
| | | picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName); |
| | | //log.debug("ä¸ä¼ æä»¶æå!" + picUrl); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("å¼å¸¸è¡ä¸ºè¯å«ä¿¡æ¯æ¥è¦ä¿¡æ¯ä¸æ¥å¾çä¿å失败" + e.getMessage()); |
| | | } |
| | | } |
| | | if (camera != null) { |
| | | camera.setChannel(channel); |
| | | cameraEventHandler(camera, alarmName, alarmType, alarmTime, picUrl); |
| | | } |
| | | if (ardEquipExternal != null) { |
| | | alarmName = "å¼å¸¸è¡ä¸ºè¯å«"; |
| | | superBrainEventHandler(ardEquipExternal, channel, alarmName, alarmType, alarmTime, picUrl, ""); |
| | | } |
| | | //endregion |
| | | break; |
| | |
| | | log.error("äººè¸æææ¥è¦ä¿¡æ¯å¾çä¿å失败" + e.getMessage()); |
| | | } |
| | | } |
| | | log.debug("ãäººè¸æææ¥è¦ä¿¡æ¯ã: alarmTime:" + alarmTime + " picUrl:" + picUrl + " facePicType:" + facePicTyp + " facePicUrl:" + facePicUrl); |
| | | //log.debug("ãäººè¸æææ¥è¦ä¿¡æ¯ã: alarmTime:" + alarmTime + " picUrl:" + picUrl + " facePicType:" + facePicTyp + " facePicUrl:" + facePicUrl); |
| | | FaceSnapEventInfo faceSnapEventInfo = new FaceSnapEventInfo(); |
| | | faceSnapEventInfo.setAlarmTime(alarmTime); |
| | | faceSnapEventInfo.setPicUrl(picUrl); |
| | |
| | | log.debug("äººè¸æ¯å¯¹æ¥è¦ä¿¡æ¯"); |
| | | //region äººè¸æ¯å¯¹æ¥è¦ä¿¡æ¯ |
| | | HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM struFaceMatchAlarm = new HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM(); |
| | | struFaceMatchAlarm.byPicTransType = 0; |
| | | struFaceMatchAlarm.write(); |
| | | Pointer fmaInfo = struFaceMatchAlarm.getPointer(); |
| | | fmaInfo.write(0, pAlarmInfo.getByteArray(0, struFaceMatchAlarm.size()), 0, struFaceMatchAlarm.size()); |
| | | struFaceMatchAlarm.read(); |
| | | alarmTime = DateUtils.parseTime(struFaceMatchAlarm.struSnapInfo.dwAbsTime);//æ¥è¦æ¶é´ |
| | | |
| | | int byMatchPicNum = struFaceMatchAlarm.byMatchPicNum;//å¹é
å¾çæ°é |
| | | String picTransType = ""; |
| | | switch (struFaceMatchAlarm.byPicTransType) { |
| | | case 0: |
| | | picTransType = "äºè¿å¶å¾ç"; |
| | | break; |
| | | case 1: |
| | | picTransType = "URLè·¯å¾å¾ç"; |
| | | break; |
| | | } |
| | | String contrastStatus = ""; |
| | | switch (struFaceMatchAlarm.byContrastStatus) { |
| | | case 1: |
| | | contrastStatus = "æ¯å¯¹æå"; |
| | | |
| | | break; |
| | | case 2: |
| | | contrastStatus = "æ¯å¯¹å¤±è´¥"; |
| | |
| | | contrastStatus = "æªç¥"; |
| | | break; |
| | | } |
| | | String BlockType = ""; |
| | | switch (struFaceMatchAlarm.struBlockListInfo.struBlockListInfo.byType) { |
| | | case 1: |
| | | alarmType = "éç人æ¥è¦"; |
| | | BlockType = "éç人æ¥è¦"; |
| | | break; |
| | | case 2: |
| | | alarmType = "äººè¸æ¯å¯¹æ¥è¦"; |
| | | BlockType = "äººè¸æ¯å¯¹æ¥è¦"; |
| | | break; |
| | | default: |
| | | alarmType = "æªç¥"; |
| | | BlockType = "æªç¥"; |
| | | break; |
| | | } |
| | | if (struFaceMatchAlarm.dwSnapPicLen > 0 && struFaceMatchAlarm.pSnapPicBuffer != null && struFaceMatchAlarm.byPicTransType == 0) { |
| | | //å°åèåå
¥æä»¶ |
| | | //äººè¸æ¯å¯¹æ¥è¦å¾çä¿åï¼å¾çæ ¼å¼äºè¿å¶ |
| | | if ((struFaceMatchAlarm.dwSnapPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 0)) { |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String newName = sf.format(new Date()); |
| | | FileOutputStream fout; |
| | | try { |
| | | String filename = "../pic/" + newName + "_pSnapPicBuffer" + ".jpg"; |
| | | fout = new FileOutputStream(filename); |
| | | //å°åèåå
¥æä»¶ |
| | | long offset = 0; |
| | | ByteBuffer buffers = struFaceMatchAlarm.pSnapPicBuffer.getByteBuffer(offset, struFaceMatchAlarm.dwSnapPicLen); |
| | | byte[] bytes = new byte[struFaceMatchAlarm.dwSnapPicLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | fout.write(bytes); |
| | | fout.close(); |
| | | } catch (FileNotFoundException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if ((struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen > 0) && (struFaceMatchAlarm.byPicTransType == 0)) { |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String newName = sf.format(new Date()); |
| | | FileOutputStream fout; |
| | | try { |
| | | String filename = "../pic/" + newName + "_struSnapInfo_pBuffer1" + ".jpg"; |
| | | fout = new FileOutputStream(filename); |
| | | //å°åèåå
¥æä»¶ |
| | | long offset = 0; |
| | | ByteBuffer buffers = struFaceMatchAlarm.struSnapInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen); |
| | | byte[] bytes = new byte[struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | fout.write(bytes); |
| | | fout.close(); |
| | | } catch (FileNotFoundException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if ((struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 0)) { |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String newName = sf.format(new Date()); |
| | | FileOutputStream fout; |
| | | try { |
| | | String filename = "../pic/" + newName + "_fSimilarity_" + struFaceMatchAlarm.fSimilarity + "_struBlackListInfo_pBuffer1" + ".jpg"; |
| | | fout = new FileOutputStream(filename); |
| | | //å°åèåå
¥æä»¶ |
| | | long offset = 0; |
| | | ByteBuffer buffers = struFaceMatchAlarm.struBlockListInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen); |
| | | byte[] bytes = new byte[struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | fout.write(bytes); |
| | | fout.close(); |
| | | } catch (FileNotFoundException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | //äººè¸æ¯å¯¹æ¥è¦å¾çä¿åï¼å¾çæ ¼å¼URLæ ¼å¼ |
| | | if ((struFaceMatchAlarm.dwSnapPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 1)) { |
| | | |
| | | long offset = 0; |
| | | ByteBuffer buffers = struFaceMatchAlarm.pSnapPicBuffer.getByteBuffer(offset, struFaceMatchAlarm.dwSnapPicLen); |
| | | byte[] bytes = new byte[struFaceMatchAlarm.dwSnapPicLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | InputStream input = new ByteArrayInputStream(bytes); |
| | | try { |
| | | String bucketName = "pic"; |
| | | String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg"; |
| | | boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG"); |
| | | if (uploadObject) { |
| | | picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName); |
| | | //log.debug("ä¸ä¼ æä»¶æå!" + url); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("äººè¸æææ¥è¦ä¿¡æ¯å¾çä¿å失败" + e.getMessage()); |
| | | } |
| | | picUrl = new String(bytes); |
| | | //log.debug("ææå¾URLï¼" + picUrl); |
| | | } |
| | | if (struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen > 0 && struFaceMatchAlarm.struBlockListInfo.pBuffer1 != null) { |
| | | //å°åèåå
¥æä»¶ |
| | | if ((struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen > 0) && (struFaceMatchAlarm.byPicTransType == 1)) { |
| | | |
| | | long offset = 0; |
| | | ByteBuffer buffers = struFaceMatchAlarm.struSnapInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen); |
| | | byte[] bytes = new byte[struFaceMatchAlarm.struSnapInfo.dwSnapFacePicLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | facePicUrl = new String(bytes); |
| | | //System.out.println("ææäººè¸åå¾URLï¼" + SnapPicUrl); |
| | | } |
| | | if ((struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen > 0) && (struFaceMatchAlarm.byPicTransType == 1)) { |
| | | |
| | | long offset = 0; |
| | | ByteBuffer buffers = struFaceMatchAlarm.struBlockListInfo.pBuffer1.getByteBuffer(offset, struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen); |
| | | byte[] bytes = new byte[struFaceMatchAlarm.struBlockListInfo.dwBlockListPicLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | faceLibUrl = new String(bytes); |
| | | //System.out.println("人è¸åºäººè¸å¾çURLï¼" + SnapPicUrl); |
| | | } |
| | | if (ardEquipExternal != null) { |
| | | alarmName = "äººè¸æ¯å¯¹æ£æµ"; |
| | | alarmType = contrastStatus + "[" + BlockType + "]"; |
| | | superBrainEventHandler(ardEquipExternal, 0, alarmName, alarmType, alarmTime, picUrl, facePicUrl); |
| | | } |
| | | //endregion |
| | | break; |
| | | case COMM_UPLOAD_AIOP_VIDEO: |
| | | log.debug("AI弿¾å¹³å°æ¥å
¥è§é¢æ£æµæ¥è¦ä¸ä¼ "); |
| | | //region AI弿¾å¹³å°æ¥å
¥è§é¢æ£æµ |
| | | HCNetSDK.NET_AIOP_VIDEO_HEAD struAIOPVideo = new HCNetSDK.NET_AIOP_VIDEO_HEAD(); |
| | | struAIOPVideo.write(); |
| | | Pointer pAIOPVideo = struAIOPVideo.getPointer(); |
| | | pAIOPVideo.write(0, pAlarmInfo.getByteArray(0, struAIOPVideo.size()), 0, struAIOPVideo.size()); |
| | | struAIOPVideo.read(); |
| | | log.debug("è§é¢ä»»å¡ID" + new String(struAIOPVideo.szTaskID).trim()); |
| | | log.debug("ééå·ï¼" + struAIOPVideo.dwChannel); |
| | | String szMPID = new String(struAIOPVideo.szMPID).trim();//æ£æµæ¨¡åå
ID |
| | | log.debug("æ£æµæ¨¡åå
ID" + szMPID); |
| | | alarmTime = String.format("%04d", struAIOPVideo.struTime.wYear) + "-" + |
| | | String.format("%02d", struAIOPVideo.struTime.wMonth) + "-" + |
| | | String.format("%02d", struAIOPVideo.struTime.wDay) + " " + |
| | | String.format("%02d", struAIOPVideo.struTime.wHour) + ":" + |
| | | String.format("%02d", struAIOPVideo.struTime.wMinute) + ":" + |
| | | String.format("%02d", struAIOPVideo.struTime.wSecond) + "." + |
| | | String.format("%03d", struAIOPVideo.struTime.wMilliSec); |
| | | alarmName = "AI弿¾å¹³å°æ¥å
¥è§é¢æ£æµ"; |
| | | switch (szMPID) { |
| | | case "H930_MODEL_SPD": |
| | | alarmType = "æ½çæçµè¯"; |
| | | break; |
| | | } |
| | | //å¾çæ°æ®ä¿å |
| | | if (struAIOPVideo.dwPictureSize > 0) { |
| | | //å°åèåå
¥æä»¶ |
| | | long offset = 0; |
| | | ByteBuffer buffers = struAIOPVideo.pBufferPicture.getByteBuffer(offset, struAIOPVideo.dwPictureSize); |
| | | byte[] bytes = new byte[struAIOPVideo.dwPictureSize]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | InputStream input = new ByteArrayInputStream(bytes); |
| | |
| | | boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG"); |
| | | if (uploadObject) { |
| | | picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName); |
| | | //log.debug("ä¸ä¼ æä»¶æå!" + url); |
| | | //log.debug("ä¸ä¼ æä»¶æå!" + picUrl); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("äººè¸æææ¥è¦ä¿¡æ¯å¾çä¿å失败" + e.getMessage()); |
| | | log.error("AI弿¾å¹³å°æ¥å
¥è§é¢æ£æµæ¥è¦ä¸ä¼ 䏿¥å¾çä¿å失败" + e.getMessage()); |
| | | } |
| | | } |
| | | String sAlarmType = ""; |
| | | try { |
| | | sAlarmType = "人è¸é»å忝坹æ¥è¦ï¼ç¸è¯åº¦ï¼" + struFaceMatchAlarm.fSimilarity + "ï¼é»ååå§åï¼" + |
| | | new String(struFaceMatchAlarm.struBlockListInfo.struBlockListInfo.struAttribute.byName, "GBK").trim() + "ï¼é»ååè¯ä»¶ä¿¡æ¯ï¼" + |
| | | new String(struFaceMatchAlarm.struBlockListInfo.struBlockListInfo.struAttribute.byCertificateNumber).trim(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | if (ardEquipExternal != null) { |
| | | superBrainEventHandler(ardEquipExternal, struAIOPVideo.dwChannel, alarmName, alarmType, alarmTime, picUrl, ""); |
| | | } |
| | | log.debug(sAlarmType); |
| | | log.debug("ãäººè¸æ¯å¯¹æ¥è¦ä¿¡æ¯ã:" + " æ¯å¯¹ç»æ:" + contrastStatus + " æ¯å¯¹ç±»å:" + alarmType + " æ¥è¦æ¶é´:" + alarmTime + " å¹é
å¾çæ°éï¼" + byMatchPicNum + " å¾çç±»åï¼" + picTransType + " æ¯å¯¹å¾ç:" + picUrl); |
| | | FaceMatchEventInfo faceMatchEventInfo = new FaceMatchEventInfo(); |
| | | faceMatchEventInfo.setAlarmTime(alarmTime); |
| | | faceMatchEventInfo.setStatus(contrastStatus); |
| | | faceMatchEventInfo.setAlarmType(alarmType); |
| | | publishMqtt(faceMatchEventInfo, "faceMatch"); |
| | | //endregion |
| | | break; |
| | | case COMM_UPLOAD_AIOP_VIDEO: |
| | | log.debug("è®¾å¤æ¯æAI弿¾å¹³å°æ¥å
¥ï¼ä¸ä¼ è§é¢æ£æµæ°æ®(æä¸è§£æ)"); |
| | | break; |
| | | case COMM_ISAPI_ALARM: |
| | | log.debug("å®å
¨å¸½æ£æµæ¥è¦ä¿¡æ¯"); |
| | | log.debug("å®å
¨å¸½æ£æµæ¥è¦ä¿¡æ¯ä¸æ¥"); |
| | | //region å®å
¨å¸½æ£æµæ¥è¦ä¿¡æ¯ |
| | | HCNetSDK.NET_DVR_ALARM_ISAPI_INFO struEventISAPI = new HCNetSDK.NET_DVR_ALARM_ISAPI_INFO(); |
| | | struEventISAPI.write(); |
| | |
| | | int dwAlarmDataLen = struEventISAPI.dwAlarmDataLen; |
| | | int byDataType = struEventISAPI.byDataType; |
| | | int byPicturesNumber = struEventISAPI.byPicturesNumber; |
| | | |
| | | //å¤çå®å
¨å¸½æ£æµä¸ä¼ çç
§çæ°æ® |
| | | HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA struPicData = new HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA(); |
| | | struPicData.write(); |
| | | Pointer pPicData = struPicData.getPointer(); |
| | | pPicData.write(0, struEventISAPI.pPicPackData.getByteArray(0, struPicData.size()), 0, |
| | | struPicData.size()); |
| | | struPicData.read(); |
| | | log.debug("æ£æµå°å®å
¨å¸½äºä»¶"); |
| | | Pointer pPicPackData = struEventISAPI.pPicPackData; |
| | | if (pPicPackData != null) { |
| | | HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA struPicData = new HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA(); |
| | | struPicData.write(); |
| | | if (struPicData.size() > 0) { |
| | | Pointer pPicData = struPicData.getPointer(); |
| | | pPicData.write(0, pPicPackData.getByteArray(0, struPicData.size()), 0, struPicData.size()); |
| | | struPicData.read(); |
| | | int dwPicLen = struPicData.dwPicLen; |
| | | pPicData = struPicData.pPicData; |
| | | if (dwPicLen > 0 && pPicData != null) { |
| | | //å°åèåå
¥æä»¶ |
| | | long offset = 0; |
| | | ByteBuffer buffers = pPicData.getByteBuffer(offset, dwPicLen); |
| | | byte[] bytes = new byte[dwPicLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | InputStream input = new ByteArrayInputStream(bytes); |
| | | try { |
| | | String bucketName = "pic"; |
| | | String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg"; |
| | | boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG"); |
| | | if (uploadObject) { |
| | | picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName); |
| | | //log.debug("ä¸ä¼ æä»¶æå!" + picUrl); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("å¼å¸¸è¡ä¸ºè¯å«ä¿¡æ¯æ¥è¦ä¿¡æ¯ä¸æ¥å¾çä¿å失败" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | if (ardEquipExternal != null) { |
| | | alarmName = "å®å
¨å¸½æ£æµ"; |
| | | alarmType = "å®å
¨å¸½äºä»¶æ¥è¦"; |
| | | alarmTime = fmt.format(new Date()); |
| | | superBrainEventHandler(ardEquipExternal, 0, alarmName, alarmType, alarmTime, picUrl, ""); |
| | | } |
| | | //endregion |
| | | break; |
| | | case COMM_GISINFO_UPLOAD: |
| | | log.debug("GPSæ¥è¦ä¿¡æ¯ä¸æ¥(æä¸è§£æ)"); |
| | | break; |
| | | case COMM_ALARMHOST_CID_ALARM: |
| | | log.debug("æ¥è¦ä¸»æºCIDæ¥åæ¥è¦ä¸æ¥"); |
| | | log.debug("æ¥è¦ä¸»æºCIDæ¥åä¿¡æ¯ä¸æ¥"); |
| | | //region æ¥è¦ä¸»æºæ¥è¦å¤ç |
| | | HCNetSDK.NET_DVR_CID_ALARM netDvrCidAlarm = new HCNetSDK.NET_DVR_CID_ALARM(); |
| | | netDvrCidAlarm.write(); |
| | |
| | | //endregion |
| | | break; |
| | | case HCNetSDK.COMM_ALARM_ACS: |
| | | log.debug("é¨ç¦ä¸»æºæ¥è¦ä¸æ¥"); |
| | | log.debug("é¨ç¦ä¸»æºä¿¡æ¯ä¸æ¥"); |
| | | //region é¨ç¦ä¸»æºæ¥è¦å¤ç |
| | | HCNetSDK.NET_DVR_ACS_ALARM_INFO strACSInfo = new HCNetSDK.NET_DVR_ACS_ALARM_INFO(); |
| | | strACSInfo.write(); |
| | |
| | | alarmTime = DateUtils.convertDate(parseAlarmTime(strACSInfo.struTime), "yyyy-M-d H:m:s"); |
| | | |
| | | //äºä»¶å¾çå¤ç |
| | | int dwPicDataLen = strACSInfo.dwPicDataLen; |
| | | dwPicDataLen = strACSInfo.dwPicDataLen; |
| | | if (dwPicDataLen > 0) { |
| | | try { |
| | | //å°åèåå
¥æä»¶ |
| | |
| | | publishMqtt(accessControlHostEventInfo, "accessControl"); |
| | | //endregion |
| | | break; |
| | | case COMM_FIREDETECTION_ALARM: //ç«ç¹æ£æµæ¥è¦ |
| | | log.debug("ç«ç¹æ£æµä¿¡æ¯ä¸æ¥"); |
| | | //region ç«ç¹æ£æµæ¥è¦ |
| | | HCNetSDK.NET_DVR_FIREDETECTION_ALARM struFireDecAlarm = new HCNetSDK.NET_DVR_FIREDETECTION_ALARM(); |
| | | struFireDecAlarm.write(); |
| | | Pointer pFireDecAlarm = struFireDecAlarm.getPointer(); |
| | | pFireDecAlarm.write(0, pAlarmInfo.getByteArray(0, struFireDecAlarm.size()), 0, struFireDecAlarm.size()); |
| | | struFireDecAlarm.read(); |
| | | String sFireDecAlarmInfo = "ç»å¯¹æ¶é´ï¼" + struFireDecAlarm.dwAbsTime + ",æ¥è¦åç±»åï¼" + struFireDecAlarm.byAlarmSubType + ",ç«ç¹æé«æ¸©åº¦ :" + |
| | | struFireDecAlarm.wFireMaxTemperature + ",ç«ç¹ç®æ è·ç¦»ï¼" + struFireDecAlarm.wTargetDistance; |
| | | System.out.println(sFireDecAlarmInfo); |
| | | //å¾çä¿å |
| | | if ((struFireDecAlarm.dwPicDataLen > 0) && (struFireDecAlarm.byPicTransType == 0)) { |
| | | long offset = 0; |
| | | ByteBuffer buffers = struFireDecAlarm.pBuffer.getByteBuffer(offset, struFireDecAlarm.dwPicDataLen); |
| | | byte[] bytes = new byte[struFireDecAlarm.dwPicDataLen]; |
| | | buffers.rewind(); |
| | | buffers.get(bytes); |
| | | InputStream input = new ByteArrayInputStream(bytes); |
| | | try { |
| | | String bucketName = "pic"; |
| | | String objectName = "alarm/" + IdUtils.simpleUUID() + ".jpeg"; |
| | | boolean uploadObject = MinioUtil.uploadObject(bucketName, objectName, input, input.available(), "image/JPEG"); |
| | | if (uploadObject) { |
| | | picUrl = MinioUtil.getBucketObjectUrl(bucketName, objectName); |
| | | //log.debug("ä¸ä¼ æä»¶æå!" + picUrl); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("ç«ç¹æ£æµäºä»¶æ¥è¦ä¸æ¥çæåå¾çä¿å失败" + e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | if (ardEquipExternal != null) { |
| | | alarmName = "ç«ç°æ£æµä¿¡æ¯ä¸æ¥"; |
| | | alarmType = "ç«ç°æ£æµäºä»¶æ¥è¦"; |
| | | int dwVisibleChannel = struFireDecAlarm.dwVisibleChannel; |
| | | alarmTime = DateUtils.parseTime(struFireDecAlarm.dwAbsTime);//æ¥è¦æ¶é´ |
| | | superBrainEventHandler(ardEquipExternal, dwVisibleChannel, alarmName, alarmType, alarmTime, picUrl, ""); |
| | | } |
| | | //endregion |
| | | break; |
| | | case COMM_ITS_PLATE_RESULT://äº¤éææçç»ç«¯å¾çä¸ä¼ |
| | | log.debug("äº¤éææçç»ç«¯å¾ç䏿¥(æä¸è§£æ)"); |
| | | break; |
| | | default: |
| | | log.debug("æªç¥æ¥è¦äºä»¶ç±»å:lCommand:" + Integer.toHexString(lCommand)); |
| | | break; |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ç¸æºäºä»¶å¤ç |
| | | * åèä¹ |
| | | * 2023/12/5 12:56:47 |
| | | */ |
| | | public void cameraEventHandler(ArdCameras camera, String alarmName, String alarmType, String alarmTime, String picUrl) { |
| | | |
| | | CameraEventInfo cameraEventInfo = new CameraEventInfo(); |
| | | cameraEventInfo.setAlarmName(alarmName); |
| | | cameraEventInfo.setAlarmTime(alarmTime); |
| | | cameraEventInfo.setCameraName(camera.getName()); |
| | | cameraEventInfo.setCameraId(camera.getId()); |
| | | cameraEventInfo.setCameraIp(camera.getIp()); |
| | | cameraEventInfo.setCameraPort(camera.getPort()); |
| | | cameraEventInfo.setCameraType(camera.getGdType()); |
| | | cameraEventInfo.setCameraChannel(camera.getChannel()); |
| | | cameraEventInfo.setLongitude(camera.getLongitude()); |
| | | cameraEventInfo.setLatitude(camera.getLatitude()); |
| | | cameraEventInfo.setAlarmType(alarmType); |
| | | //å¾çåå
¥minio |
| | | if (picUrl.equals("")) { |
| | | picUrl = snapPicture(cameraEventInfo); |
| | | } |
| | | cameraEventInfo.setPicUrl(picUrl); |
| | | log.debug("å¤çéç¨å
çµäºä»¶æ¥è¦:ãNameã" + alarmName + "ãTypeã" + alarmType + "ãTimeã" + alarmTime + "ãDeviceã" + camera.getName() + "ãUrlã" + picUrl); |
| | | publishMqtt(cameraEventInfo, "camera"); |
| | | } |
| | | |
| | | /** |
| | | * è¶
èäºä»¶å¤ç |
| | | * åèä¹ |
| | | * 2023/12/5 12:56:47 |
| | | */ |
| | | public void superBrainEventHandler(ArdEquipExternal superBrainDevice, Integer chanNo, String alarmName, String alarmType, String alarmTime, String picUrl, String faceUrl) { |
| | | |
| | | SuperBrainEventInfo superBrainEventInfo = new SuperBrainEventInfo(); |
| | | superBrainEventInfo.setAlarmName(alarmName); |
| | | superBrainEventInfo.setAlarmType(alarmType); |
| | | superBrainEventInfo.setAlarmTime(alarmTime); |
| | | superBrainEventInfo.setDeviceId(superBrainDevice.getId()); |
| | | superBrainEventInfo.setDeviceName(superBrainDevice.getName()); |
| | | superBrainEventInfo.setChanNo(chanNo); |
| | | superBrainEventInfo.setLongitude(superBrainDevice.getLongitude()); |
| | | superBrainEventInfo.setLatitude(superBrainDevice.getLatitude()); |
| | | superBrainEventInfo.setPicUrl(picUrl); |
| | | superBrainEventInfo.setFaceUrl(faceUrl); |
| | | log.debug("å¤çéè¶
èäºä»¶æ¥è¦:ãNameã" + alarmName + "ãTypeã" + alarmType + "ãTimeã" + alarmTime + "ãDeviceã" + superBrainDevice.getName() + "ãUrlã" + picUrl + "ãfaceUrlã" + faceUrl ); |
| | | publishMqtt(superBrainEventInfo, "superBrain"); |
| | | } |
| | | |
| | | /** |
| | |
| | | .filter(camera -> camera.getIp().equals(ip) && camera.getPort() == port) |
| | | .findFirst(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ç¸æºæªå¾ |
| | |
| | | int bySecond = netDvrTimeEx.dwSecond; |
| | | return wYear + "-" + byMonth + "-" + byDay + " " + byHour + ":" + byMinute + ":" + bySecond; |
| | | } |
| | | |
| | | } |