/// <summary> /// 开始智能交通设备实时上传--回调 /// </summary> /// <param name="lAnalyzerHandle"></param> /// <param name="dwAlarmType"></param> /// <param name="pAlarmInfo"></param> /// <param name="pBuffer"></param> /// <param name="dwBufSize"></param> /// <param name="dwUser"></param> /// <param name="nSequence"></param> /// <param name="reserved"></param> /// <returns></returns> private int AnalyzerDataCallBackEvent(Int32 lAnalyzerHandle, UInt32 dwAlarmType, IntPtr pAlarmInfo, IntPtr pBuffer, UInt32 dwBufSize, UInt32 dwUser, Int32 nSequence, IntPtr reserved) { if (dwBufSize == 0) { return(1); } try { CarPlateDevice device = _Devices.SingleOrDefault(d => d.m_nRealLoadPic == lAnalyzerHandle); if (device != null) { // 记录文件 byte[] buf = new byte[dwBufSize]; Marshal.Copy(pBuffer, buf, 0, (int)dwBufSize); DH_MSG_OBJECT plateObj = new DH_MSG_OBJECT(); DH_MSG_OBJECT VehicleObj = new DH_MSG_OBJECT(); NET_TIME_EX utc = new NET_TIME_EX(); int lane = 0; string strMsg; bool bret = DaHuaSDKManager.GetInstance().GetStuObject(dwAlarmType, pAlarmInfo, out plateObj, out VehicleObj, out utc, out lane, out strMsg); device.ResetResult(); if (plateObj.szText != null) { device.CarPlate = Encoding.GetEncoding("gb2312").GetString(plateObj.szText); } if (!string.IsNullOrEmpty(device.CarPlate)) { device.CarPlate = device.CarPlate.TrimEnd('\0'); //去除结束符\0 } device.EventDateTime = DateTime.Now; if (plateObj.bColor == 1) { device.PlateColor = DaHuaSDKManager.GetInstance().GetColorString(plateObj.rgbaMainColor); } if (VehicleObj.bColor == 1) { device.CarColor = DaHuaSDKManager.GetInstance().GetColorString(VehicleObj.rgbaMainColor); } device.Lane = lane; try { device.DeviceSnapTime = new DateTime((int)utc.dwYear, (int)utc.dwMonth, (int)utc.dwDay, (int)utc.dwHour, (int)utc.dwMinute, (int)utc.dwSecond, (int)utc.dwMillisecond); } catch { } device.SnapPath = DaHuaSDKManager.GetInstance().SaveSnapImage(buf); device.PlatePath = DaHuaSDKManager.GetInstance().SavePlateJpg(plateObj, pBuffer, buf); foreach (DataGridViewRow row in dataGridView1.Rows) { CarPlateDevice d = row.Tag as CarPlateDevice; if (d != null) { if (d.m_nRealLoadPic == device.m_nRealLoadPic) { ShowItemOnRow(device, row); } } } if (_ActiveDevice != null && _ActiveDevice.m_nRealLoadPic == device.m_nRealLoadPic) { ShowCarPlateInfo(device); } } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } return(1); }
/// <summary> /// 获取识别对象 车身对象 事件发生时间 车道号等信息 /// </summary> /// <param name="dwAlarmType"></param> /// <param name="pAlarmInfo"></param> /// <returns></returns> public bool GetStuObject(UInt32 dwAlarmType, IntPtr pAlarmInfo, out DH_MSG_OBJECT stuObj, out DH_MSG_OBJECT vehicleObj, out NET_TIME_EX outUTC, out int outlane, out string strMsg) { DH_MSG_OBJECT msg = new DH_MSG_OBJECT(); DH_MSG_OBJECT veahcile = new DH_MSG_OBJECT(); NET_TIME_EX utc = new NET_TIME_EX(); int lane = 0; DH_EVENT_FILE_INFO fileinfo = new DH_EVENT_FILE_INFO(); string EventMsg = "未定义事件"; if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFICGATE) { DEV_EVENT_TRAFFICGATE_INFO Info = new DEV_EVENT_TRAFFICGATE_INFO(); Info = (DEV_EVENT_TRAFFICGATE_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFICGATE_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通卡口事件"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFICJUNCTION) { DEV_EVENT_TRAFFICJUNCTION_INFO Info = new DEV_EVENT_TRAFFICJUNCTION_INFO(); Info = (DEV_EVENT_TRAFFICJUNCTION_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFICJUNCTION_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通路口事件"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_RUNREDLIGHT) { DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO Info = new DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO(); Info = (DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通违章-闯红灯事件"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_TURNLEFT) { DEV_EVENT_TRAFFIC_TURNLEFT_INFO Info = new DEV_EVENT_TRAFFIC_TURNLEFT_INFO(); Info = (DEV_EVENT_TRAFFIC_TURNLEFT_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_TURNLEFT_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通违章-违章左转"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_TURNRIGHT) { DEV_EVENT_TRAFFIC_TURNRIGHT_INFO Info = new DEV_EVENT_TRAFFIC_TURNRIGHT_INFO(); Info = (DEV_EVENT_TRAFFIC_TURNRIGHT_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_TURNRIGHT_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通违章-违章右转"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_OVERSPEED) { DEV_EVENT_TRAFFIC_OVERSPEED_INFO Info = new DEV_EVENT_TRAFFIC_OVERSPEED_INFO(); Info = (DEV_EVENT_TRAFFIC_OVERSPEED_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_OVERSPEED_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通违章-超速"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_UNDERSPEED) { DEV_EVENT_TRAFFIC_UNDERSPEED_INFO Info = new DEV_EVENT_TRAFFIC_UNDERSPEED_INFO(); Info = (DEV_EVENT_TRAFFIC_UNDERSPEED_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_UNDERSPEED_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通违章-低速"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_MANUALSNAP) { DEV_EVENT_TRAFFIC_MANUALSNAP_INFO Info = new DEV_EVENT_TRAFFIC_MANUALSNAP_INFO(); Info = (DEV_EVENT_TRAFFIC_MANUALSNAP_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_MANUALSNAP_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通手动抓拍事件"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_PARKING) { DEV_EVENT_TRAFFIC_PARKING_INFO Info = new DEV_EVENT_TRAFFIC_PARKING_INFO(); Info = (DEV_EVENT_TRAFFIC_PARKING_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_PARKING_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "交通违章停车"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_PARKINGSPACENOPARKING) { DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO Info = new DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO(); Info = (DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "车位无车事件"; } else if (dwAlarmType == EventIvs.EVENT_IVS_TRAFFIC_PARKINGSPACEPARKING) { DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO Info = new DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO(); Info = (DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO)); stuObj = Info.stuObject; vehicleObj = Info.stuVehicle; outUTC = Info.UTC; outlane = Info.nLane; fileinfo = Info.stuFileInfo; EventMsg = "车位有车事件"; } else { stuObj = msg; vehicleObj = veahcile; outUTC = utc; outlane = 0; EventMsg = "未处理事件dwAlarmType = " + dwAlarmType.ToString(); } if (!EventMsg.Contains("未处理事件")) { EventMsg = EventMsg + ";组编号GroupID = " + fileinfo.nGroupId + ";图片组总数bount = " + fileinfo.bCount + ";当前图片序号bIndex=" + fileinfo.bIndex; try { //车牌 string platenumber = Encoding.GetEncoding("gb2312").GetString(stuObj.szText); string[] plate = platenumber.Split('\0'); if (plate.Length > 0) { EventMsg += ";车牌号 = " + plate[0]; } //车标 string strType = Encoding.GetEncoding("gb2312").GetString(vehicleObj.szText); string[] vechitypes = strType.Split('\0'); if (vechitypes.Length > 0) { // "Unknown"未知 // "Audi" 奥迪 // "Honda" 本田 // "Buick" 别克 // "Volkswagen" 大众 // "Toyota" 丰田 // "BMW" 宝马 // "Peugeot" 标致 // "Ford" 福特 // "Mazda" 马自达 // "Nissan" 尼桑 // "Hyundai" 现代 // "Suzuki" 铃木 // "Citroen" 雪铁龙 // "Benz" 奔驰 // "BYD" 比亚迪 // "Geely" 吉利 // "Lexus" 雷克萨斯 // "Chevrolet" 雪佛兰 // "Chery" 奇瑞 // "Kia" 起亚 // "Charade" 夏利 // "DF" 东风 // "Naveco" 依维柯 // "SGMW" 五菱 // "Jinbei" 金杯 if (!vechitypes[0].Equals("")) { EventMsg += ";车标 = " + vechitypes[0]; } } } catch { ; } finally { ; } } strMsg = EventMsg; return(true); }
public static extern IntPtr CLIENT_LoadOffLineFile(IntPtr lLoginID, int nChannelID, uint dwAlarmType, NET_TIME_EX lpStartTime, NET_TIME_EX lpEndTime, fAnalyzerDataCallBack cbAnalyzerData, IntPtr dwUser);