예제 #1
0
        public void OnCaptured(CaptureResult captureResult)
        {
            this.picBoxToCap     = picBoxFingerPrint;
            this.fingerToCapture = 0;
            count++;
            lblCount.Invoke(new Action(() => { lblCount.Text = count.ToString(); }));
            DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);

            if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                if (CurrentReader != null)
                {
                    CurrentReader.Dispose();
                    CurrentReader = null;
                }

                MessageBox.Show("Error:  " + captureResult.ResultCode);
            }
            if (captureResult.Data != null)
            {
                foreach (Fid.Fiv fiv in captureResult.Data.Views)
                {
                    picBoxFingerPrint.Image    = CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                    picBoxFingerPrint.SizeMode = PictureBoxSizeMode.Zoom;
                }
            }
            preenrollmentFmds.Add(resultConversion.Data);
            if (count >= 4)
            {
                resultEnrollment = Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                TempFingerPrint = Fmd.SerializeXml(resultConversion.Data);

                resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    FileStream fs = new System.IO.FileStream(@"..\..\Pictures\right.bmp", FileMode.Open, FileAccess.Read);
                    picRigithWrong.Invoke(new Action(() => { picRigithWrong.Image = Image.FromStream(fs); }));
                    picRigithWrong.SizeMode = PictureBoxSizeMode.Zoom;
                    //preenrollmentFmds.Clear();
                    //count = 0;
                    MessageBox.Show("An enrollment was successfully created.");
                    return;
                }
                else if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                {
                    MessageBox.Show("Enrollment was unsuccessful.  Please try again.");
                    preenrollmentFmds.Clear();
                    count = 0;
                    return;
                }
            }
        }
예제 #2
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.");
                        //}
                    }
                }));
            }
        }