public static void LumiCaptureWithPresenceDetectionFeedback(byte[] snapShot24bppPointer, byte[] template1Pointer, ref uint templateSize1, uint width, uint height, LumiSDKWrapper.LumiPresenceDetectCallbackDelegate callbackFunc) { try { byte[] snapShot = new byte[width * height]; // Array to hold raw data 8 bpp format int spoof = 0; // Make sure Presence Detection is on. // Because we need another definition for LumiSetOption, we call the SetPresenceDetectionMode // static method on the object LumiSDKLumiSetOption. This is because the LumiSDKWrapper // has the LumiSetOption defined to take the LumiPresenceDetectCallbackDelegate argument while for // setting PD mode, we need it to take an integer pointer argument instead. LumiSDKLumiSetOption.SetPresenceDetectionMode(_hHandle, LumiSDKWrapper.LUMI_PRES_DET_MODE.LUMI_PD_ON); // Set the address of the presence detection callback function IntPtr prtDel = Marshal.GetFunctionPointerForDelegate(callbackFunc); _rc = LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_PRESENCE_DET_CALLBACK, prtDel, GetIntPtrSz()); _rc = LumiSDKWrapper.LumiSetDCOptions(_hHandle, "C:/Temp/", 0); LumiSDKWrapper.LUMI_PROCESSING_MODE procMode; procMode.bExtract = 1; procMode.bLatent = 0; procMode.bSpoof = 1; _rc = LumiSDKWrapper.SetProcessingMode(_hHandle, procMode); procMode.bExtract = 0; _rc = LumiSDKWrapper.GetProcessingMode(_hHandle, ref procMode); //_rc = LumiCapture(_hHandle, snapshotPointer, &spoof, null); _rc = LumiSDKWrapper.LumiCaptureEx(_hHandle, snapShot, template1Pointer, ref templateSize1, ref spoof, null); if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { throw new Exception("ERROR: lumiCaptureProcess rc = " + _rc); } else { _statusMessage += "PASS: lumiCaptureProcess rc = " + _rc + " spoof = " + spoof + "\r\n"; } LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_PRESENCE_DET_CALLBACK, IntPtr.Zero, GetIntPtrSz()); // size of int is 4 ConvertRawImageTo24bpp(snapShot24bppPointer, snapShot, snapShot.Length); } catch (Exception err) { _statusMessage += "An Error occured: " + err.ToString() + "\r\n"; //CloseScanner(); throw err; } finally { } }
public void Run() { uint width = 0, height = 0; int nSpoof = 0; GetWidthAndHeight(ref width, ref height); byte[] snapShot24bpp = new byte[width * height * 3]; // multiply by 3 to get 24bppRgb format byte[] template1 = new byte[5000]; //array to hold the template uint templateLen1 = 0; uint nMatchScore1 = 0; int nSpoofScore = 0; LumiSDKWrapper.LumiPresenceDetectCallbackDelegate del = m_form.PresenceDetectionCallback; m_form.Invoke(m_form.m_DelegateErrorMessage, "Place finger down for verification", m_form.Blue); //////////////////////////// LumiSDKWrapper.LUMI_PROCESSING_MODE processingMode; processingMode.bExtract = 0; processingMode.bLatent = 0; processingMode.bSpoof = 0; LumiSDKWrapper.LumiStatus pStatus = LumiSDKWrapper.GetProcessingMode(_hHandle, ref processingMode); if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { m_form.Invoke(m_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", m_form.Red); return; } processingMode.bSpoof = m_form.m_bSpoofEnabled ? (byte)1 : (byte)0; pStatus = LumiSDKWrapper.SetProcessingMode(_hHandle, processingMode); if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { m_form.Invoke(m_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", m_form.Red); return; } ////////////////////////////////// if (EnrollAndDisplay(snapShot24bpp, template1, ref templateLen1, width, height, ref nSpoof, del) == false) { m_form.Invoke(m_form.m_VerifyThreadFinished); return; } if (m_form.m_bClosingApp) { CloseScanner(); return; } /*int index; * index = m_form.m_currentSubject.fingers.IndexOf(m_form.m_CurrentHotSpot); * uint templatelength = (uint)m_form.m_currentSubject.templateLengths[index]; * * LumiSDKWrapper.LumiMatch(_hHandle, template1, ref templateLen1, (byte[])m_form.m_currentSubject.templates[index], ref templatelength, ref nMatchScore1, ref nSpoofScore); * if (m_form.m_bSpoofEnabled&&(nSpoof != -1)) * { * if (nMatchScore1 > m_form.m_MatchThreshold && nSpoof <= m_form.m_SpoofThreshold) * { * m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nSpoof Score = " + nSpoof + "\nVerification Successful", m_form.Blue); * } * * else * { * m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nSpoof Score = " + nSpoof + "\nVerification Failed", m_form.Red); * * } * } * else * { * if (nMatchScore1 > m_form.m_MatchThreshold) * { * m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nVerification Successful", m_form.Blue); * } * * else * { * m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nVerification Failed", m_form.Red); * * } * }*/ m_form.Invoke(m_form.m_VerifyThreadFinished); }
public void Run() { try { var sensorid = (Sensor)m_form.SensorList[(int)m_form.m_nSelectedSensorID]; _hHandle = sensorid.handle; uint width = 0, height = 0; int nSpoof = 0; GetWidthAndHeight(ref width, ref height); byte[] snapShot24bpp = new byte[width * height * 3]; // multiply by 3 to get 24bppRgb format byte[] template = new byte[5000]; //array to hold the template uint templateLen = 0; uint nNFIQ = 0; // Assign the main form's PresenceDetectionCallback method to the LumiPresenceDetectCallbackDelegate LumiSDKWrapper.LumiPresenceDetectCallbackDelegate del = m_form.PresenceDetectionCallback; byte[] snapShot = new byte[width * height]; // raw 8 bpp image buffer //////////////////// if (sensorid.SensorType == LumiSDKWrapper.LUMI_SENSOR_TYPE.M32X) { Bitmap bitmap1 = Resources.CaptureInProgress_M320_resized; BitmapData bmpData = bitmap1.LockBits(new Rectangle(0, 0, bitmap1.Width, bitmap1.Height), ImageLockMode.WriteOnly, bitmap1.PixelFormat); byte[] snapShot24 = new byte[bitmap1.Width * bitmap1.Height * 3]; // multiply by 3 to get 24bppRgb format Marshal.Copy(bmpData.Scan0, snapShot24, 0, bitmap1.Width * bitmap1.Height * 3); m_form.Invoke(m_form.m_DelegateSetImage, snapShot, snapShot24, (uint)bitmap1.Width, (uint)bitmap1.Height, template, templateLen, -1); } ///////////////////// ///////////////// LumiSDKWrapper.LUMI_PROCESSING_MODE processingMode; processingMode.bExtract = 0; processingMode.bLatent = 0; processingMode.bSpoof = 0; LumiSDKWrapper.LumiStatus pStatus = LumiSDKWrapper.GetProcessingMode(_hHandle, ref processingMode); if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture failed. Unable to Set the Spoof detection mode", m_form.Red); return; } if (m_form.m_bSpoofEnabled) { processingMode.bSpoof = 1; } else { processingMode.bSpoof = 0; } pStatus = LumiSDKWrapper.SetProcessingMode(_hHandle, processingMode); if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture failed. Unable to Set the Spoof detection mode", m_form.Red); return; } //////////////// LumiSDKWrapper.LumiStatus Status = CaptureImage(snapShot, snapShot24bpp, template, ref templateLen, width, height, ref nSpoof, del, ref nNFIQ); if (m_form.m_bClosingApp) { CloseScanner(); return; } if (m_form.m_bNISTQuality) { m_form.Invoke(m_form.m_DelegateNISTStatus, "NIST Quality = " + nNFIQ, m_form.Blue); m_form.Invoke(m_form.m_DelegateSetNISTImage, nNFIQ); } else { m_form.Invoke(m_form.m_DelegateNISTStatus, "", m_form.Blue); } if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_CANCELLED_BY_USER) { m_form.Invoke(m_form.m_DelegateCaptureCancelled); m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Cancelled by User", m_form.Red); //throw new Exception(); return; } if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_ERROR_TIMEOUT) { m_form.Invoke(m_form.m_DelegateCaptureTimeOut); m_form.Invoke(m_form.m_DelegateErrorMessage, "Sensor Time Out.", m_form.Red); return; } if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_ERROR_TIMEOUT_LATENT) { m_form.Invoke(m_form.m_DelegateCaptureTimeOut); m_form.Invoke(m_form.m_DelegateErrorMessage, "Sensor Time Out.", m_form.Red); return; } if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_ERROR_SENSOR_COMM_TIMEOUT) { m_form.Invoke(m_form.m_DelegateComTimeOut); m_form.Invoke(m_form.m_DelegateErrorMessage, "Sensor Communication Time Out.\n Please re-connect the device and restart the application", m_form.Red); return; } m_form.Invoke(m_form.m_DelegateSetImage, snapShot, snapShot24bpp, width, height, template, templateLen, -1); GC.KeepAlive(del); if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { if (m_form.m_bSpoofEnabled && (nSpoof != -1)) { if (nSpoof <= m_form.m_SpoofThreshold) { m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Complete\r\nSpoofScore = " + nSpoof + ": It is a Real Finger", m_form.Blue); } else { m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Complete\r\nSpoofScore = " + nSpoof + ": It is a Spoof", m_form.Red); } } else { m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Complete", m_form.Blue); } } } catch (Exception err) { string str = err.ToString(); m_form.Invoke(m_form.m_DelegateErrorMessage, ("Error occured. Restart your application"), m_form.Red); } m_form.Invoke(m_form.m_CaptureThreadFinished); }
public void Run() { uint width = 0, height = 0; int nSpoof = 0; GetWidthAndHeight(ref width, ref height); byte[] snapShot24bpp = new byte[width * height * 3]; // multiply by 3 to get 24bppRgb format byte[] template1 = new byte[5000]; //array to hold the template byte[] template2 = new byte[5000]; //array to hold the template byte[] template3 = new byte[5000]; //array to hold the template uint templateLen1 = 0; uint templateLen2 = 0; uint templateLen3 = 0; uint nMatchScore1 = 0; uint nMatchScore2 = 0; uint nMatchScore3 = 0; int nSpoofScore = 0; LumiSDKWrapper.LumiPresenceDetectCallbackDelegate del = _form.PresenceDetectionCallback; //////////////////////////// LumiSDKWrapper.LUMI_PROCESSING_MODE processingMode; processingMode.bExtract = 0; processingMode.bLatent = 0; processingMode.bSpoof = 0; LumiSDKWrapper.LumiStatus pStatus = LumiSDKWrapper.GetProcessingMode(_hHandle, ref processingMode); if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", _form.Red); return; } processingMode.bSpoof = _form.m_bSpoofEnabled ? (byte)1 : (byte)0; pStatus = LumiSDKWrapper.SetProcessingMode(_hHandle, processingMode); if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) { _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", _form.Red); return; } ////////////////////////////////// _form.Invoke(_form.m_DelegateErrorMessage, "Place finger down for first insertion", _form.Blue); if (EnrollAndDisplay(0, snapShot24bpp, template1, ref templateLen1, width, height, ref nSpoof, del) == false) { _form.Invoke(_form.m_EnrollThreadFinished); return; } if (_form.m_bClosingApp) { CloseScanner(); return; } ///////////// if (_form.m_bSpoofEnabled) { if (nSpoof > 1050) { _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please enroll with real finger", _form.Red); _form.Invoke(_form.m_EnrollThreadFinished); return; } } // Force Finger Lift between enrollment insertions _form.Invoke(_form.m_DelegateErrorMessage, "Please lift finger and place again", _form.Red); ForceFingerLift(); _form.Invoke(_form.m_DelegateErrorMessage, "Place finger down for second insertion", _form.Blue); if (EnrollAndDisplay(1, snapShot24bpp, template2, ref templateLen2, width, height, ref nSpoof, del) == false) { _form.Invoke(_form.m_EnrollThreadFinished); return; } if (_form.m_bClosingApp) { CloseScanner(); return; } if (_form.m_bSpoofEnabled) { if (nSpoof > 1050) { _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please enroll with real finger", _form.Red); _form.Invoke(_form.m_EnrollThreadFinished); return; } } // Force Finger Lift between enrollment insertions _form.Invoke(_form.m_DelegateErrorMessage, "Please lift finger and place again", _form.Red); ForceFingerLift(); _form.Invoke(_form.m_DelegateErrorMessage, "Place finger down for third insertion", _form.Blue); if (EnrollAndDisplay(2, snapShot24bpp, template3, ref templateLen3, width, height, ref nSpoof, del) == false) { _form.Invoke(_form.m_EnrollThreadFinished); return; } if (_form.m_bClosingApp) { CloseScanner(); return; } if (_form.m_bSpoofEnabled) { if (nSpoof > 1050) { _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please enroll with real finger", _form.Red); _form.Invoke(_form.m_EnrollThreadFinished); return; } } /////////////// /* * LumiSDKWrapper.LumiMatch(_hHandle, template2, ref templateLen2, template3, ref templateLen3, ref nMatchScore2, ref nSpoofScore); * * if (nMatchScore2 < _form.m_MatchThreshold) * { * _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please use the same finger for enrollment", _form.Red); * _form.Invoke(_form.m_EnrollThreadFinished); * return; * } * LumiSDKWrapper.LumiMatch(_hHandle, template1, ref templateLen1, template3, ref templateLen3, ref nMatchScore3, ref nSpoofScore); * * FileStream stream; * BinaryFormatter bformatter = new BinaryFormatter(); * * if (_form.m_newSubjID) * { * stream = File.Create(_form.m_sFolderPath + "\\Database\\" + _form.m_sEnrollSubjID + ".bin"); * } * else * { * stream = File.Open(_form.m_sFolderPath + "\\Database\\" + _form.m_sEnrollSubjID + ".bin", FileMode.Open); * } * * * _form.m_currentSubject.deleteData(_form.m_CurrentHotSpot); * * if(nMatchScore1>nMatchScore2) * { * if (nMatchScore1 > nMatchScore3) * { * if (nMatchScore2 > nMatchScore3) * { * _form.m_currentSubject.addData(template2, templateLen2, _form.m_CurrentHotSpot); * * } * else * { * _form.m_currentSubject.addData(template1, templateLen1, _form.m_CurrentHotSpot); * * } * * } * else * { * _form.m_currentSubject.addData(template1, templateLen1, _form.m_CurrentHotSpot); * } * * } * else * { * if (nMatchScore2 > nMatchScore3) * { * if (nMatchScore1 > nMatchScore3) * { * _form.m_currentSubject.addData(template2, templateLen2, _form.m_CurrentHotSpot); * } * else * { * _form.m_currentSubject.addData(template3, templateLen3, _form.m_CurrentHotSpot); * } * } * else * { * _form.m_currentSubject.addData(template3, templateLen3, _form.m_CurrentHotSpot); * } * * } * * bformatter.Serialize(stream, _form.m_currentSubject); * stream.Close();*/ _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment successful", _form.Blue); _form.Invoke(_form.m_EnrollThreadFinished); }