//摄像机回调函数
 public void CaremaCall(IntPtr buf, int len, IntPtr PlateNo, ref byte PlateColor, IntPtr PlateBrand, int vehtype, int res)
 {
     try
     {
         MF.CameraCanpost.WaitOne(1000);
         MF.AddOperLogCacheStr("摄像机进入回调");
         FlieClass fc          = new FlieClass();
         byte[]    VehImage    = new byte[len];
         string    sPlate      = "";
         string    sPlateBrand = "";
         Marshal.Copy(buf, VehImage, 0, len);
         byte[] l_PlateNo = new byte[16];
         Marshal.Copy(PlateNo, l_PlateNo, 0, 16);
         if (res == 0)
         {
             sPlate = Encoding.Default.GetString(l_PlateNo);
             sPlate = sPlate.Substring(0, sPlate.IndexOf("\0"));
         }
         else
         {
             sPlate = "无车牌";
         }
         if (sPlate == "")
         {
             sPlate = "无牌车";
         }
         byte[] l_PlateBrand = new byte[12];
         Marshal.Copy(PlateBrand, l_PlateBrand, 0, 12);
         sPlateBrand         = Encoding.Default.GetString(l_PlateBrand);
         sPlateBrand         = sPlateBrand.Substring(0, sPlateBrand.IndexOf("\0"));
         GetVehicleLogoRecog = sPlateBrand;
         GetPlateNo          = sPlate;
         MF.AddOperLogCacheStr("车牌;" + GetPlateNo);
         string   dirpath     = ".\\plateimage\\";
         DateTime forcetimedt = DateTime.Now;
         string   forcetime   = forcetimedt.ToString("yyyyMMddHHmmss");
         string   imagename   = forcetime + sPlate + ".jpg";
         dirpath  += DateTime.Now.Year.ToString();
         dirpath  += "年\\";
         dirpath  += DateTime.Now.Month.ToString();
         dirpath  += "月\\";
         dirpath  += DateTime.Now.Day.ToString();
         dirpath  += "日\\";
         imagepath = dirpath + imagename;
         //string imagepath = dirpath + imagename + "车型" + vehtype.ToString();
         if (true == fc.WriteFileImage(dirpath, imagename, VehImage, 0, len))
         {
             MF.CameraPicture.Set();
             MF.AddOperLogCacheStr("保存车牌图片成功!");
         }
         else
         {
             MF.AddOperLogCacheStr("保存车牌图片失败!");
         }
     }
     catch (Exception ex)
     {
         MF.AddOperLogCacheStr("保存车牌图片失败!");
     }
 }
示例#2
0
        public uint ProcessCommAlarm_ITSPlate(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
        {
            DateTime dtS = DateTime.Now;

            CHCNetSDK.NET_ITS_PLATE_RESULT struITSPlateResult = new CHCNetSDK.NET_ITS_PLATE_RESULT();
            uint dwSize = (uint)Marshal.SizeOf(struITSPlateResult);

            struITSPlateResult = (CHCNetSDK.NET_ITS_PLATE_RESULT)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_ITS_PLATE_RESULT));
            TimeSpan ts = DateTime.Now - dtS;

            Log.WritePlateLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + " 摄像机抓拍完成时间1:" + ts.TotalMilliseconds + "\r\n");
            MF.CameraCanpost.WaitOne(1000);
            MF.AddOperLogCacheStr("进入报警布防回调函数,图片" + struITSPlateResult.dwPicNum.ToString() + "张..");
            string res  = "成功";
            int    iLen = (int)struITSPlateResult.struPicInfo[0].dwDataLen;

            byte[] by = new byte[iLen];
            if (iLen > 0)
            {
                res = "成功";
            }
            else
            {
                res = "失败";
            }
            MF.AddOperLogCacheStr("取图返回:" + res);
            if (struITSPlateResult.struPlateInfo.sLicense.Equals("无车牌"))
            {
                GetPlateNo = "未检测";
            }
            else
            {
                string temp = "";
                switch (struITSPlateResult.struPlateInfo.byColor)
                {
                case 0:
                    temp = "蓝";
                    break;

                case 1:
                    temp = "黄";
                    break;

                case 2:
                    temp = "白";
                    break;

                case 3:
                    temp = "黑";
                    break;

                case 4:
                    temp = "绿";
                    break;

                default:
                    break;
                }
                GetPlateNo = struITSPlateResult.struPlateInfo.sLicense;
            }
            if (GetPlateNo.Equals(""))
            {
                GetPlateNo = "无牌车";
            }
            MF.AddOperLogCacheStr("车牌: " + GetPlateNo);
            GetVehicleLogoRecog = "";
            GetVehicleLogoRecog = CHCNetSDK.VLR_VEHICLE_CLASS[struITSPlateResult.struVehicleInfo.byVehicleLogoRecog];
            FlieClass fc          = new FlieClass();
            string    dirpath     = GlobalMember.SavePicPath + "\\";
            DateTime  forcetimedt = DateTime.Now;
            string    forcetime   = forcetimedt.ToString("yyyyMMddHHmmss");
            string    imagename   = forcetime + GetPlateNo + ".bmp";

            dirpath  += DateTime.Now.Year.ToString();
            dirpath  += "年\\";
            dirpath  += DateTime.Now.Month.ToString();
            dirpath  += "月\\";
            dirpath  += DateTime.Now.Day.ToString();
            dirpath  += "日\\";
            imagepath = dirpath + imagename;
            //暂时放这里
            ts = DateTime.Now - dtS;
            Log.WritePlateLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + " 摄像机抓拍完成时间2:" + ts.TotalMilliseconds + "\r\n");

            Marshal.Copy(struITSPlateResult.struPicInfo[0].pBuffer, by, 0, iLen);
            try
            {
                if (true == fc.WriteFileImage(dirpath, imagename, by, 0, iLen))
                {
                    //MF.CameraCanpost.WaitOne(300);
                    MF.CameraPicture.Set();
                    ts = DateTime.Now - dtS;
                    Log.WritePlateLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + " 摄像机抓拍完成时间3:" + ts.TotalMilliseconds + "\r\n");
                }
                else
                {
                    MF.AddOperLogCacheStr("保存车牌图片失败!");
                    return(1);
                }
            }
            catch (Exception)
            {
                MF.AddOperLogCacheStr("保存车牌图片失败!");
                return(1);
            }
            //MF.CameraCanpost.Reset();
            return(0);
        }
示例#3
0
        //强制抓拍
        public int camera_ForceGetBigImage()
        {
            CHCNetSDK.NET_DVR_PLATE_RESULT struPlateResultInfo = new CHCNetSDK.NET_DVR_PLATE_RESULT();
            struPlateResultInfo.pBuffer1 = Marshal.AllocHGlobal(2 * 1024 * 1024);
            struPlateResultInfo.pBuffer2 = Marshal.AllocHGlobal(1024 * 1024);
            CHCNetSDK.NET_DVR_MANUALSNAP struInter = new CHCNetSDK.NET_DVR_MANUALSNAP();
            struInter.byLaneNo = 1;
            if (!CHCNetSDK.NET_DVR_ManualSnap(m_lUserID, ref struInter, ref struPlateResultInfo))
            {
                uint   iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                string strErr   = "NET_DVR_ManualSnap failed, error code= " + iLastErr;
                MF.AddOperLogCacheStr(strErr);

                Marshal.FreeHGlobal(struPlateResultInfo.pBuffer1);
                Marshal.FreeHGlobal(struPlateResultInfo.pBuffer2);
                return(-1);
            }
            else
            {
                int iLen = (int)struPlateResultInfo.dwPicLen;;
                if (iLen > 0)
                {
                    byte[] by = new byte[iLen];
                    if (struPlateResultInfo.struPlateInfo.sLicense.Equals("无车牌"))
                    {
                        GetPlateNo = "未检测";
                    }
                    else
                    {
                        string temp = "";
                        switch (struPlateResultInfo.struPlateInfo.byColor)
                        {
                        case 0:
                            temp = "蓝";
                            break;

                        case 1:
                            temp = "黄";
                            break;

                        case 2:
                            temp = "白";
                            break;

                        case 3:
                            temp = "黑";
                            break;

                        case 4:
                            temp = "绿";
                            break;

                        default:
                            break;
                        }
                        GetPlateNo = struPlateResultInfo.struPlateInfo.sLicense;
                    }
                    GetVehicleLogoRecog = "";
                    GetVehicleLogoRecog = CHCNetSDK.VLR_VEHICLE_CLASS[struPlateResultInfo.struVehicleInfo.byVehicleLogoRecog];

                    FlieClass fc          = new FlieClass();
                    string    dirpath     = GlobalMember.SavePicPath + "\\";
                    DateTime  forcetimedt = DateTime.Now;
                    string    forcetime   = forcetimedt.ToString("yyyyMMddHHmmss");
                    string    imagename   = forcetime + GetPlateNo + ".bmp";
                    dirpath  += DateTime.Now.Year.ToString();
                    dirpath  += "年\\";
                    dirpath  += DateTime.Now.Month.ToString();
                    dirpath  += "月\\";
                    dirpath  += DateTime.Now.Day.ToString();
                    dirpath  += "日\\";
                    imagepath = dirpath + imagename;
                    Marshal.Copy(struPlateResultInfo.pBuffer1, by, 0, iLen);
                    try
                    {
                        if (true == fc.WriteFileImage(dirpath, imagename, by, 0, iLen))
                        {
                            Marshal.FreeHGlobal(struPlateResultInfo.pBuffer1);
                            Marshal.FreeHGlobal(struPlateResultInfo.pBuffer2);
                            return(0);
                        }
                        else
                        {
                            Marshal.FreeHGlobal(struPlateResultInfo.pBuffer1);
                            Marshal.FreeHGlobal(struPlateResultInfo.pBuffer2);
                            //AddOperLogCacheStr("保存车牌图片失败!");
                            return(-1);
                        }
                    }
                    catch (Exception)
                    {
                        //AddOperLogCacheStr("保存车牌图片失败!");
                        Marshal.FreeHGlobal(struPlateResultInfo.pBuffer1);
                        Marshal.FreeHGlobal(struPlateResultInfo.pBuffer2);
                        return(-1);
                    }
                }
            }
            return(0);
        }