private void button6_Click(object sender, EventArgs e)
        {
            if (textBoxFilePath.Text == "")
            {
                MessageBox.Show("Please choose human Face path");
                return;
            }

            if (pictureBoxFace.Image != null)
            {
                pictureBoxFace.Image.Dispose();
                pictureBoxFace.Image = null;
            }

            CHCNetSDK.NET_DVR_FACE_COND struCond = new CHCNetSDK.NET_DVR_FACE_COND();
            struCond.init();
            struCond.dwSize    = Marshal.SizeOf(struCond);
            struCond.dwFaceNum = 1;
            int.TryParse(textBoxCardReaderNo.Text.ToString(), out struCond.dwEnableReaderNo);
            byte[] byTemp = System.Text.Encoding.UTF8.GetBytes(textBoxCardNo.Text);
            for (int i = 0; i < byTemp.Length; i++)
            {
                struCond.byCardNo[i] = byTemp[i];
            }

            int    dwInBufferSize = struCond.dwSize;
            IntPtr ptrstruCond    = Marshal.AllocHGlobal(dwInBufferSize);

            Marshal.StructureToPtr(struCond, ptrstruCond, false);
            m_lSetFaceCfgHandle = CHCNetSDK.NET_DVR_StartRemoteConfig(m_UserID, CHCNetSDK.NET_DVR_SET_FACE, ptrstruCond, dwInBufferSize, null, IntPtr.Zero);
            if (-1 == m_lSetFaceCfgHandle)
            {
                Marshal.FreeHGlobal(ptrstruCond);
                MessageBox.Show("NET_DVR_SET_FACE_FAIL, ERROR CODE" + CHCNetSDK.NET_DVR_GetLastError().ToString(), "Error", MessageBoxButtons.OK);
                return;
            }

            CHCNetSDK.NET_DVR_FACE_RECORD struRecord = new CHCNetSDK.NET_DVR_FACE_RECORD();
            struRecord.init();
            struRecord.dwSize = Marshal.SizeOf(struRecord);

            byte[] byRecordNo = System.Text.Encoding.UTF8.GetBytes(textBoxCardNo.Text);
            for (int i = 0; i < byRecordNo.Length; i++)
            {
                struRecord.byCardNo[i] = byRecordNo[i];
            }

            ReadFaceData(ref struRecord);
            int dwInBuffSize = Marshal.SizeOf(struRecord);
            int dwStatus     = 0;

            CHCNetSDK.NET_DVR_FACE_STATUS struStatus = new CHCNetSDK.NET_DVR_FACE_STATUS();
            struStatus.init();
            struStatus.dwSize = Marshal.SizeOf(struStatus);
            int    dwOutBuffSize = struStatus.dwSize;
            IntPtr ptrOutDataLen = Marshal.AllocHGlobal(sizeof(int));
            bool   Flag          = true;

            while (Flag)
            {
                dwStatus = CHCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lSetFaceCfgHandle, ref struRecord, dwInBuffSize, ref struStatus, dwOutBuffSize, ptrOutDataLen);
                switch (dwStatus)
                {
                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS:    //成功读取到数据,处理完本次数据后需调用next
                    ProcessSetFaceData(ref struStatus, ref Flag);
                    break;

                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_NEED_WAIT:
                    break;

                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_FAILED:
                    CHCNetSDK.NET_DVR_StopRemoteConfig(m_lSetFaceCfgHandle);
                    MessageBox.Show("NET_SDK_GET_NEXT_STATUS_FAILED" + CHCNetSDK.NET_DVR_GetLastError().ToString(), "Error", MessageBoxButtons.OK);
                    Flag = false;
                    break;

                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_FINISH:
                    CHCNetSDK.NET_DVR_StopRemoteConfig(m_lSetFaceCfgHandle);
                    Flag = false;
                    break;

                default:
                    MessageBox.Show("NET_SDK_GET_NEXT_STATUS_UNKOWN" + CHCNetSDK.NET_DVR_GetLastError().ToString(), "Error", MessageBoxButtons.OK);
                    Flag = false;
                    CHCNetSDK.NET_DVR_StopRemoteConfig(m_lSetFaceCfgHandle);
                    break;
                }
            }

            Marshal.FreeHGlobal(ptrstruCond);
            Marshal.FreeHGlobal(ptrOutDataLen);
        }
        private void btnGet_Click(object sender, EventArgs e)
        {
            if (m_lGetFaceCfgHandle != -1)
            {
                CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFaceCfgHandle);
                m_lGetFaceCfgHandle = -1;
            }

            if (pictureBoxFace.Image != null)
            {
                pictureBoxFace.Image.Dispose();
                pictureBoxFace.Image = null;
            }

            CHCNetSDK.NET_DVR_FACE_COND struCond = new CHCNetSDK.NET_DVR_FACE_COND();
            struCond.init();
            struCond.dwSize = Marshal.SizeOf(struCond);
            int dwSize = struCond.dwSize;

            if (textBoxCardReaderNo.Text.ToString() == "")
            {
                struCond.dwEnableReaderNo = 0;
            }
            else
            {
                int.TryParse(textBoxCardReaderNo.Text.ToString(), out struCond.dwEnableReaderNo);
            }
            struCond.dwFaceNum = 1;//人脸数量是1
            byte[] byTemp = System.Text.Encoding.UTF8.GetBytes(textBoxCardNo.Text);
            for (int i = 0; i < byTemp.Length; i++)
            {
                struCond.byCardNo[i] = byTemp[i];
            }

            IntPtr ptrStruCond = Marshal.AllocHGlobal(dwSize);

            Marshal.StructureToPtr(struCond, ptrStruCond, false);

            m_lGetFaceCfgHandle = CHCNetSDK.NET_DVR_StartRemoteConfig(m_UserID, CHCNetSDK.NET_DVR_GET_FACE, ptrStruCond, dwSize, null, IntPtr.Zero);
            if (m_lGetFaceCfgHandle == -1)
            {
                Marshal.FreeHGlobal(ptrStruCond);
                MessageBox.Show("NET_DVR_GET_FACE_FAIL, ERROR CODE" + CHCNetSDK.NET_DVR_GetLastError().ToString(), "Error", MessageBoxButtons.OK);
                return;
            }

            bool Flag     = true;
            int  dwStatus = 0;

            CHCNetSDK.NET_DVR_FACE_RECORD struRecord = new CHCNetSDK.NET_DVR_FACE_RECORD();
            struRecord.init();
            struRecord.dwSize = Marshal.SizeOf(struRecord);
            int dwOutBuffSize = struRecord.dwSize;

            while (Flag)
            {
                dwStatus = CHCNetSDK.NET_DVR_GetNextRemoteConfig(m_lGetFaceCfgHandle, ref struRecord, dwOutBuffSize);
                switch (dwStatus)
                {
                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS:    //成功读取到数据,处理完本次数据后需调用next
                    ProcessFaceData(ref struRecord, ref Flag);
                    break;

                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_NEED_WAIT:
                    break;

                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_FAILED:
                    CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFaceCfgHandle);
                    MessageBox.Show("NET_SDK_GET_NEXT_STATUS_FAILED" + CHCNetSDK.NET_DVR_GetLastError().ToString(), "Error", MessageBoxButtons.OK);
                    Flag = false;
                    break;

                case CHCNetSDK.NET_SDK_GET_NEXT_STATUS_FINISH:
                    MessageBox.Show("NET_SDK_GET_NEXT_STATUS_FINISH", "Tips", MessageBoxButtons.OK);
                    CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFaceCfgHandle);
                    Flag = false;
                    break;

                default:
                    MessageBox.Show("NET_SDK_GET_STATUS_UNKOWN" + CHCNetSDK.NET_DVR_GetLastError().ToString(), "Error", MessageBoxButtons.OK);
                    Flag = false;
                    CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFaceCfgHandle);
                    break;
                }
            }

            Marshal.FreeHGlobal(ptrStruCond);
        }