Example #1
0
        private void btnGet_Click(object sender, EventArgs e)
        {
            if (m_lGetFaceParamCfgHandle != -1)
            {
                CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFaceParamCfgHandle);
            }

            listViewFaceConfig.Items.Clear();
            LpArr.Clear();

            CHCNetSDK.NET_DVR_FACE_PARAM_COND struCond = new CHCNetSDK.NET_DVR_FACE_PARAM_COND();
            struCond.Init();
            struCond.dwSize    = (uint)Marshal.SizeOf(struCond);
            struCond.dwFaceNum = (uint)IndexOfListview;
            struCond.byFaceID  = Convert.ToByte(textBoxFaceID.Text.ToString());
            StrToByteArray(ref struCond.byCardNo, textBoxAssociatedCardNo.Text);
            GetCardReaderIndex(ref struCond.byEnableCardReader);

            int    dwSize      = Marshal.SizeOf(struCond);
            IntPtr ptrStruCond = Marshal.AllocHGlobal(dwSize);

            Marshal.StructureToPtr(struCond, ptrStruCond, true);
            g_fGetFaceParamCallback  = new CHCNetSDK.RemoteConfigCallback(ProcessGetFaceParam);
            m_lGetFaceParamCfgHandle = CHCNetSDK.NET_DVR_StartRemoteConfig(m_lServerID, CHCNetSDK.NET_DVR_GET_FACE_PARAM_CFG, ptrStruCond, dwSize, g_fGetFaceParamCallback, this.Handle);
            if (-1 == m_lGetFaceParamCfgHandle)
            {
                g_formList.AddLog(m_iDevIndex, AcsDemoPublic.OPERATION_FAIL_T, "NET_DVR_GET_FACE_PARAM_CFG failed");
            }
            else
            {
                g_formList.AddLog(m_iDevIndex, AcsDemoPublic.OPERATION_SUCC_T, "NET_DVR_GET_FACE_PARAM_CFG success");
            }

            Marshal.FreeHGlobal(ptrStruCond);
        }
Example #2
0
        private void btnSet_Click(object sender, EventArgs e)
        {
            if (m_lSetFaceParamCfgHandle != -1)
            {
                CHCNetSDK.NET_DVR_StopRemoteConfig(m_lSetFaceParamCfgHandle);
            }

            CHCNetSDK.NET_DVR_FACE_PARAM_COND StruCond = new CHCNetSDK.NET_DVR_FACE_PARAM_COND();
            StruCond.dwSize    = (uint)Marshal.SizeOf(StruCond);
            StruCond.dwFaceNum = (uint)IndexOfListview;
            int    dwSize      = (int)StruCond.dwSize;
            IntPtr PtrStruCond = Marshal.AllocHGlobal(dwSize);

            Marshal.StructureToPtr(StruCond, PtrStruCond, true);
            g_fSetFaceParamCallback  = new CHCNetSDK.RemoteConfigCallback(ProcessSetFaceParamCallback);
            m_lSetFaceParamCfgHandle = CHCNetSDK.NET_DVR_StartRemoteConfig(m_lServerID, CHCNetSDK.NET_DVR_SET_FACE_PARAM_CFG, PtrStruCond, dwSize, g_fSetFaceParamCallback, this.Handle);
            //int i =(int)CHCNetSDK.NET_DVR_GetLastError();
            if (-1 == m_lSetFaceParamCfgHandle)
            {
                g_formList.AddLog(m_iDevIndex, AcsDemoPublic.OPERATION_FAIL_T, "NET_DVR_SET_FACE_PARAM_CFG failed");
            }
            else
            {
                g_formList.AddLog(m_iDevIndex, AcsDemoPublic.OPERATION_SUCC_T, "NET_DVR_SET_FACE_PARAM_CFG success");
            }
            Marshal.FreeHGlobal(PtrStruCond);

            m_dwSendIndex = 0;
            if (!SendFirstFace())
            {
                CHCNetSDK.NET_DVR_StopRemoteConfig(m_lSetFaceParamCfgHandle);
                m_lSetFaceParamCfgHandle = -1;
            }
        }
        private void buttonGet_Click(object sender, EventArgs e)
        {
            if (-1 != m_lGetFaceCfgHandle)
            {
                if (CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFaceCfgHandle))
                {
                    m_lGetFaceCfgHandle = -1;
                }
            }
            CHCNetSDK.NET_DVR_FACE_PARAM_COND struCond = new CHCNetSDK.NET_DVR_FACE_PARAM_COND();
            struCond.dwSize                = (uint)Marshal.SizeOf(struCond);
            struCond.dwFaceNum             = 1;
            struCond.byFaceID              = 1;
            struCond.byEnableCardReader    = new byte[CHCNetSDK.MAX_CARD_READER_NUM_512];
            struCond.byEnableCardReader[0] = 1;
            if ("" == textBoxCardNo.Text)
            {
                MessageBox.Show("Please input the card number!");
                return;
            }
            struCond.byCardNo = new byte[CHCNetSDK.ACS_CARD_NO_LEN];
            byte[] byTempCardNo = System.Text.Encoding.UTF8.GetBytes(textBoxCardNo.Text);
            for (int i = 0; i < byTempCardNo.Length; i++)
            {
                if (i > struCond.byCardNo.Length)
                {
                    MessageBox.Show("card number length too long!");
                    return;
                }
                struCond.byCardNo[i] = byTempCardNo[i];
            }

            int    dwSize      = Marshal.SizeOf(struCond);
            IntPtr ptrStruCond = Marshal.AllocHGlobal(dwSize);

            Marshal.StructureToPtr(struCond, ptrStruCond, false);
            g_fGetFaceParamCallback = new CHCNetSDK.RemoteConfigCallback(ProcessGetFaceParamCallback);
            m_lGetFaceCfgHandle     = CHCNetSDK.NET_DVR_StartRemoteConfig(m_lUserID, CHCNetSDK.NET_DVR_GET_FACE_PARAM_CFG, ptrStruCond, dwSize, g_fGetFaceParamCallback, this.Handle);
            if (-1 == m_lGetFaceCfgHandle)
            {
                g_formList.AddLog(m_lDeviceIndex, AcsDemoPublic.OPERATION_FAIL_T, "NET_DVR_GET_FACE_PARAM_CFG");
            }
            else
            {
                g_formList.AddLog(m_lDeviceIndex, AcsDemoPublic.OPERATION_SUCC_T, "NET_DVR_GET_FACE_PARAM_CFG");
            }
            Marshal.FreeHGlobal(ptrStruCond);
        }
Example #4
0
        /// <summary>
        /// 构造“人脸参数配置条件结构体” (查询)
        /// </summary>
        /// <param name="cardNo"></param>
        /// <returns></returns>
        private CHCNetSDK.NET_DVR_FACE_PARAM_COND BuildFaceParamCondStruct(string cardNo)
        {
            CHCNetSDK.NET_DVR_FACE_PARAM_COND struFaceParamCond = new CHCNetSDK.NET_DVR_FACE_PARAM_COND();

            struFaceParamCond.dwSize                = (uint)Marshal.SizeOf(struFaceParamCond);
            struFaceParamCond.dwFaceNum             = 1;
            struFaceParamCond.byFaceID              = 1;
            struFaceParamCond.byEnableCardReader    = new byte[CHCNetSDK.MAX_CARD_READER_NUM_512];
            struFaceParamCond.byEnableCardReader[0] = 1;

            struFaceParamCond.byCardNo = new byte[CHCNetSDK.ACS_CARD_NO_LEN];
            byte[] byTempCardNo = System.Text.Encoding.GetEncoding(PreSettings.charset).GetBytes(cardNo);
            byTempCardNo.CopyTo(struFaceParamCond.byCardNo, 0);

            return(struFaceParamCond);
        }
Example #5
0
        /// <summary>
        /// 给指定的卡号下发人脸数据
        /// </summary>
        /// <param name="deviceUserId"></param>
        /// <param name="cbStateCallback"></param>
        /// <param name="pUserData"></param>
        /// <param name="sCardNo"></param>
        /// <param name="byFacePic"></param>
        /// <returns></returns>
        public int StartRemoteConfigForFaceInsert(
            int deviceUserId,
            CHCNetSDK.RemoteConfigCallback cbStateCallback,
            IntPtr pUserData,
            string sCardNo)
        {
            int  handle  = -1;
            uint command = CHCNetSDK.NET_DVR_SET_FACE_PARAM_CFG;

            CHCNetSDK.NET_DVR_FACE_PARAM_COND struFaceParamCond = BuildFaceParamCondStruct(sCardNo);
            int    struFaceParamCondSize = Marshal.SizeOf(struFaceParamCond);
            IntPtr ptrFaceParaCond       = Marshal.AllocHGlobal(struFaceParamCondSize);

            Marshal.StructureToPtr(struFaceParamCond, ptrFaceParaCond, false);

            handle = CHCNetSDK.NET_DVR_StartRemoteConfig(deviceUserId, command, ptrFaceParaCond, (uint)struFaceParamCondSize, cbStateCallback, pUserData);

            Marshal.FreeHGlobal(ptrFaceParaCond);

            return(handle);
        }
        private void buttonPut_Click(object sender, EventArgs e)
        {
            if (-1 != m_lSetFaceCfgHandle)
            {
                if (CHCNetSDK.NET_DVR_StopRemoteConfig(m_lSetFaceCfgHandle))
                {
                    m_lSetFaceCfgHandle = -1;
                }
            }
            CHCNetSDK.NET_DVR_FACE_PARAM_COND struCond = new CHCNetSDK.NET_DVR_FACE_PARAM_COND();
            struCond.dwSize                = (uint)Marshal.SizeOf(struCond);
            struCond.dwFaceNum             = 1;
            struCond.byFaceID              = 1;
            struCond.byEnableCardReader    = new byte[CHCNetSDK.MAX_CARD_READER_NUM_512];
            struCond.byEnableCardReader[0] = 1;
            if ("" == textBoxCardNo.Text)
            {
                MessageBox.Show("Please input the card number!");
                return;
            }
            struCond.byCardNo = new byte[CHCNetSDK.ACS_CARD_NO_LEN];
            byte[] byTempCardNo = System.Text.Encoding.UTF8.GetBytes(textBoxCardNo.Text);
            for (int i = 0; i < byTempCardNo.Length; i++)
            {
                if (i > struCond.byCardNo.Length)
                {
                    MessageBox.Show("card number length too long!");
                    return;
                }
                struCond.byCardNo[i] = byTempCardNo[i];
            }

            int    dwSize      = Marshal.SizeOf(struCond);
            IntPtr ptrStruCond = Marshal.AllocHGlobal(dwSize);

            Marshal.StructureToPtr(struCond, ptrStruCond, false);
            g_fSetFaceParamCallback = new CHCNetSDK.RemoteConfigCallback(ProcessSetFaceParamCallback);
            m_lSetFaceCfgHandle     = CHCNetSDK.NET_DVR_StartRemoteConfig(m_lUserID, CHCNetSDK.NET_DVR_SET_FACE_PARAM_CFG, ptrStruCond, dwSize, g_fSetFaceParamCallback, this.Handle);
            if (-1 == m_lSetFaceCfgHandle)
            {
                g_formList.AddLog(m_lDeviceIndex, AcsDemoPublic.OPERATION_FAIL_T, "NET_DVR_SET_FACE_PARAM_CFG");
            }
            else
            {
                g_formList.AddLog(m_lDeviceIndex, AcsDemoPublic.OPERATION_SUCC_T, "NET_DVR_SET_FACE_PARAM_CFG");
            }
            Marshal.FreeHGlobal(ptrStruCond);

            CHCNetSDK.NET_DVR_FACE_PARAM_CFG struFaceParamCfg = new CHCNetSDK.NET_DVR_FACE_PARAM_CFG();
            struFaceParamCfg.dwSize                = (uint)Marshal.SizeOf(struFaceParamCfg);
            struFaceParamCfg.byFaceID              = 1;
            struFaceParamCfg.byFaceDataType        = 1;
            struFaceParamCfg.byEnableCardReader    = new byte[CHCNetSDK.MAX_CARD_READER_NUM_512];
            struFaceParamCfg.byEnableCardReader[0] = 1;
            struFaceParamCfg.byCardNo              = new byte[CHCNetSDK.ACS_CARD_NO_LEN];
            byte[] byTempFaceCardNo = System.Text.Encoding.UTF8.GetBytes(textBoxCardNo.Text);
            for (int i = 0; i < byTempFaceCardNo.Length; i++)
            {
                if (i > struFaceParamCfg.byCardNo.Length)
                {
                    MessageBox.Show("card number length too long!");
                    return;
                }
                struFaceParamCfg.byCardNo[i] = byTempFaceCardNo[i];
            }

            if (!File.Exists(textBoxFacePicturePath.Text))
            {
                MessageBox.Show("The face picture does not exist!");
                return;
            }
            FileStream fs = new FileStream(textBoxFacePicturePath.Text, FileMode.OpenOrCreate);

            if (0 == fs.Length)
            {
                MessageBox.Show("The face picture is 0k,please input another picture!");
                return;
            }
            if (200 * 1024 < fs.Length)
            {
                MessageBox.Show("The face picture is larger than 200k,please input another picture!");
                return;
            }

            struFaceParamCfg.dwFaceLen = (uint)fs.Length;
            int iLen = (int)struFaceParamCfg.dwFaceLen;

            byte[] by = new byte[iLen];
            struFaceParamCfg.pFaceBuffer = Marshal.AllocHGlobal(iLen);
            fs.Read(by, 0, iLen);
            Marshal.Copy(by, 0, struFaceParamCfg.pFaceBuffer, iLen);
            fs.Close();

            uint   dwParamSize         = (uint)Marshal.SizeOf(struFaceParamCfg);
            IntPtr ptrStruFaceParamCfg = Marshal.AllocHGlobal((int)dwParamSize);

            Marshal.StructureToPtr(struFaceParamCfg, ptrStruFaceParamCfg, false);

            if (!CHCNetSDK.NET_DVR_SendRemoteConfig(m_lSetFaceCfgHandle, 9, ptrStruFaceParamCfg, dwParamSize))
            {
                g_formList.AddLog(m_lDeviceIndex, AcsDemoPublic.OPERATION_FAIL_T, "set face picture failed!");
            }

            Marshal.FreeHGlobal(struFaceParamCfg.pFaceBuffer);
            Marshal.FreeHGlobal(ptrStruFaceParamCfg);

            return;
        }