コード例 #1
0
        public void OpenDevice1(IntPtr pictureHand)
        {
            string ip       = IniFiles.iniFile.IniReadValue("device1", "ip");
            string com      = IniFiles.iniFile.IniReadValue("device1", "com");
            string user     = IniFiles.iniFile.IniReadValue("device1", "user");
            string password = IniFiles.iniFile.IniReadValue("device1", "password");

            Log.myLog.Info("ip=" + ip);
            Log.myLog.Info("com=" + com);
            Log.myLog.Info("user="******"password="******"打开设备失败!");
                return;
            }

            //输出到pictureBox_in_video
            VzClientSDK.VzLPRClient_SetPlateInfoCallBack(handle, null, IntPtr.Zero, 0);
            int m_nPlayHandle2 = VzClientSDK.VzLPRClient_StartRealPlay(handle, pictureHand);

            // 设置车牌识别结果回调
            m_PlateResultCB1 = new VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK(OnPlateResult1);
            VzClientSDK.VzLPRClient_SetPlateInfoCallBack(handle, m_PlateResultCB1, IntPtr.Zero, 1);
        }
コード例 #2
0
        //开启接收组网结果
        private void btnGroupOpen_Click(object sender, EventArgs e)
        {
            int lprHandle = GetSeleHandle();

            if (lprHandle == 0)
            {
                MessageBox.Show("请选择一台列表中的设备");
                return;
            }

            string strDeviceIP = GetSeleDeviceIP();
            int    retSetDG    = VzClientSDK.VzLPRClient_SetDGResultEnable(lprHandle, true);

            if (retSetDG != 0)
            {
                MessageBox.Show(strDeviceIP + "开启接收组网结果失败!", "提示");
                return;
            }

            this.listViewOpenDevice.SelectedItems[0].SubItems[1].Text = "是";
            //MessageBox.Show(strDeviceIP + "开启接收组网结果成功!", "提示");

            //设置识别结果的回调函数(组网)
            if (flag < 10)
            {
                m_PlateGroupResult[flag] = new VzClientSDK.VZLPRC_PLATE_GROUP_INFO_CALLBACK(OnPlateGroupInfo);
                VzClientSDK.VzLPRClient_SetPlateGroupInfoCallBack(lprHandle, m_PlateGroupResult[flag], IntPtr.Zero);
                flag++;
            }
            else
            {
                MessageBox.Show("开启接收组网结果的设备已达到10个,请关闭一些设备!");
                return;
            }
        }
コード例 #3
0
        private int OnPlateResult2(int handle, IntPtr pUserData,
                                   IntPtr pResult, uint uNumPlates,
                                   VzClientSDK.VZ_LPRC_RESULT_TYPE eResultType,
                                   IntPtr pImgFull,
                                   IntPtr pImgPlateClip)
        {
            if (eResultType != VzClientSDK.VZ_LPRC_RESULT_TYPE.VZ_LPRC_RESULT_REALTIME)
            {
                VzClientSDK.TH_PlateResult result = (VzClientSDK.TH_PlateResult)Marshal.PtrToStructure(pResult, typeof(VzClientSDK.TH_PlateResult));
                string strLicense = new string(result.license);

                //strLicense = strLicense.Replace(" ", "");
                //label_out_chepai.Text = strLicense;
                //strLicense = label_out_chepai.Text.Trim();

                if (Manager.instance.m_oldOutChepai == strLicense || strLicense.Contains(Manager.instance.m_oldOutChepai))
                {
                    Manager.instance.m_outChepaiChange = false;
                    return(0);
                }
                else
                {
                    Manager.instance.m_outChepaiChange = true;
                }

                Log.myLog.Info(string.Format("chepai='{0}'", strLicense));
                Log.myLog.Info("=======>strLicense:  " + strLicense);
                Log.myLog.Info("=======>m_oldOutChepai:  " + Manager.instance.m_oldOutChepai);

                VzClientSDK.VZ_LPR_MSG_PLATE_INFO plateInfo = new VzClientSDK.VZ_LPR_MSG_PLATE_INFO();
                plateInfo.plate = strLicense;

                DateTime now   = DateTime.Now;
                string   sTime = string.Format("{0:yyyyMMddHHmmssffff}", now);

                string strFilePath = m_sAppPath + "\\cap_out\\";
                if (!Directory.Exists(strFilePath))
                {
                    Directory.CreateDirectory(strFilePath);
                }

                string path = strFilePath + sTime + ".jpg";

                VzClientSDK.VzLPRClient_ImageSaveToJpeg(pImgFull, path, 100);


                //识别结果显示出来
                // label_out_chepai.Text = strLicense;
                //pictureBox_out_img.Image = Image.FromFile(path);
                UpdateOutChepai(strLicense);
                UpdateOutChepaiImage(path);

                Manager.instance.ledControl.OutLEDTextUpdate(strLicense, "进行中...");
            }

            return(0);
        }
コード例 #4
0
        //"手动识别"功能
        private void btnManual_Click(object sender, EventArgs e)
        {
            int lprHandle = GetSeleHandle();

            if (lprHandle == 0)
            {
                MessageBox.Show("请选择一台列表中的设备");
                return;
            }
            if (lprHandle > 0)
            {
                VzClientSDK.VzLPRClient_ForceTrigger(lprHandle);
            }
        }
コード例 #5
0
        //关闭设备
        private void btnCloseDevice_Click(object sender, EventArgs e)
        {
            int lprHandle = GetSeleHandle();

            if (lprHandle == 0)
            {
                MessageBox.Show("请选择一台列表中的设备");
                return;
            }

            int index = 0;

            if (lprHandle == GetPicBox1Handle())
            {
                if (m_nPlayHandle > 0)
                {
                    int ret = VzClientSDK.VzLPRClient_StopRealPlay(m_nPlayHandle);
                    m_nPlayHandle = 0;
                }

                Pic1Close();
                Pic3Close();
                lblPlateResult1.Text = "";
            }
            else
            {
                if (m_nPlayHandle2 > 0)
                {
                    int ret = VzClientSDK.VzLPRClient_StopRealPlay(m_nPlayHandle2);
                    m_nPlayHandle2 = 0;
                }

                Pic2Close();
                Pic4Close();
                lblPlateResult2.Text = "";
            }

            VzClientSDK.VzLPRClient_Close(lprHandle);

            //删除列表中当前选中项
            index = this.listViewOpenDevice.SelectedItems[0].Index;
            listViewOpenDevice.Items[index].Remove();
        }
コード例 #6
0
        //打开设备
        private void btnOpenDevice_Click(object sender, EventArgs e)
        {
            short nPort = Int16.Parse(textBoxPort.Text);

            //同一设备只能打开一次
            for (int i = 0; i < this.listViewOpenDevice.Items.Count; i++)
            {
                if (this.listViewOpenDevice.Items[i].Text == textBoxDeviceIP.Text)
                {
                    MessageBox.Show("该设备已打开", "提示");
                    return;
                }
            }

            //打开设备
            int handle = VzClientSDK.VzLPRClient_Open(textBoxDeviceIP.Text, (ushort)nPort, textBoxUserName.Text, textBoxPwd.Text);

            if (handle == 0)
            {
                MessageBox.Show("打开设备失败");
                return;
            }

            //打开的设备添加到列表
            ListViewItem item = new ListViewItem(textBoxDeviceIP.Text);

            item.SubItems.Add("否");
            item.Tag = handle;

            this.listViewOpenDevice.Items.Add(item);

            //选中当前打开的设备
            int size = this.listViewOpenDevice.Items.Count;

            for (int i = 0; i < this.listViewOpenDevice.SelectedItems.Count; i++)
            {
                this.listViewOpenDevice.Items[this.listViewOpenDevice.SelectedItems[i].Index].Selected = false; // 当前选中的设备IP设置为不选中
            }
            this.listViewOpenDevice.Items[size - 1].Selected = true;                                            //设定刚打开的设备选中
        }
コード例 #7
0
        //车牌识别结果回调
        private int OnPlateResult(int handle, IntPtr pUserData,
                                  IntPtr pResult, uint uNumPlates,
                                  VzClientSDK.VZ_LPRC_RESULT_TYPE eResultType,
                                  IntPtr pImgFull,
                                  IntPtr pImgPlateClip)
        {
            if (eResultType != VzClientSDK.VZ_LPRC_RESULT_TYPE.VZ_LPRC_RESULT_REALTIME)
            {
                VzClientSDK.TH_PlateResult result = (VzClientSDK.TH_PlateResult)Marshal.PtrToStructure(pResult, typeof(VzClientSDK.TH_PlateResult));
                string strLicense = new string(result.license);

                VzClientSDK.VZ_LPR_MSG_PLATE_INFO plateInfo = new VzClientSDK.VZ_LPR_MSG_PLATE_INFO();
                plateInfo.plate = strLicense;

                //设置视频截图保存图片的目录及格式
                DateTime nowTime = DateTime.Now;
                string   sTime   = string.Format("{0:yyyyMMddHHmmssffff}", nowTime);

                string strFilePath = m_sAppPath + "\\cap\\";
                if (!Directory.Exists(strFilePath))
                {
                    Directory.CreateDirectory(strFilePath);
                }

                string path = strFilePath + sTime + ".jpg";

                //将图像保存为JPEG到指定路径
                VzClientSDK.VzLPRClient_ImageSaveToJpeg(pImgFull, path, 100);
                plateInfo.img_path = path;

                int    size   = Marshal.SizeOf(plateInfo);
                IntPtr intptr = Marshal.AllocHGlobal(size);
                Marshal.StructureToPtr(plateInfo, intptr, true);

                Win32API.PostMessage(hwndMain, MSG_PLATE_INFO, (int)intptr, handle);//将消息推送给窗体
            }

            return(0);
        }
コード例 #8
0
        private void btnstopplay_Click(object sender, EventArgs e)
        {
            if (m_bFirst)
            {
                if (m_nPlayHandle > 0)
                {
                    VzClientSDK.VzLPRClient_StopRealPlay(m_nPlayHandle);
                    m_nPlayHandle = 0;
                }

                int lprHandle = GetPicBox1Handle();
                if (lprHandle > 0)
                {
                    VzClientSDK.VzLPRClient_SetPlateInfoCallBack(lprHandle, null, IntPtr.Zero, 0);
                }

                Pic1Close();
                Pic3Close();
            }
            else
            {
                if (m_nPlayHandle2 > 0)
                {
                    VzClientSDK.VzLPRClient_StopRealPlay(m_nPlayHandle2);
                    m_nPlayHandle2 = 0;
                }

                int lprHandle2 = GetPicBox2Handle();
                if (lprHandle2 > 0)
                {
                    VzClientSDK.VzLPRClient_SetPlateInfoCallBack(lprHandle2, null, IntPtr.Zero, 0);
                }

                Pic2Close();
                Pic4Close();
            }
        }
コード例 #9
0
        //停止组网车牌识别结果
        private void btnGroupClose_Click(object sender, EventArgs e)
        {
            int lprHandle = GetSeleHandle();

            if (lprHandle == 0)
            {
                MessageBox.Show("请选择一台列表中的设备");
                return;
            }

            string strDeviceIP = GetSeleDeviceIP();
            int    retSetDG    = VzClientSDK.VzLPRClient_SetDGResultEnable(lprHandle, false);//关闭“接收组网识别结果"

            if (retSetDG != 0)
            {
                MessageBox.Show(strDeviceIP + "停止接收组网结果失败!", "提示");
                return;
            }

            this.listViewOpenDevice.SelectedItems[0].SubItems[1].Text = "否";
            //MessageBox.Show(strDeviceIP + "停止接收组网结果成功!", "提示");

            VzClientSDK.VzLPRClient_SetPlateGroupInfoCallBack(lprHandle, null, IntPtr.Zero);
        }
コード例 #10
0
        //初始化
        private void VzGroupNetDemo_Load(object sender, EventArgs e)
        {
            VzClientSDK.VzLPRClient_Setup();

            //初始化"设备列表"
            this.listViewOpenDevice.Columns.Add("设备IP");
            this.listViewOpenDevice.Columns.Add("是否接受组网结果");
            this.listViewOpenDevice.View             = System.Windows.Forms.View.Details;
            this.listViewOpenDevice.FullRowSelect    = true;
            this.listViewOpenDevice.GridLines        = true;
            this.listViewOpenDevice.Columns[0].Width = 90;
            this.listViewOpenDevice.Columns[1].Width = 120;


            //初始化"组网车牌识别结果"列表
            this.listView1.Columns.Add("设备IP");
            this.listView1.Columns.Add("车牌号");
            this.listView1.Columns.Add("入口时间");
            this.listView1.Columns.Add("出口时间");
            this.listView1.Columns.Add("时间间隔");
            this.listView1.View          = System.Windows.Forms.View.Details;
            this.listView1.FullRowSelect = true;
            this.listView1.GridLines     = true;
            listView1.Columns[0].Width   = 110;
            listView1.Columns[1].Width   = 100;
            listView1.Columns[2].Width   = 160;
            listView1.Columns[3].Width   = 160;
            listView1.Columns[4].Width   = 120;

            hwndMain = this.Handle;

            m_sAppPath = System.IO.Directory.GetCurrentDirectory();

            m_originalColor = pictureBox1.BackColor;
            m_bFirst        = true;
        }
コード例 #11
0
 //关闭窗口
 private void VzGroupNetDemo_FormClosed(object sender, FormClosedEventArgs e)
 {
     VzClientSDK.VzLPRClient_Cleanup();
 }
コード例 #12
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();
            }
        }
コード例 #13
0
        //输出功能
        private void btnOutput_Click(object sender, EventArgs e)
        {
            int lprHandle = GetSeleHandle();

            if (lprHandle == 0)
            {
                MessageBox.Show("请选择一台列表中的设备", "提示");
                return;
            }

            if (lprHandle == GetPicBox1Handle() || lprHandle == GetPicBox2Handle())
            {
                MessageBox.Show("该设备已经输出在视频窗口中", "提示");
                return;
            }

            //在第一个视频窗口播放视频
            if (m_bFirst)
            {
                pictureBox1.Image = null;//不显示图片

                if (m_nPlayHandle > 0)
                {
                    VzClientSDK.VzLPRClient_StopRealPlay(m_nPlayHandle);//停止当前播放的视频
                    m_nPlayHandle = 0;
                }

                int picHandle1 = GetPicBox1Handle();
                if (picHandle1 > 0)
                {
                    VzClientSDK.VzLPRClient_SetPlateInfoCallBack(picHandle1, null, IntPtr.Zero, 0);//清空上一个车牌识别结果
                }

                m_nPlayHandle   = VzClientSDK.VzLPRClient_StartRealPlay(lprHandle, pictureBox1.Handle);//播放实时视频
                pictureBox1.Tag = lprHandle;

                //设置车牌识别结果回调
                m_PlateResultCB = new VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK(OnPlateResult);
                VzClientSDK.VzLPRClient_SetPlateInfoCallBack(lprHandle, m_PlateResultCB, IntPtr.Zero, 1);
            }
            //在第二个视频窗口播放视频
            else
            {
                pictureBox2.Image = null;//不显示图片

                if (m_nPlayHandle2 > 0)
                {
                    VzClientSDK.VzLPRClient_StopRealPlay(m_nPlayHandle2);//停止当前播放的视频
                    m_nPlayHandle2 = 0;
                }

                int picHandle2 = GetPicBox2Handle();
                if (picHandle2 > 0)
                {
                    VzClientSDK.VzLPRClient_SetPlateInfoCallBack(picHandle2, null, IntPtr.Zero, 0);//清空上一个车牌识别结果
                }

                m_nPlayHandle2  = VzClientSDK.VzLPRClient_StartRealPlay(lprHandle, pictureBox2.Handle);//播放实时视频
                pictureBox2.Tag = lprHandle;

                //设置车牌识别结果回调
                m_PlateResultCB2 = new VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK(OnPlateResult);
                VzClientSDK.VzLPRClient_SetPlateInfoCallBack(lprHandle, m_PlateResultCB2, IntPtr.Zero, 1);
            }
        }
コード例 #14
0
 public void Init()
 {
     VzClientSDK.VzLPRClient_Setup();
     m_sAppPath = System.IO.Directory.GetCurrentDirectory();
 }