Пример #1
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");
                Fingerprint newFingerPrint = new Fingerprint();
                if (count < 4)
                {
                    foreach (Fid.Fiv fiv in captureResult.Data.Views)
                    {
                        newFingerPrint.AsBitmap = _sender.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                    }
                    patient.Fingerprints.Add(newFingerPrint);
                    Afis.Extract(patient);
                    count += 1;
                    if (count != 4)
                    {
                        SendMessage(Action.SendMessage, "Now place your next finger on the reader.");
                    }
                    else
                    {
                        SendMessage(Action.SendMessage, "Now place a search finger on the reader.");
                    }
                }
                else if (count > 0)
                {
                    Person matchFinger = new Person();

                    foreach (Fid.Fiv fiv in captureResult.Data.Views)
                    {
                        newFingerPrint.AsBitmap = _sender.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                    }
                    matchFinger.Fingerprints.Add(newFingerPrint);
                    Afis.Extract(matchFinger);
                    long   memUsage    = GetMemoryUsage(patient);
                    float  score       = Afis.Verify(matchFinger, patient);
                    bool   match       = (score > Afis.Threshold);
                    string matchString = "AFIS doesn't match.  Get out of here kid!";
                    if (match)
                    {
                        matchString = "AFIS matches.";
                    }

                    SendMessage(Action.SendMessage, "Identification resulted: " + matchString + " score = " + score.ToString());
                    SendMessage(Action.SendMessage, "Place another finger on the reader.");
                    count += 1;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
            public override void Display()
            {
                var allPersons = new List <Person>();

                var i = 0;

                // Create missing templates
                foreach (var username in GetUsernames())
                {
                    var person = new Person();
                    person.Id = i++;

                    var dataFolder = Path.Combine(PrintsFolderName, username);

                    var allBitmaps = Directory.GetFiles(dataFolder, "*.bmp", SearchOption.TopDirectoryOnly).Select(Path.GetFileName);
                    //var allPatterns = Directory.GetFiles(dataFolder, "*.min", SearchOption.TopDirectoryOnly).Select(Path.GetFileName).ToList();

                    foreach (var bitmapFile in allBitmaps)
                    {
                        //var fingerprintId = Path.GetFileNameWithoutExtension(bitmapFile);

                        //var patternFile = $"{fingerprintId}.min";

                        Bitmap bitmap = new Bitmap(Path.Combine(dataFolder, bitmapFile));

                        Fingerprint fp = new Fingerprint();
                        fp.AsBitmap = bitmap;

                        person.Fingerprints.Add(fp);
                    }

                    _afis.Extract(person);
                    allPersons.Add(person);
                }


                var device = new DeviceAccessor().AccessFingerprintDevice();

                device.FingerDetected += (sender, args) =>
                {
                    device.StopFingerDetection();

                    Output.WriteLine("Finger detected, dont remove");
                    var readFingerprint = device.ReadFingerprint();

                    Output.WriteLine("Finger captured. Validation in progress");
                    ValidateFingerprint(readFingerprint, allPersons);

                    device.StartFingerDetection();
                };

                device.StartFingerDetection();

                Output.WriteLine("Please place your finger on the device or press enter to cancel");

                Input.ReadString(string.Empty);
                device.Dispose();

                this.Program.NavigateBack();
            }
Пример #3
0
        // Take fingerprint image file and create Person object from the image
        public static MyPerson getProbe(string filename, string visitorNbr)
        {
            Console.WriteLine("Matching {0}...", visitorNbr);

            // Initialize empty fingerprint object and set properties
            MyFingerprint fp = new MyFingerprint();

            fp.Filename = filename;
            // Load image from the file
            Console.WriteLine(" Loading image from {0}...", filename);
            BitmapImage image = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute));

            fp.AsBitmapSource = image;
            // Above update of fp.AsBitmapSource initialized also raw image in fp.Image
            // Check raw image dimensions, Y axis is first, X axis is second
            Console.WriteLine(" Image size = {0} x {1} (width x height)", fp.Image.GetLength(1), fp.Image.GetLength(0));

            // Initialize empty person object and set its properties
            MyPerson person = new MyPerson();

            person.Name = visitorNbr;
            //            person.Id = id;
            // Add fingerprint to the person
            person.Fingerprints.Add(fp);

            // Execute extraction in order to initialize fp.Template
            Afis.Extract(person);
            // Check template size
            Console.WriteLine(" Template size = {0} bytes", fp.Template.Length);

            return(person);
        }//getProbe
Пример #4
0
        static void test()
        {
            AfisEngine Afis = new AfisEngine();

            Afis.Threshold = (float)100.12;
            Console.WriteLine(Afis.Threshold.ToString());
            string files1 = @"C:\Users\Mihir Gajjar\Desktop\DSP_Final\FingerPrint\FingerPrint\Database\1_1.bmp";
            string files2 = @"C:\Users\Mihir Gajjar\Desktop\DSP_Final\FingerPrint\FingerPrint\Database\1_2.bmp";

            Fingerprint fp1 = new Fingerprint();

            fp1.AsBitmapSource = new BitmapImage(new Uri(files1, UriKind.RelativeOrAbsolute));

            Fingerprint fp2 = new Fingerprint();

            fp2.AsBitmapSource = new BitmapImage(new Uri(files2, UriKind.RelativeOrAbsolute));

            Person person1 = new Person();

            person1.Fingerprints.Add(fp1);

            Person person2 = new Person();

            person2.Fingerprints.Add(fp2);


            Afis.Extract(person1);
            Afis.Extract(person2);
            float score = Afis.Verify(person1, person1);
            bool  match = (score > Afis.Threshold);

            Console.WriteLine(score.ToString());

            string temp = Console.ReadLine();
        }
Пример #5
0
        public async Task <ActionResult> ManCreate([Bind(Include = "Name, Filename")] mortal mortal)
        {
            AfisEngine Afis = new AfisEngine();

            Afis.Threshold = 180;

            var    myExport = new CsvExport();
            string apppath  = System.IO.Path.Combine(Server.MapPath("~"), "images");


            for (int i = 0; i < 40; i++)
            {
                string pathToImageO = (System.IO.Path.Combine(apppath, "original/" + (i + 1).ToString() + ".png"));

                for (int j = 0; j < 40; j++)
                {
                    string      pathToImageM2 = (System.IO.Path.Combine(apppath, "augmented/" + (j + 1).ToString() + ".jpg"));
                    Fingerprint fp1           = new Fingerprint();
                    Fingerprint fp2           = new Fingerprint();

                    MyPerson personO = new MyPerson();
                    MyPerson personM = new MyPerson();

                    Bitmap bitmap1 = fp1.AsBitmap = new Bitmap(Image.FromFile(pathToImageO));
                    Bitmap bitmap2 = fp2.AsBitmap = new Bitmap(Image.FromFile(pathToImageM2));

                    personO.Fingerprints.Add(fp1);
                    personM.Fingerprints.Add(fp2);
                    Afis.Extract(personO);
                    Afis.Extract(personM);
                    float score = Afis.Verify(personO, personM);
                    if (score > Afis.Threshold)
                    {
                        myExport.AddRow();
                        myExport["Theshold"]     = Afis.Threshold;
                        myExport["Match"]        = 1;
                        myExport["FingerprintO"] = i + 1;
                        myExport["FingerprintM"] = j + 1;
                    }
                    else
                    {
                        myExport.AddRow();
                        myExport["Theshold"]     = Afis.Threshold;
                        myExport["Match"]        = 0;
                        myExport["FingerprintO"] = i + 1;
                        myExport["FingerprintM"] = j + 1;
                    }
                }
            }



            ///ASP.NET MVC action example
            return(File(myExport.ExportToBytes(), "text/csv", "results(180).csv"));

            //return View();
            //Response.Write("<script>alert('Please Enter Filename');</script>");
        }
Пример #6
0
        public void FingerTest()
        {
            AfisEngine afis = new AfisEngine();

            afis.Threshold = 0.0001f;
            Person person1 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.SomeFingerprint
            });

            afis.Extract(person1);
            Person person2 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.MatchingFingerprint
            });

            afis.Extract(person2);

            person1.Fingerprints[0].Finger = Finger.RightThumb;
            Assert.AreEqual(Finger.RightThumb, person1.Fingerprints[0].Finger);
            person2.Fingerprints[0].Finger = Finger.RightThumb;
            Assert.That(afis.Verify(person1, person2) > 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() > 0);

            person2.Fingerprints[0].Finger = Finger.LeftIndex;
            Assert.That(afis.Verify(person1, person2) == 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() == 0);

            person1.Fingerprints[0].Finger = Finger.Any;
            Assert.That(afis.Verify(person1, person2) > 0);
            Assert.That(afis.Verify(person2, person1) > 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() > 0);
            Assert.That(afis.Identify(person2, new[] { person1 }).Count() > 0);

            person2.Fingerprints[0].Finger = Finger.Any;
            Assert.That(afis.Verify(person1, person2) > 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() > 0);

            Person person3 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.MatchingFingerprint
            });

            afis.Extract(person3);
            person1.Fingerprints[0].Finger = Finger.LeftIndex;
            person2.Fingerprints[0].Finger = Finger.LeftIndex;
            person3.Fingerprints[0].Finger = Finger.RightMiddle;
            CollectionAssert.AreEqual(afis.Identify(person1, new[] { person2, person3 }), new[] { person2 });
            person1.Fingerprints[0].Finger = Finger.RightMiddle;
            CollectionAssert.AreEqual(afis.Identify(person1, new[] { person2, person3 }), new[] { person3 });

            Assert.Catch(() => { person1.Fingerprints[0].Finger = (Finger)(-1); });
        }
Пример #7
0
        public void Fill(List <tbFingerprint> db)
        {
            database.Clear();

            foreach (tbFingerprint person in db)
            {
                Afis.Extract(person);

                // FSDK.CImage img = new FSDK.CImage(Asbt.Utils.CImage.ByteArrayToImage( person.Photo ));
                //person.PhotoTemplate = img.GetFaceTemplate();
                database.Add(person);
            }
        }
        public void RegisterUser(string b64, string UserId)
        {
            AfisEngine  afis  = new AfisEngine();
            Database    Db    = new Database();
            Person      probe = new Person();
            Fingerprint fp    = new Fingerprint();

            int Uid = Convert.ToInt16(UserId);

            //create image on harddrive
            byte[] imageBytes = Convert.FromBase64String(b64);
            fp.AsBitmap = CreateBmpImage(imageBytes);

            probe.Fingerprints.Add(fp);
            afis.Extract(probe);
            byte[] template = fp.Template;


            using (SqlCommand cmd = new SqlCommand("EnrollFaculty", Db.ConnectFingerDb()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@FingerImage", imageBytes);
                cmd.Parameters.AddWithValue("@FingerTemplate", template);
                cmd.Parameters.AddWithValue("@UserId", Uid);
                cmd.ExecuteNonQuery();
            }
        }
Пример #9
0
        public void Clone()
        {
            Fingerprint fp1 = new Fingerprint();

            fp1.AsBitmap = Settings.SomeFingerprint;
            fp1.Finger   = Finger.RightThumb;
            AfisEngine afis = new AfisEngine();

            afis.Extract(new Person(fp1));
            Assert.IsNotNull(fp1.Template);

            Fingerprint fp2 = fp1.Clone();

            Assert.AreEqual(fp1.Image, fp2.Image);
            Assert.AreEqual(Finger.RightThumb, fp2.Finger);
            Assert.AreEqual(fp1.Template, fp2.Template);

            Fingerprint fp3 = new Fingerprint().Clone();

            Assert.IsNull(fp3.Image);
            Assert.AreEqual(Finger.Any, fp3.Finger);
            Assert.IsNull(fp3.Template);

            Fingerprint fp4 = (fp2 as ICloneable).Clone() as Fingerprint;

            Assert.AreEqual(fp1.Image, fp4.Image);
            Assert.AreEqual(Finger.RightThumb, fp4.Finger);
            Assert.AreEqual(fp1.Template, fp4.Template);
        }
Пример #10
0
        public void Extract()
        {
            AfisEngine  afis = new AfisEngine();
            Fingerprint fp   = new Fingerprint()
            {
                AsBitmap = Settings.SomeFingerprint
            };

            Assert.IsNull(fp.Template);
            afis.Extract(new Person(fp));
            Assert.IsNotNull(fp.Template);

            Assert.Catch(() => { afis.Extract(new Person(new Fingerprint())); });
            afis.Extract(new Person());
            Assert.Catch(() => { afis.Extract(null); });
        }
Пример #11
0
        static void insertaHuellasDesdeCarpeta()
        {
            // Inicializa la carpeta de imagenes
            //DirectoryInfo di = new DirectoryInfo(@"C:\Users\PC_STE_19\Documents\Visual Studio 2015\Projects\BiometricFinger\images");
            DirectoryInfo di = new DirectoryInfo(@"C:\Users\PC_STE_19\Desktop\DEDOS_SECUGEN");

            Console.WriteLine("No search pattern returns:");
            List <Usuario> usuarios = new List <Usuario>();

            using (var context = new db_Entidades())
            {
                foreach (var fi in di.GetFiles())
                {
                    AfisEngine Afis = new AfisEngine();
                    //Bitmap image1 = (Bitmap)Image.FromFile(@"C:\Users\PC_STE_19\Documents\Visual Studio 2015\Projects\BiometricFinger\images\" + fi.Name, true);
                    Bitmap      image1 = (Bitmap)Image.FromFile(@"C:\Users\PC_STE_19\Desktop\DEDOS_SECUGEN\" + fi.Name, true);
                    Fingerprint f      = new Fingerprint();
                    f.AsBitmap = image1;
                    Usuario usu     = new Usuario();
                    Person  persona = new Person();
                    persona.Fingerprints.Add(f);
                    Afis.Extract(persona);
                    usu.username = fi.Name;
                    usu.finger   = f.AsIsoTemplate;
                    usuarios.Add(usu);
                    Console.WriteLine(fi.Name);
                    context.Usuario.Add(usu);
                }
                context.SaveChanges();
            }
        }
        public bool Verify(byte[] bitmap, string template)
        {
            AfisEngine Afis = new AfisEngine();

            Afis.Threshold = Treshold;

            Stream      bitmapStream = new MemoryStream(bitmap);
            Fingerprint fp1          = new Fingerprint();

            fp1.AsBitmap = new Bitmap(bitmapStream);
            Person p1 = new Person();

            p1.Fingerprints.Add(fp1);
            Afis.Extract(p1);

            Fingerprint fp2 = new Fingerprint();

            fp2.AsXmlTemplate = XElement.Parse(template);
            Person p2 = new Person();

            p2.Fingerprints.Add(fp2);

            float score = Afis.Verify(p1, p2);

            Console.WriteLine("Matching score " + score + " - fingerprints " + (score > 0 ? "match" : "do not match"));
            Console.WriteLine("Biometrics Match Treshold used: " + Treshold);

            return(score > 0);
        }
Пример #13
0
        // Take fingerprint image file and create Person object from the image
        static MyPerson Enroll(Bitmap image, string name)
        {
            Console.WriteLine("Enrolling {0}...", name);

            // Initialize empty fingerprint object and set properties
            MyFingerprint fp = new MyFingerprint();

            fp.Filename = name;
            // Load image from the file
            Console.WriteLine(" Loading image from Bitmap...");

            //BitmapImage image = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute));
            //FileInputStream fstream = new FileInputStream (filename);
            //Bitmap image = BitmapFactory.DecodeFile (filename);
            fp.AsBitmap = image;
            // Above update of fp.AsBitmapSource initialized also raw image in fp.Image
            // Check raw image dimensions, Y axis is first, X axis is second
            Console.WriteLine(" Image size = {0} x {1} (width x height)", fp.Image.GetLength(1), fp.Image.GetLength(0));

            // Initialize empty person object and set its properties
            MyPerson person = new MyPerson();

            person.Name = name;
            // Add fingerprint to the person
            person.Fingerprints.Add(fp);

            // Execute extraction in order to initialize fp.Template
            Console.WriteLine(" Extracting template...");
            Afis.Extract(person);
            // Check template size
            Console.WriteLine(" Template size = {0} bytes", fp.Template.Length);

            return(person);
        }
Пример #14
0
        // Take fingerprint image file and create Person object from the image
        static MyPerson Enroll(string filename, string name)
        {
            // Initialize empty fingerprint object and set properties
            MyFingerprint fp = new MyFingerprint();

            fp.Filename = filename;
            // Load image from the file
            BitmapImage image = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute));

            fp.AsBitmapSource = image;
            // Above update of fp.AsBitmapSource initialized also raw image in fp.Image
            // Check raw image dimensions, Y axis is first, X axis is second
            Console.WriteLine(" Image size = {0} x {1} (width x height)", fp.Image.GetLength(1), fp.Image.GetLength(0));

            // Initialize empty person object and set its properties
            MyPerson person = new MyPerson();

            person.Name = name;
            // Add fingerprint to the person
            person.Fingerprints.Add(fp);

            // Execute extraction in order to initialize fp.Template
            Afis.Extract(person);

            return(person);
        }
Пример #15
0
        private void btn_cmp_Click(object sender, EventArgs e)
        {
            Fingerprint fp2 = new Fingerprint();

            fp2.AsBitmap = new Bitmap(Bitmap.FromFile(pictureBox1.ImageLocation));
            Person p2 = new Person();

            p2.Fingerprints.Add(fp2);
            afis.Extract(p2);

            Person ans   = afis.Identify(p2, candidates).FirstOrDefault();
            bool   match = (ans != null);

            if (match)
            {
                DataSet ds = selectClassObj.get_enroll_no_by_id(ans.Id);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    count++;
                    List <Fingerprint> li = ans.Fingerprints;
                    foreach (Fingerprint f in li)
                    {
                        Bitmap bitmp = new Bitmap(f.AsBitmap);
                        pictureBox2.Image    = bitmp;
                        pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
                        pictureBox2.Refresh();
                    }
                    lbl_result.Text      = "Matched";
                    lbl_result.ForeColor = Color.Green;

                    lbl_result.Text += " " + ds.Tables[0].Rows[0]["enroll_no"];
                }
                else
                {
                    pictureBox2.Image    = null;
                    lbl_result.Text      = "Not Matched";
                    lbl_result.ForeColor = Color.Red;
                }
            }
            else
            {
                pictureBox2.Image    = null;
                lbl_result.Text      = "Not Matched";
                lbl_result.ForeColor = Color.Red;
            }
            MessageBox.Show("\nCount: " + count);
        }
Пример #16
0
        public void AsIsoTemplate()
        {
            Fingerprint fp1 = new Fingerprint()
            {
                AsBitmap = Settings.SomeFingerprint
            };

            Assert.IsNull(fp1.AsIsoTemplate);

            AfisEngine afis = new AfisEngine();

            afis.Extract(new Person(fp1));
            Assert.IsNotNull(fp1.AsIsoTemplate);

            Fingerprint fp2 = new Fingerprint()
            {
                AsIsoTemplate = fp1.AsIsoTemplate
            };

            Assert.AreEqual(fp1.AsIsoTemplate, fp2.AsIsoTemplate);
            Assert.IsNotNull(fp2.Template);
            Assert.IsNull(fp2.Image);

            Person person1 = new Person(fp1);
            Person person2 = new Person(fp2);
            Person person3 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.NonMatchingFingerprint
            });

            afis.Extract(person3);
            afis.Threshold = 0;
            Assert.That(afis.Verify(person1, person2) > afis.Verify(person1, person3));

            fp1.AsIsoTemplate = Settings.Template1_1;
            fp2.AsIsoTemplate = Settings.Template1_2;
            person3.Fingerprints[0].AsIsoTemplate = Settings.Template2_2;
            Assert.That(afis.Verify(person1, person2) > afis.Verify(person2, person3));
            fp2.AsIsoTemplate = Settings.Template2_2;
            Assert.That(afis.Verify(person1, person2) < afis.Verify(person2, person3));

            fp1.AsIsoTemplate = null;
            Assert.IsNull(fp1.AsIsoTemplate);

            Assert.Catch(() => { fp1.AsIsoTemplate = new byte[100]; });
            Assert.Catch(() => { fp1.AsIsoTemplate = fp2.Template; });
        }
Пример #17
0
 protected void btnXml_Click(object sender, EventArgs e)
 {
     fp.AsBitmap = new System.Drawing.Bitmap(System.Drawing.Bitmap.FromFile(HttpContext.Current.Server.MapPath("~/admin/ThumbData/probe.bmp")));
     kartik.Fingerprints.Add(fp);
     kartik.Id = 1;
     sfis.Extract(kartik);
     Serialize(kartik);
 }
Пример #18
0
        public void Identify()
        {
            AfisEngine afis    = new AfisEngine();
            Person     person1 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.SomeFingerprint
            });

            afis.Extract(person1);
            Person person2 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.MatchingFingerprint
            });

            afis.Extract(person2);
            Person person3 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.NonMatchingFingerprint
            });

            afis.Extract(person3);

            CollectionAssert.AreEqual(afis.Identify(person1, new[] { person2, person3 }), new[] { person2 });
            CollectionAssert.AreEqual(afis.Identify(person1, new[] { person3, person2 }), new[] { person2 });
            CollectionAssert.AreEqual(afis.Identify(person1, new[] { person3 }), new Person[0]);
            CollectionAssert.AreEqual(afis.Identify(person1, new[] { person2, person3, person1 }), new[] { person1, person2 });

            Person person4 = new Person(person2.Fingerprints[0], person3.Fingerprints[0]);

            CollectionAssert.AreEqual(afis.Identify(person1, new[] { person4 }), new[] { person4 });

            var bigArray = Enumerable.Repeat(person3, 100).Concat(new[] { person2 }).Concat(Enumerable.Repeat(person3, 100));

            CollectionAssert.AreEqual(afis.Identify(person1, bigArray), new[] { person2 });

            CollectionAssert.AreEqual(afis.Identify(person1, new Person[] { }), new Person[0]);
            CollectionAssert.AreEqual(afis.Identify(person1, new[] { new Person() }), new Person[0]);
            CollectionAssert.AreEqual(afis.Identify(new Person(), new[] { person2, person3 }), new Person[0]);

            Assert.Catch(() => { afis.Identify(null, new[] { person2, person3 }); });
            Assert.Catch(() => { afis.Identify(new Person(null), new[] { person2, person3 }); });
            Assert.Catch(() => { afis.Identify(person1, null); });
            Assert.Catch(() => { afis.Identify(person1, new[] { person2, null }); });
            Assert.Catch(() => { afis.Identify(person1, new[] { person2, new Person(null) }); });
        }
Пример #19
0
        //Ok
        /// <summary>
        /// FingerprintTemplate From Image
        /// </summary>
        /// <param name="_FingerImage">fingerprint image</param>
        /// <returns></returns>
        public static byte[] fingerprintImageToFingerprintTemplate(Bitmap _FingerImage)
        {
            Person      unknownPerson      = new Person();
            Fingerprint unknownFingerprint = new Fingerprint();

            unknownFingerprint.AsBitmap = _FingerImage;
            unknownPerson.Fingerprints.Add(unknownFingerprint);
            Afis.Extract(unknownPerson);
            return(unknownPerson.Fingerprints[0].Template);
        }
        public static Person makePersonObjFromImage(Bitmap img)
        {
            Person      toReturn    = new Person();
            Fingerprint fingerPrint = new Fingerprint();

            fingerPrint.AsBitmap = img;
            toReturn.Fingerprints.Add(fingerPrint);
            _afis.Extract(toReturn);
            return(toReturn);
        }
Пример #21
0
        private void selectClassRun(Object f, string path)
        {
            FileInfo fi = (FileInfo)f;
            //Console.WriteLine("Thread " + fi.Name);
            Fingerprint fp1 = new Fingerprint();

            fp1.AsBitmap = new Bitmap(Bitmap.FromFile(path + "\\" + fi.Name));
            Person p1 = new Person();

            p1.Fingerprints.Add(fp1);
            DataSet ds = selectClassObj.get_id_by_enroll_no(Path.GetFileNameWithoutExtension(fi.Name));

            if (ds.Tables[0].Rows.Count > 0)
            {
                p1.Id = Convert.ToInt32(ds.Tables[0].Rows[0]["stu_id"]);
            }
            afis.Extract(p1);
            cand.Add(p1);
        }
Пример #22
0
 private void ExtractMinutiae(Person person)
 {
     try
     {
         _afisEngine.Extract(person);
     }
     catch (Exception ex)
     {
         throw new Exception(CannotExtractMinutiaeError, ex);
     }
 }
Пример #23
0
        public void Dpi()
        {
            AfisEngine afis    = new AfisEngine();
            Person     person1 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.SomeFingerprint
            });
            Person person2 = person1.Clone();

            afis.Extract(person1);
            afis.Dpi = 750;
            afis.Extract(person2);
            Assert.AreNotEqual(person1.Fingerprints[0].Template, person2.Fingerprints[0].Template);
            Assert.That(afis.Verify(person1, person2) == 0);

            afis.Dpi = 230;
            afis.Dpi = 1000;
            Assert.Catch(() => { afis.Dpi = 90; });
            Assert.Catch(() => { afis.Dpi = 10000; });
        }
Пример #24
0
        private void btnProvjeraPrsta_Click(object sender, EventArgs e)
        {
            List <Otisak_prsta> listaOtisaka = new List <Otisak_prsta>();

            listaOtisaka = Otisak_prsta.DohvatiOtiske();
            foreach (var item in listaOtisaka)
            {
                Fingerprint fp = new Fingerprint();
                fp.AsBitmap = new Bitmap(Bitmap.FromFile(Application.StartupPath + item.Otisak_putanja));
                Person osoba = new Person();
                osoba.Id = item.FK_korisnik;
                osoba.Fingerprints.Add(fp);
                Afis.Extract(osoba);
                ListaOsobaIzBaze.Add(osoba);
            }

            Afis.Threshold = 40;
            Person matchingCandidate = Afis.Identify(NepoznataOsoba, ListaOsobaIzBaze).FirstOrDefault();

            if (matchingCandidate == null)
            {
                MessageBox.Show("Nije pronadena osoba s navedenim otiskom prsta!");
            }
            else
            {
                Korisnik trazeniKorisnik = new Korisnik();
                trazeniKorisnik = Korisnik.DohvatiKorisnika(matchingCandidate.Id);
                float score = Afis.Verify(NepoznataOsoba, matchingCandidate);
                bool  match = (score > 0);
                MessageBox.Show("Pronađen je korisnik: " + trazeniKorisnik.Korisnicko_ime + " s koeficijentom podudranja: " + score.ToString());
                if (trazeniKorisnik.Korisnicko_ime == textBoxKorIme.Text)
                {
                    zastavicaPrst              = true;
                    lblOsobaFinger.Text        = trazeniKorisnik.Korisnicko_ime;
                    lblOsobaFinger.ForeColor   = System.Drawing.Color.Green;
                    lblFingerTocnost.Text      = score.ToString();
                    lblFingerTocnost.ForeColor = System.Drawing.Color.Green;
                }
            }
            ProvjeraPrijave();
        }
Пример #25
0
        /// <summary>
        ///     Verify a candidates fingerprint
        /// </summary>
        /// <param name="c">The candidate to compare against</param>
        /// <param name="fp">The provided fingerprint</param>
        /// <returns>A float from 0 to 100 which represents the strength of the fingerprint match. Higher is better.</returns>
        public static float VerifyFingerprint(Candidate c, Fingerprint fp)
        {
            var afis = new AfisEngine();

            var test = new Person(fp);

            afis.Extract(test);

            var candidate = new Person(c.Fingerprint);

            return(afis.Verify(candidate, test));
        }
Пример #26
0
        public void AsXmlTemplate()
        {
            Fingerprint fp1 = new Fingerprint()
            {
                AsBitmap = Settings.SomeFingerprint
            };

            Assert.IsNull(fp1.AsXmlTemplate);

            AfisEngine afis = new AfisEngine();

            afis.Extract(new Person(fp1));
            Assert.IsNotNull(fp1.AsXmlTemplate);

            Fingerprint fp2 = new Fingerprint()
            {
                AsXmlTemplate = fp1.AsXmlTemplate
            };

            Assert.AreEqual(fp1.AsXmlTemplate.ToString(), fp2.AsXmlTemplate.ToString());
            Assert.IsNotNull(fp2.Template);
            Assert.IsNull(fp2.Image);

            Person person1 = new Person(fp1);
            Person person2 = new Person(fp2);
            Person person3 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.NonMatchingFingerprint
            });

            afis.Extract(person3);
            afis.Threshold = 0;
            Assert.That(afis.Verify(person1, person2) > afis.Verify(person1, person3));

            fp1.AsXmlTemplate = null;
            Assert.IsNull(fp1.AsXmlTemplate);
            Assert.IsNull(fp1.Template);

            Assert.Catch(() => { fp1.AsXmlTemplate = new XElement("garbage"); });
        }
Пример #27
0
        public static Usuario CompararDigital(string nome, string digital, List <string> comparar)
        {
            var Afis = new AfisEngine();

            Fingerprint Digital_Usuario = new Fingerprint();


            Digital_Usuario.AsBitmap = CriaImagem(digital);
            Person Usuario = new Person();

            Usuario.Fingerprints.Add(Digital_Usuario);
            Afis.Extract(Usuario);


            List <Person> Comparadores = new List <Person>();

            foreach (var item in comparar)
            {
                Fingerprint Digital = new Fingerprint();
                Digital.AsBitmap = CriaImagem(digital);
                Person Comparador = new Person();
                Comparador.Fingerprints.Add(Digital);
                Afis.Extract(Comparador);

                Comparadores.Add(Comparador);
            }

            Person Match = Afis.Identify(Usuario, Comparadores).FirstOrDefault();

            if (Match != null)
            {
                var _repo = new Usuario_Service();
                return(_repo.CarregarUsuario(nome));
            }
            else
            {
                return(null);
            }
        }
Пример #28
0
        static void buildDB(int TotalFiles, string path, string[] files, string[] share)
        {
            AfisEngine Afis = new AfisEngine();

            Afis.Threshold = 5;

            Fingerprint fp1 = new Fingerprint();
            Fingerprint fp2 = new Fingerprint();

            int k = 0;

            for (int i = 0; i < files.Length; i++)
            {
                fp1.AsBitmapSource = new BitmapImage(new Uri(files[i], UriKind.RelativeOrAbsolute));
                Person person1 = new Person();
                person1.Fingerprints.Add(fp1);
                Afis.Extract(person1);

                for (int j = 0; j < share.Length; j++)
                {
                    fp2.AsBitmapSource = new BitmapImage(new Uri(share[j], UriKind.RelativeOrAbsolute));
                    Person person2 = new Person();
                    person2.Fingerprints.Add(fp2);

                    Afis.Extract(person2);

                    float score = Afis.Verify(person1, person2);
                    bool  match = (score > Afis.Threshold);
                    Console.WriteLine(files[i] + "\n Compare with " + share[j]);
                    Console.WriteLine(score.ToString());
                    using (StreamWriter sw = File.AppendText(path))
                    {
                        sw.WriteLine(score.ToString());
                    }
                    k++;
                }
                Console.WriteLine("\n");
            }
        }
Пример #29
0
        public async Task <ActionResult> Create([Bind(Include = "logId,mortalId,dateTime_2,areaCode")] log log, FormCollection collection)
        {
            string fileNameInput = collection["filename"];

            AfisEngine Afis = new AfisEngine();

            Afis.Threshold = 10;

            Fingerprint fp1 = new Fingerprint();

            string apppath     = System.IO.Path.Combine(Server.MapPath("~"), "images");
            string pathToImage = (System.IO.Path.Combine(apppath, fileNameInput));

            Bitmap bitmap = fp1.AsBitmap = new Bitmap(Image.FromFile(pathToImage));

            MyPerson personsdk = new MyPerson();

            personsdk.Fingerprints.Add(fp1);

            Afis.Extract(personsdk);

            string          sql           = "Select * from mortal";
            List <mortal>   personListRom = db.mortals.SqlQuery(sql).ToList();
            List <MyPerson> personListRam = new List <MyPerson>();

            foreach (mortal p in personListRom)
            {
                MyPerson      personTemp = new MyPerson();
                MyFingerprint fpTemp     = new MyFingerprint();
                personTemp.Id        = p.mortalId;
                personTemp.Name      = p.name;
                fpTemp.Filename      = p.filename;
                fpTemp.AsXmlTemplate = XElement.Parse(p.template);
                personTemp.Fingerprints.Add(fpTemp);
                personListRam.Add(personTemp);
            }

            MyPerson match = Afis.Identify(personsdk, personListRam).FirstOrDefault() as MyPerson;

            log.mortalId = match.Id;
            if (ModelState.IsValid)
            {
                db.logs.Add(log);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.mortalId = new SelectList(db.mortals, "mortalId", "name", log.mortalId);
            return(View(log));
        }
Пример #30
0
        public void Threshold()
        {
            AfisEngine afis    = new AfisEngine();
            Person     person1 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.SomeFingerprint
            });

            afis.Extract(person1);
            Person person2 = new Person(new Fingerprint()
            {
                AsBitmap = Settings.MatchingFingerprint
            });

            afis.Extract(person2);

            float score = afis.Verify(person1, person2);

            Assert.That(score > 0);

            afis.Threshold = 1.001f * score;
            Assert.That(afis.Verify(person1, person2) == 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() == 0);

            afis.Threshold = 0.999f * score;
            Assert.That(afis.Verify(person1, person2) > 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() > 0);

            afis.Threshold = score;
            Assert.That(afis.Verify(person1, person2) > 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() > 0);

            afis.Threshold = 0;
            Assert.That(afis.Verify(person1, person2) > 0);
            Assert.That(afis.Identify(person1, new[] { person2 }).Count() > 0);

            Assert.Catch(() => { afis.Threshold = -0.001f; });
        }