private void EnrollmentCapture() { count = 0; Constants.ResultCode captureResult = reader.CaptureAsync(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, reader.Capabilities.Resolutions[0]); if (captureResult != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("CaptureResult: " + captureResult.ToString()); } }
private void VerificationCapture() { //resultion 1 is for 1000 dpi, 0 is for 500 dpi Constants.ResultCode captureResult = reader.CaptureAsync(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, reader.Capabilities.Resolutions[0]); UpdateVerifyMessage("Swipe finger to start verification", null); if (captureResult != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("CaptureResult: " + captureResult.ToString()); } }
/// <summary> /// Initialize the form and start either a capture or streaming thread. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Capture_Stream_Load(object sender, EventArgs e) { Constants.ResultCode result = Constants.ResultCode.DP_DEVICE_FAILURE; result = _sender.CurrentReader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE); if (result != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("Error: " + result.ToString()); if (_sender.CurrentReader != null) { _sender.CurrentReader.Dispose(); _sender.CurrentReader = null; } return; } // Check if streaming or capture was chosen. streamingOn = _sender.streamingOn; pbFingerprint.Image = null; if (streamingOn) { if (!_sender.CurrentReader.Capabilities.CanStream) { MessageBox.Show("This reader cannot stream in this environment."); backEnabled = true; this.Close(); reset = true; _sender.CurrentReader.Dispose(); return; } this.Text = "Streaming"; threadHandle = new Thread(StreamThread); threadHandle.IsBackground = true; threadHandle.Start(); } else { this.Text = "Capture"; threadHandle = new Thread(CaptureThread); threadHandle.IsBackground = true; threadHandle.Start(); } }
private void Form1_Load(object sender, EventArgs e) { InitializeReaders(); Constants.ResultCode result = reader.GetStatus(); CheckReaderStatus(); if (result == Constants.ResultCode.DP_SUCCESS) { if (reader.Status.Status == Constants.ReaderStatuses.DP_STATUS_READY) { //reader.On_Captured += new Reader.CaptureCallback(reader_On_Captured); //VerificationCapture(); VerifyMessageLbl.Text = "Fingerprint Reader found and status is ready"; } } else { VerifyMessageLbl.Text = "Could not perform capture. Reader result code :" + result.ToString(); } }
private void StartEnrollment(Constants.ResultCode readerResult) { fingerindex = 0; preEnrollmentFmd = new List <Fmd>(); CheckReaderStatus(); if (readerResult == Constants.ResultCode.DP_SUCCESS) { reader.On_Captured += new Reader.CaptureCallback(reader_On_Captured); EnrollmentCapture(); } else { messagelbl.Text = "Could not perform capture. Reader result code :" + readerResult.ToString(); } }
/// <summary> /// Check reader status. If okay, stream an image and display as a bitmap. /// </summary> public void StreamThread() { // A lock to only allow one thread to one at a time. threadHandle_lock = true; _sender.CurrentReader.StartStreaming(); // A flag to allow back to be pressed only after opening and starting a stream. backEnabled = true; // A reset flag to stop the stream image loop when the form is closed. reset = false; while ((!reset)) { CaptureResult captureResult = null; Constants.ResultCode result = _sender.CurrentReader.GetStatus(); #region Validate GetStatus if ((result != Constants.ResultCode.DP_SUCCESS)) { MessageBox.Show("Get Status Error: " + result); if (_sender.CurrentReader != null) { _sender.CurrentReader.Dispose(); _sender.CurrentReader = null; } reset = true; continue; } if ((_sender.CurrentReader.Status.Status == Constants.ReaderStatuses.DP_STATUS_BUSY)) { Thread.Sleep(50); continue; } else if ((_sender.CurrentReader.Status.Status == Constants.ReaderStatuses.DP_STATUS_NEED_CALIBRATION)) { _sender.CurrentReader.Calibrate(); } else if ((_sender.CurrentReader.Status.Status != Constants.ReaderStatuses.DP_STATUS_READY)) { MessageBox.Show("Get Status: " + _sender.CurrentReader.Status.Status); if (_sender.CurrentReader != null) { _sender.CurrentReader.Dispose(); _sender.CurrentReader = null; } reset = true; continue; } #endregion captureResult = _sender.CurrentReader.GetStreamImage(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, _sender.CurrentReader.Capabilities.Resolutions[0]); #region Validate GetStreamImage if (captureResult.Quality == Constants.CaptureQuality.DP_QUALITY_TIMED_OUT) { Thread.Sleep(50); continue; } if ((captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS || captureResult.Quality == Constants.CaptureQuality.DP_QUALITY_CANCELED)) { MessageBox.Show("Error: " + captureResult.ResultCode); if (_sender.CurrentReader != null) { _sender.CurrentReader.StopStreaming(); _sender.CurrentReader.Dispose(); _sender.CurrentReader = null; } reset = true; continue; } if ((captureResult.Quality == Constants.CaptureQuality.DP_QUALITY_NO_FINGER || captureResult.Quality == Constants.CaptureQuality.DP_QUALITY_FAKE_FINGER)) { continue; } #endregion foreach (Fid.Fiv fiv in captureResult.Data.Views) { SendMessage(CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height)); } } if (_sender.CurrentReader != null) { Constants.ResultCode result2 = _sender.CurrentReader.StopStreaming(); if (result2 != Constants.ResultCode.DP_SUCCESS && result2 != Constants.ResultCode.DP_NOT_IMPLEMENTED) { MessageBox.Show("Error: " + result2.ToString()); } } if (_sender.CurrentReader != null) { _sender.CurrentReader.Dispose(); } threadHandle_lock = false; }
//In Load lets enumerate and open fingerprint reader private void IdentifyDlg_Load(object sender, EventArgs e) { this.DialogResult = System.Windows.Forms.DialogResult.None; ReaderCollection readers = ReaderCollection.GetReaders(); if (readers.Count == 0) { MessageBox.Show("Registration requires a plugged in fingerprint reader."); readers.Dispose(); readers = null; this.Close(); return; } if (readers.Count > 1) { MessageBox.Show("This sample is designed for a single connected reader. Please connect only 1 device."); readers.Dispose(); readers = null; this.Close(); return; } reader = readers[0]; if (reader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE) != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("Could not open device."); readers.Dispose(); readers = null; this.Close(); return; } if (reader.GetStatus() != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("Error getting device status."); readers.Dispose(); readers = null; this.Close(); return; } if (reader.Status.Status != Constants.ReaderStatuses.DP_STATUS_READY) { MessageBox.Show("Device not ready. Try again in a few seconds."); readers.Dispose(); readers = null; this.Close(); return; } HelperFunctions.LoadAllUsers(); reader.On_Captured += new Reader.CaptureCallback(reader_On_Captured); Constants.ResultCode captureResult = reader.CaptureAsync(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, reader.Capabilities.Resolutions[0]); if (captureResult != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("Error CaptureResult: " + captureResult.ToString()); } }