public bool InitSensor() { bool result = true; int ret = zkfp.ZKFP_ERR_OK; if ((ret = fpInstance.Initialize()) == zkfp.ZKFP_ERR_OK) { int nCount = fpInstance.GetDeviceCount(); if (nCount <= 0) { result = false; } } else { result = false; } if (!result) { fpInstance.Finalize(); } else { //加载已经注册的指纹 LoadFinger(); } return(result); }/// <summary>
private void bnInit_Click(object sender, EventArgs e) { cmbIdx.Items.Clear(); int ret = zkfp.ZKFP_ERR_OK; if ((ret = fpInstance.Initialize()) == zkfp.ZKFP_ERR_OK) { int nCount = fpInstance.GetDeviceCount(); if (nCount > 0) { for (int i = 0; i < nCount; i++) { cmbIdx.Items.Add(i.ToString()); } cmbIdx.SelectedIndex = 0; bnInit.Enabled = false; bnFree.Enabled = true; bnOpen.Enabled = true; } else { fpInstance.Finalize(); MessageBox.Show("No device connected!"); } } else { MessageBox.Show("Initialize fail, ret=" + ret + " !"); } }
// [ INITALIZE DEVICE ] private void bnInit_Click(object sender, EventArgs e) // PASO 2 INICIALIZA EL DISPOISTIVO { parentForm.statusBar.Visible = false; cmbIdx.Items.Clear(); int initializeCallBackCode = fpInstance.Initialize(); if (zkfp.ZKFP_ERR_OK == initializeCallBackCode) { int nCount = fpInstance.GetDeviceCount(); if (nCount > 0) { for (int i = 1; i <= nCount; i++) { cmbIdx.Items.Add(i.ToString()); } cmbIdx.SelectedIndex = 0; btnInit.Enabled = false; DisplayMessage(MessageManager.msg_FP_InitComplete, true); } else { int finalizeCount = fpInstance.Finalize(); DisplayMessage(MessageManager.msg_FP_NotConnected, false); } // CONNECT DEVICE #region -------- CONNECT DEVICE -------- int openDeviceCallBackCode = fpInstance.OpenDevice(cmbIdx.SelectedIndex); if (zkfp.ZKFP_ERR_OK != openDeviceCallBackCode) { DisplayMessage($"Uable to connect with the device! (Return Code: {openDeviceCallBackCode} )", false); return; } Utilities.EnableControls(false, btnInit); Utilities.EnableControls(true, btnClose, btnEnroll, btnVerify, btnIdentify, btnFree); RegisterCount = 0; regTempLen = 0; iFid = 1; //for (int i = 0; i < 3; i++) for (int i = 0; i < REGISTER_FINGER_COUNT; i++) { RegTmps[i] = new byte[2048]; } byte[] paramValue = new byte[4]; int size = 4; //fpInstance.GetParameters fpInstance.GetParameters(1, paramValue, ref size); zkfp2.ByteArray2Int(paramValue, ref mfpWidth); size = 4; fpInstance.GetParameters(2, paramValue, ref size); zkfp2.ByteArray2Int(paramValue, ref mfpHeight); FPBuffer = new byte[mfpWidth * mfpHeight]; //FPBuffer = new byte[fpInstance.imageWidth * fpInstance.imageHeight]; captureThread = new Thread(new ThreadStart(DoCapture)); captureThread.IsBackground = true; captureThread.Start(); bIsTimeToDie = false; string devSN = fpInstance.devSn; lblDeviceStatus.Text = "Connected \nDevice S.No: " + devSN; DisplayMessage("You are now connected to the device.", true); #endregion } else { DisplayMessage("Unable to initailize the device. " + FingerPrintDeviceUtilities.DisplayDeviceErrorByCode(initializeCallBackCode) + " !! ", false); } }