static void Main(string[] args)
        {
            var repositorio = new DigitalRepositorio();
            var biometrias  = repositorio.RecuperarPagina(1, 8000);

            Console.WriteLine($"{biometrias.Count()} biometrias recuperadas...");

            foreach (var biometria in biometrias)
            {
                var teste = FeatureExtraction.CreateFmdFromRaw(biometria.TemplateISO, 1, 1, 1, 1, 1, Constants.Formats.Fmd.ISO);
            }
        }
예제 #2
0
        /// <summary>
        /// Create FMD from samples
        /// </summary>
        /// <param name="fid"></param>
        /// <returns></returns>
        private IEnumerable <Fmd> CreateFMD(string folderPath)
        {
            //Convert the fingerprint samples to raw byte[]
            //Create FMD of the fingerprint samples from Raw
            foreach (string file in Directory.EnumerateFiles(folderPath, "*.bmp"))
            {
                Image img = Image.FromFile(file);

                //DataResult<Fmd> data = Importer.ImportFmd(imageToByteArray(img), Constants.Formats.Fmd.ISO, Constants.Formats.Fmd.ISO);
                //yield return data.Data;

                DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromRaw(ConvertToRaw(img), 0, 0, img.Width, img.Height,
                                                                          (int)img.HorizontalResolution, Constants.Formats.Fmd.ISO);

                yield return(fmd.Data);
            }
        }
예제 #3
0
        /// <summary>
        /// Finger print verification
        /// </summary>
        private void FingerprintVerifcation1()
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                string identification = string.Empty;
                string scores         = string.Empty;
                string folderPath     = this.txtDirectory.Text; //delcare the folder containing fingerprint samples
                string fileName       = "matchScores.txt";

                //Convert the uploaded fingerprint to raw byte[]
                //Create FMD of the uploaded fingerprint from Raw
                DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromRaw(ConvertToRaw(this.fingerprint), 0, 0, fingerprint.Width, fingerprint.Height,
                                                                          (int)this.fingerprint.HorizontalResolution, Constants.Formats.Fmd.ISO);

                string[] directories = Directory.GetDirectories(folderPath);

                if (directories.Length > 0)
                {
                    foreach (string subDirPath in directories)
                    {
                        scores = string.Empty;
                        //Convert the fingerprint samples to raw byte[]
                        //Create FMD of the fingerprint samples from Raw
                        IEnumerable <Fmd> fingerPrintFMD = CreateFMD(subDirPath);

                        //Compare the uploaded fingerprint with fingerprint samples
                        foreach (Fmd sampleFMD in fingerPrintFMD)
                        {
                            if (sampleFMD == null)
                            {
                                int matchScore = Int32.MaxValue;
                                scores += matchScore.ToString() + "; ";
                                continue;
                            }
                            else
                            {
                                CompareResult rst = Comparison.Compare(fmd.Data, 0, sampleFMD, 0);

                                if (rst.Score == 0)
                                {
                                    identification += Path.GetFileName(subDirPath) + " - ";
                                }

                                scores += rst.Score.ToString() + "; ";
                            }
                        }

                        //Store match scores in a string array
                        scores = scores.Substring(0, scores.Length - 2);
                        string[] matchScoreArr = scores.Split(';');

                        if (File.Exists(subDirPath + "\\" + fileName))
                        {
                            File.Delete(subDirPath + "\\" + fileName);
                        }

                        //Create data table containing file name and match scores
                        DataTable dtScores = new DataTable();
                        dtScores.Columns.Add("FileName");
                        dtScores.Columns.Add("MatchScores");

                        for (int i = 0; i < Directory.GetFiles(subDirPath).Length; i++)
                        {
                            DataRow dr = dtScores.NewRow();
                            dr["FileName"]    = Directory.GetFiles(subDirPath)[i];
                            dr["MatchScores"] = matchScoreArr[i];
                            dtScores.Rows.Add(dr);
                        }

                        //write match scores into a file
                        CreateFile(dtScores, subDirPath + "\\" + fileName);
                    }
                }
                else
                {
                    //Convert the fingerprint samples to raw byte[]
                    //Create FMD of the fingerprint samples from Raw
                    IEnumerable <Fmd> fingerPrintFMD = CreateFMD(folderPath);

                    //Compare the uploaded fingerprint with fingerprint samples
                    foreach (Fmd sampleFMD in fingerPrintFMD)
                    {
                        if (sampleFMD == null)
                        {
                            int matchScore = Int32.MaxValue;
                            scores += matchScore.ToString() + "; ";
                            continue;
                        }
                        else
                        {
                            CompareResult rst = Comparison.Compare(fmd.Data, 0, sampleFMD, 0);
                            //scores += rst.Score.ToString() + "; ";
                            if (rst.Score == 0)
                            {
                                identification += Path.GetFileName(folderPath) + " - ";
                            }

                            scores += rst.Score.ToString() + "; ";
                        }
                    }

                    //Store match scores in a string array
                    scores = scores.Substring(0, scores.Length - 2);
                    string[] matchScoreArr = scores.Split(';');

                    if (File.Exists(folderPath + "\\" + fileName))
                    {
                        File.Delete(folderPath + "\\" + fileName);
                    }

                    //Create data table containing file name and match scores
                    DataTable dtScores = new DataTable();
                    dtScores.Columns.Add("FileName");
                    dtScores.Columns.Add("MatchScores");

                    for (int i = 0; i < Directory.GetFiles(folderPath).Length; i++)
                    {
                        DataRow dr = dtScores.NewRow();
                        dr["FileName"]    = Directory.GetFiles(folderPath)[i];
                        dr["MatchScores"] = matchScoreArr[i];
                        dtScores.Rows.Add(dr);
                    }

                    //write match scores into a file
                    CreateFile(dtScores, folderPath + "\\" + fileName);
                }

                if (identification.Trim().Equals(string.Empty))
                {
                    MessageBox.Show("No match found!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    identification = identification.Substring(0, identification.Length - 2);
                    MessageBox.Show("Identified candidates: " + identification.Trim(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                MessageBox.Show("Verification done! A text file with match scores has been created in every folder containing fingerprint samples",
                                "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                throw;
            }

            this.Cursor = Cursors.Arrow;
        }