Пример #1
0
        void reader_On_Captured(CaptureResult result)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Function(delegate
                {
                    if (result.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        MessageBox.Show("Capture failed.");
                        return;
                    }

                    Fid fid = result.Data;

                    //Extract pre-registration features
                    DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromFid(result.Data, Constants.Formats.Fmd.DP_PRE_REGISTRATION);
                    if (fmd.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        MessageBox.Show("Error extracting features from image.  Please try again");
                        return;
                    }

                    listPreRegFMDs.Add(fmd.Data);  //Add good image to list of fids

                    //Attempt to create enrollment Fmd from list of fids
                    DataResult <Fmd> enrollmentFMD = Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.DP_REGISTRATION, listPreRegFMDs);

                    if (enrollmentFMD.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                    {
                        MessageBox.Show("Enrollment failed.  Please try again.");
                        pressCount = 0;
                        pb1.Image  = null;
                        pb2.Image  = null;
                        pb3.Image  = null;
                        pb4.Image  = null;
                        //reader.CaptureAsync(Constants.Formats.Fid.ISO, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, reader.Capabilities.Resolutions[0]);
                        return;
                    }

                    if (pressCount == 0)
                    {
                        pb1.Image = new Bitmap(Fid2Bitmap.CreateBitmap(result.Data.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb1.Size);
                    }
                    else if (pressCount == 1)
                    {
                        pb2.Image = new Bitmap(Fid2Bitmap.CreateBitmap(fid.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb2.Size);
                    }
                    else if (pressCount == 2)
                    {
                        pb3.Image = new Bitmap(Fid2Bitmap.CreateBitmap(fid.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb3.Size);
                    }
                    else if (pressCount == 3) //Dont increment.  Say on last picture box until successfull registration
                    {
                        pb4.Image = new Bitmap(Fid2Bitmap.CreateBitmap(fid.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb4.Size);
                    }

                    ++pressCount;

                    if (enrollmentFMD.ResultCode == Constants.ResultCode.DP_SUCCESS) //enrollment FMD created
                    {
                        //if (rbLeftIndex.Checked)
                        //{
                        //    leftIndex = enrollmentFMD.Data;
                        //    //rbRightIndex.Checked = true;
                        //    lblInfo.Text = "Now press your right index 4 or more times.";
                        //    pb1.Image = null;  pb2.Image = null; pb3.Image = null; pb4.Image = null;
                        //    pressCount = 0;
                        //    listPreRegFMDs.Clear();
                        //}
                        //else
                        //{
                        fmd1            = enrollmentFMD.Data;
                        btnSave.Enabled = true;
                        //reader.CancelCapture();
                        //MessageBox.Show("Fingerprint enrollment complete.  Click 'Save' to complete registration.");
                        //}
                    }
                }));
            }
        }
Пример #2
0
        void reader_On_Captured(CaptureResult result)
        {
            if (result.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Capture failed.");
                return;
            }

            Fid fid = result.Data;

            //Display captured image
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Function(delegate
                {
                    pbImage.Image = new Bitmap(Fid2Bitmap.CreateBitmap(result.Data.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pbImage.Size);
                }));
            }

            //Extract pre-registration features
            DataResult <Fmd> fmdResult = FeatureExtraction.CreateFmdFromFid(result.Data, Constants.Formats.Fmd.DP_VERIFICATION);

            if (fmdResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Error extracting features from image.  Please try again");
                return;
            }
            else
            {
                fmd = fmdResult.Data;
            }

            // Lets identify the print

            // Perform indentification of fmd of captured sample against enrolledFmds for userid
            IdentifyResult iResult1 = Comparison.Identify(fmd, 0, HelperFunctions.GetAllFmd1s, 21474, 1);

            // If Identify was successful
            if (iResult1.ResultCode == Constants.ResultCode.DP_SUCCESS)
            {
                //If number of matches were greater than 0
                if (iResult1.Indexes.Length == 1)
                {
                    string[] usernames  = HelperFunctions.GetAllPrisonerIds;
                    string   prisonerId = usernames[iResult1.Indexes[0][0]];

                    string ip = (_serverIP == "(local)" ? "localhost" : _serverIP);

                    string url = string.Format("http://{0}/PMIS/Prisoner/Details?PrisonerId={1}", ip, prisonerId);

                    //if(browser == null)
                    //    browser = new WebBrowser();

                    //browser.Navigate(url, "_prs");
                    //browser.Document.Window.Open(url, "_prs", null, true);

                    //window.Open(url, "_prs", null, true);
                    System.Diagnostics.Process.Start(url);
                }
                else if (iResult1.Indexes.Length > 1)
                {
                    string ids = "";

                    string[] usernames = HelperFunctions.GetAllPrisonerIds;

                    for (int i = 0; i < iResult1.Indexes.Length; i++)
                    {
                        ids += usernames[iResult1.Indexes[i][0]] + ", ";
                    }

                    MessageBox.Show("Error: Multiple matches found. Prisoner IDs : {0}", ids);
                }
                else
                {
                    MessageBox.Show("Prisoner NOT found! Try again or enroll prisoner!");
                }
            }
            else
            {
                MessageBox.Show("Error : " + iResult1.ResultCode.ToString());
            }

            pbImage.Image = null;
        }