//设置组网识别结果的回调函数 private int OnPlateGroupInfo(int handle, IntPtr pUserData, int exitEntryInfo, IntPtr exitIvsInfo, IntPtr entryIvsInfo, IntPtr exitDGInfo, IntPtr entryDGInfo) { VzClientSDK.TH_PlateResult entryInfo = new VzClientSDK.TH_PlateResult(); VzClientSDK.TH_PlateResult exitInfo = new VzClientSDK.TH_PlateResult(); VzClientSDK.IVS_DG_DEVICE_INFO entryImageInfo = new VzClientSDK.IVS_DG_DEVICE_INFO(); VzClientSDK.IVS_DG_DEVICE_INFO exitImageInfo = new VzClientSDK.IVS_DG_DEVICE_INFO(); if (exitIvsInfo != null) { entryInfo = (VzClientSDK.TH_PlateResult)Marshal.PtrToStructure(entryIvsInfo, typeof(VzClientSDK.TH_PlateResult)); } if (entryIvsInfo != null) { exitInfo = (VzClientSDK.TH_PlateResult)Marshal.PtrToStructure(exitIvsInfo, typeof(VzClientSDK.TH_PlateResult)); } if (entryDGInfo != null) { entryImageInfo = (VzClientSDK.IVS_DG_DEVICE_INFO)Marshal.PtrToStructure(entryDGInfo, typeof(VzClientSDK.IVS_DG_DEVICE_INFO)); } if (exitDGInfo != null) { exitImageInfo = (VzClientSDK.IVS_DG_DEVICE_INFO)Marshal.PtrToStructure(exitDGInfo, typeof(VzClientSDK.IVS_DG_DEVICE_INFO)); } VzClientSDK.TH_GroupPlateResult groupPlateResult = new VzClientSDK.TH_GroupPlateResult(); //获取入口设备组网车牌识别结果 if (exitEntryInfo == 0) { //车牌号码 string strEntryLicense = new string(entryInfo.license); groupPlateResult.groupLicense = strEntryLicense; //入口时间 UInt64 entryTotalSeconds1 = entryInfo.tvPTS.uTVSec; string strEntryDateTime1 = date1970ConvertCurrentDate(entryTotalSeconds1); groupPlateResult.entryDateTime = strEntryDateTime1; } //获取出口设备组网车牌结果 else if (exitEntryInfo == 1) { //车牌号码 string strExitLicense2 = new string(entryInfo.license); groupPlateResult.groupLicense = strExitLicense2; //入口时间 UInt64 entryTotalSeconds2 = entryInfo.tvPTS.uTVSec; string EntryDateTime2 = date1970ConvertCurrentDate(entryTotalSeconds2); groupPlateResult.entryDateTime = EntryDateTime2; //出口时间 UInt64 exitTotalSeconds2 = exitInfo.tvPTS.uTVSec; string strExitDateTime2 = date1970ConvertCurrentDate(exitTotalSeconds2); groupPlateResult.exitDateTime = strExitDateTime2; //时间间隔 Int32 timeInterval = (Int32)(exitTotalSeconds2 - entryTotalSeconds2); string strTimeInterval = timeIntervalConvert(timeInterval); groupPlateResult.timeInterval = strTimeInterval; } //入口图片 if (entryInfo.uId > 0 && entryImageInfo.vzSN.ToString() != "") { string strEntrySN = new string(entryImageInfo.vzSN); char[] chrEntrySN = new char[17]; strEntrySN.CopyTo(0, chrEntrySN, 0, 17); string strNewEntrySN = new string(chrEntrySN); LoadGroupImg(handle, (int)entryInfo.uId, strNewEntrySN, 1); } //出口图片 if (exitInfo.uId > 0 && exitImageInfo.vzSN.ToString() != "") { string strExitSN = new string(exitImageInfo.vzSN); char[] chrExitSN = new char[17]; strExitSN.CopyTo(0, chrExitSN, 0, 17); string strNewExitSN = new string(chrExitSN); LoadGroupImg(handle, (int)exitInfo.uId, strNewExitSN, 0); } int size = Marshal.SizeOf(groupPlateResult); IntPtr intptr = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(groupPlateResult, intptr, true); Win32API.PostMessage(hwndMain, MSG_GROUP_PLATE_INFO, (int)intptr, handle);//将消息推送给窗体 return(0); }
//获取组网图片线程 private void LoadGroupImgThread(int handle, int id, string sn, int isEntry) { VzClientSDK.TH_GroupPlateResult groupImageResult = new VzClientSDK.TH_GroupPlateResult(); int nSize = 1280 * 720; byte[] picdata = new byte[1280 * 720]; GCHandle hObject = GCHandle.Alloc(picdata, GCHandleType.Pinned); //为指定的对象分配指定类型的句柄,允许使用固定对象的地址 IntPtr pObject = hObject.AddrOfPinnedObject(); //检索对象的地址 int ret = VzClientSDK.VzLPRClient_LoadGroupFullImageById(handle, id, sn, pObject, ref nSize); DateTime now = DateTime.Now; string sTime = string.Format("{0:yyyyMMddHHmmssffff}", now); string szImgDir = ""; string strFilePath = m_sAppPath + "\\组网"; if (!Directory.Exists(strFilePath)) { Directory.CreateDirectory(strFilePath); } if (isEntry == 1) { szImgDir = strFilePath + "\\入口"; if (!Directory.Exists(szImgDir)) { Directory.CreateDirectory(szImgDir); } } else { szImgDir = strFilePath + "\\出口"; if (!Directory.Exists(szImgDir)) { Directory.CreateDirectory(szImgDir); } } string path = szImgDir + "\\" + sTime + ".jpg"; if (nSize > 0 && nSize < 1280 * 720) { FileStream aFile = new FileStream(path, FileMode.Create); aFile.Seek(0, SeekOrigin.Begin); aFile.Write(picdata, 0, picdata.Length); aFile.Close(); } groupImageResult.img_path = path; int size = Marshal.SizeOf(groupImageResult); IntPtr intptr = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(groupImageResult, intptr, true); Win32API.PostMessage(hwndMain, MSG_GROUP_IMAGE_INFO, (int)intptr, isEntry);//将消息推送给窗体 if (hObject.IsAllocated) { hObject.Free(); } }