Ejemplo n.º 1
0
        // 获取识别结果的回调函数 (新的使用方式)
        public unsafe void WTYDataExCallback(IntPtr recResult)
        {
            WTY.plate_result recRes;
            string           sIp;

            /*
             * 注:
             *  客户在挂接的时候,不要将自己的事物处理放到此回调函数中。
             *  否则,可能会影响DLL的正常工作。
             *  将识别数据拷贝全局缓冲区,去处理。
             */
            WTY.plate_result recResult_ss = new WTY.plate_result();
            int size = Marshal.SizeOf(recResult_ss);

            byte[] bytes = new byte[size];
            Marshal.Copy(recResult, bytes, 0, size);
            recRes = ConverBytesToStructure <WTY.plate_result>(bytes);

            sIp = new string(recRes.chWTYIP);
            if (String.Compare(sIp, txtbox1.Trim(), true) == 0)
            {
                // 将识别结果拷贝全局缓冲区
                recRes1 = ConverBytesToStructure <WTY.plate_result>(bytes);
                // 通知显示线程去显示识别结果
                nCallbackTrigger1 = true;
            }
            if (String.Compare(sIp, txtbox2.Trim(), true) == 0)
            {
                // 将识别结果拷贝全局缓冲区
                recRes2 = ConverBytesToStructure <WTY.plate_result>(bytes);
                // 通知显示线程去显示识别结果
                nCallbackTrigger2 = true;
            }
        }
Ejemplo n.º 2
0
        //识别车牌
        public void pateShow(WTY.plate_result recResult, String fullImgFile, String plateImgFile, System.Windows.Forms.PictureBox FullImg, System.Windows.Forms.PictureBox PlateImg, Label lbl)
        {
            string fileNameTime = DateTime.Now.ToString("hh-mm-ss");

            recResult.shootTime.Year        = Convert.ToInt32(DateTime.Now.Year.ToString());
            recResult.shootTime.Month       = Convert.ToInt32(DateTime.Now.Month.ToString());
            recResult.shootTime.Day         = Convert.ToInt32(DateTime.Now.Day.ToString());
            recResult.shootTime.Hour        = Convert.ToInt32(DateTime.Now.Hour.ToString());
            recResult.shootTime.Minute      = Convert.ToInt32(DateTime.Now.Minute.ToString());
            recResult.shootTime.Second      = Convert.ToInt32(DateTime.Now.Second.ToString());
            recResult.shootTime.Millisecond = 2;
            //string fileNameTime = System.DateTime.Now.ToString();
            string directoryPath = recResult.chWTYIP.ToString();
            // 显示车牌
            string strLicesen = new string(recResult.chLicense);//车牌显示字符串
            string strColor   = new string(recResult.chColor);

            object[] Dl =
            {
                strLicesen,
                strColor,
                lbl
            };
            // int handle = new WindowInteropHelper(this).Handle.ToInt32();
            Dispatcher.BeginInvoke(new delShowPlate(ShowPlate), Dl);

            Directory.CreateDirectory(recResult.chWTYIP.ToString());

            // 显示识别时间
            object[] D2 =
            {
                recResult.shootTime.Year,
                recResult.shootTime.Month,
                recResult.shootTime.Day,
                recResult.shootTime.Hour,
                recResult.shootTime.Minute,
                recResult.shootTime.Second,
                recResult.shootTime.Millisecond
            };

            Dispatcher.BeginInvoke(new delShowRecogniseTime(ShowRecogniseTime), D2);


            // 显示识别坐标
            //object[] D3 = {
            //                 recResult.pcLocation.Left,
            //                 recResult.pcLocation.Top,
            //                 recResult.pcLocation.Right,
            //                 recResult.pcLocation.Bottom
            //              };
            //Dispatcher.BeginInvoke(new delShowPlateC(ShowPlateC), D3);

            // 显示识别图像
            if (recResult.nFullLen > 0)
            {
                // 保存全景图
                FullImg.Load("111.jpg");
                System.IO.FileStream fs = new System.IO.FileStream(fullImgFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, FileShare.ReadWrite);
                //System.IO.FileStream fs = new System.IO.FileStream(directoryPath + fileNameTime + ".jpg", System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, FileShare.ReadWrite);
                try
                {
                    fs.Write(recResult.chFullImage, 0, recResult.nFullLen);
                    fs.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                // 将全景图显示在界面上
                FullImg.Image = null;
                FileInfo fi = new FileInfo(fullImgFile);
                if (fi.Exists)
                {
                    FullImg.Load(fullImgFile);
                }
            }

            if (recResult.nPlateLen > 0)
            {
                // 保存车牌小图
                PlateImg.Load("112.jpg");
                System.IO.FileStream fs = new System.IO.FileStream(plateImgFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, FileShare.ReadWrite);
                try
                {
                    fs.Write(recResult.chPlateImage, 0, recResult.nPlateLen);
                    fs.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                // 将车牌小图显示在界面上
                PlateImg.Image = null;
                FileInfo fi = new FileInfo(plateImgFile);
                if (fi.Exists)
                {
                    PlateImg.Load(plateImgFile);
                }
            }
        }
Ejemplo n.º 3
0
        public void pateShowOut(WTY.plate_result recResult, String fullImgFile, String plateImgFile, System.Windows.Forms.PictureBox FullImg, System.Windows.Forms.PictureBox PlateImg, System.Windows.Controls.TextBox tbx)
        {
            string fileNameTime = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");//文件当前时间
            //string directoryPath = recResult.chWTYIP.ToString();//文件路径
            string directoryPath = Model.DicValue.Rootpath + "\\" + "Out";
            string strLicesen    = new string(recResult.chLicense);//车牌显示字符串
            string strColor      = new string(recResult.chColor);

            object[] Dl =
            {
                strLicesen,
                strColor,
                tbx
            };
            Dispatcher.BeginInvoke(new delShowPlate(ShowPlateOut), Dl);//显示识别结果
            Directory.CreateDirectory(recResult.chWTYIP.ToString());
            // 显示识别图像
            if (recResult.nFullLen > 0)
            {
                // 保存全景图
                FullImg.Load("113.jpg");
                //System.IO.FileStream fs = new System.IO.FileStream(fullImgFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, FileShare.ReadWrite);
                System.IO.FileStream fs = new System.IO.FileStream(directoryPath + fileNameTime + ".jpg", System.IO.FileMode.CreateNew, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite);
                string pathname         = fileNameTime + ".jpg";//获得图片路径
                Model.DicValue.Outpicpath = pathname.Replace("\\", "/");
                try
                {
                    fs.Write(recResult.chFullImage, 0, recResult.nFullLen);
                    fs.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                FullImg.Image.Dispose();
                FullImg.Image = null;
                FileInfo fi = new FileInfo(directoryPath + fileNameTime + ".jpg");
                if (fi.Exists)
                {
                    FullImg.Load(directoryPath + fileNameTime + ".jpg");
                }
            }
            if (recResult.nPlateLen > 0)
            {
                // 保存车牌小图
                PlateImg.Load("114.jpg");
                System.IO.FileStream fs = new System.IO.FileStream(plateImgFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, FileShare.ReadWrite);
                try
                {
                    fs.Write(recResult.chPlateImage, 0, recResult.nPlateLen);
                    fs.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                // 将车牌小图显示在界面上
                PlateImg.Image = null;
                FileInfo fi = new FileInfo(plateImgFile);
                if (fi.Exists)
                {
                    PlateImg.Load(plateImgFile);
                }
            }
        }