private void ShowResults(double matchingScore, List <MinutiaPair> matchingMtiae)
        {
            if (matchingScore == 0 || matchingMtiae == null)
            {
                MessageBox.Show(string.Format("Similarity: {0}.", matchingScore));
            }
            else
            {
                List <Minutia> qMtiae = new List <Minutia>();
                List <Minutia> tMtiae = new List <Minutia>();
                foreach (MinutiaPair mPair in matchingMtiae)
                {
                    qMtiae.Add(mPair.QueryMtia);
                    tMtiae.Add(mPair.TemplateMtia);
                }
                IFeatureDisplay <List <Minutia> > display = new MinutiaeDisplay();

                pbxQueryImg.Image = qImage.Clone() as Bitmap;
                Graphics g = Graphics.FromImage(pbxQueryImg.Image);
                display.Show(qMtiae, g);
                pbxQueryImg.Invalidate();

                pbxTemplateImg.Image = tImage.Clone() as Bitmap;
                g = Graphics.FromImage(pbxTemplateImg.Image);
                display.Show(tMtiae, g);
                pbxTemplateImg.Invalidate();

                MessageBox.Show(string.Format("Similarity: {0}. Matching minutiae: {1}.", matchingScore,
                                              matchingMtiae.Count));
            }
        }
        private void ShowResults(double matchingScore, List<MinutiaPair> matchingMtiae)
        {
            if (matchingScore == 0 || matchingMtiae == null)
                MessageBox.Show(string.Format("Similarity: {0}.", matchingScore));
            else
            {
                List<Minutia> qMtiae = new List<Minutia>();
                List<Minutia> tMtiae = new List<Minutia>();
                foreach (MinutiaPair mPair in matchingMtiae)
                {
                    qMtiae.Add(mPair.QueryMtia);
                    tMtiae.Add(mPair.TemplateMtia);
                }
                IFeatureDisplay<List<Minutia>> display = new MinutiaeDisplay();

                pbxQueryImg.Image = qImage.Clone() as Bitmap;
                Graphics g = Graphics.FromImage(pbxQueryImg.Image);
                display.Show(qMtiae, g);
                pbxQueryImg.Invalidate();

                pbxTemplateImg.Image = tImage.Clone() as Bitmap;
                g = Graphics.FromImage(pbxTemplateImg.Image);
                display.Show(tMtiae, g);
                pbxTemplateImg.Invalidate();

                MessageBox.Show(string.Format("Similarity: {0}. Matching minutiae: {1}.", matchingScore,
                                              matchingMtiae.Count));
            }
        }
Exemplo n.º 3
0
        public override void Show(List <Minutia> features, Graphics g)
        {
            var mtpFeatureExtractor = new MTripletsExtractor()
            {
                NeighborsCount = 2
            };
            MtripletsFeature mtriplets = mtpFeatureExtractor.ExtractFeatures(features);

            foreach (MTriplet mt in mtriplets.MTriplets)
            {
                Pen pen = new Pen(Color.Blue)
                {
                    Width = 2
                };
                Point[] points = new Point[3];
                for (int i = 0; i < 3; i++)
                {
                    points[i] = new Point()
                    {
                        X = Convert.ToInt32(mt[i].X),
                        Y = Convert.ToInt32(mt[i].Y)
                    }
                }
                ;
                g.DrawPolygon(new Pen(Color.White, 4), points);
                g.DrawPolygon(pen, points);
            }

            var mtiaDisplay = new MinutiaeDisplay();

            mtiaDisplay.Show(mtriplets.Minutiae, g);
        }
    }
        private void btnMatch_Click(object sender, EventArgs e)
        {
            Stopwatch st = new Stopwatch();

            st.Start();

            if (qImage == null)
            {
                MessageBox.Show("Unable to match fingerprints: Unassigned query fingerprint!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (tImage == null)
            {
                MessageBox.Show("Unable to match fingerprints: Unassigned template fingerprint!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Matching features
            List <MinutiaPair> matchingMtiae = null;
            double             score;
            IMinutiaMatcher    minutiaMatcher = matcher as IMinutiaMatcher;

            if (minutiaMatcher != null)
            {
                score = minutiaMatcher.Match(qFeatures, tFeatures, out matchingMtiae);

                st.Stop();
                tm3 = st.Elapsed;

                if (qFeatures is List <Minutia> && tFeatures is List <Minutia> )
                {
                    pbxQueryImg.Image = qImage.Clone() as Bitmap;
                    Graphics g1 = Graphics.FromImage(pbxQueryImg.Image);
                    ShowBlueMinutiae(qFeatures as List <Minutia>, g1);
                    //pbxQueryImg.Invalidate();

                    pbxTemplateImg.Image = tImage.Clone() as Bitmap;
                    Graphics g2 = Graphics.FromImage(pbxTemplateImg.Image);
                    ShowBlueMinutiae(tFeatures as List <Minutia>, g2);
                    //pbxTemplateImg.Invalidate();

                    if (score == 0 || matchingMtiae == null)
                    {
                        MessageBox.Show(string.Format("Similarity: {0}.", score));
                    }
                    else
                    {
                        List <Minutia> qMtiae = new List <Minutia>();
                        List <Minutia> tMtiae = new List <Minutia>();
                        foreach (MinutiaPair mPair in matchingMtiae)
                        {
                            qMtiae.Add(mPair.QueryMtia);
                            tMtiae.Add(mPair.TemplateMtia);
                        }
                        IFeatureDisplay <List <Minutia> > display = new MinutiaeDisplay();

                        display.Show(qMtiae, g1);
                        pbxQueryImg.Invalidate();

                        display.Show(tMtiae, g2);
                        pbxTemplateImg.Invalidate();

                        MessageBox.Show(string.Format("Similarity: {0}. Matching minutiae: {1}.", score, matchingMtiae.Count), "Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    ShowResults(score, matchingMtiae);
                }
            }
            else
            {
                score = matcher.Match(qFeatures, tFeatures);
            }

            ShowTime();
        }
Exemplo n.º 5
0
        private void btnMatchInDatabase_Click(object sender, EventArgs e)
        {
            if (qImage == null)
            {
                MessageBox.Show("Unable to match fingerprints: Unassigned query fingerprint!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Stopwatch stDetect = new Stopwatch();
            Stopwatch stFinish = new Stopwatch();

            stDetect.Start();
            stFinish.Start();

            IMinutiaMatcher minutiaMatcher = matcher as IMinutiaMatcher;

            if (minutiaMatcher != null)
            {
                List <MinutiaPair> matchingMtiae = null;

                string filename, shortFileName;
                double score = 0.0, maxScore = 0.0;
                int    idIndex = -1;

                for (int i = 0; i < sizerow; i++)
                {
                    filename      = FingerData.Rows[i][4].ToString();
                    shortFileName = Path.GetFileNameWithoutExtension(filename);
                    try
                    {
                        tFeatures = provider.GetResource(shortFileName, repository);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Unable to load features " + provider.GetSignature() + ". Try using different parameters.", "Feature Loading Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    //-----------------------------

                    matchingMtiae = null;
                    try
                    {
                        score = minutiaMatcher.Match(qFeatures, tFeatures, out matchingMtiae);
                    }
                    catch (Exception superE)
                    {
                        //Phat hien van tay giong 100%
                        maxScore = 100.0;
                        idIndex  = i;
                        try
                        {
                            stDetect.Stop();
                            TimeDetect = stDetect.Elapsed;
                        }
                        catch
                        {
                            //For second time
                        }
                        //break;
                    }

                    if (score > maxScore)
                    {
                        try
                        {
                            stDetect.Stop();
                            TimeDetect = stDetect.Elapsed;
                        }
                        catch
                        {
                            //For second time
                        }
                        maxScore = score;
                        idIndex  = i;
                    }
                }

                stFinish.Stop();
                TimeFinish = stFinish.Elapsed;

                //Print output
                tbxRecordID.Text         = FingerData.Rows[idIndex][0].ToString();
                tbxFullname.Text         = FingerData.Rows[idIndex][1].ToString();
                tbxInformation.Text      = FingerData.Rows[idIndex][2].ToString();
                tbxFingerprintImage.Text = FingerData.Rows[idIndex][3].ToString();

                filename      = FingerData.Rows[idIndex][4].ToString();
                shortFileName = Path.GetFileNameWithoutExtension(filename);

                tFeatures            = provider.GetResource(shortFileName, repository);
                tImage               = ImageLoader.LoadImage(filename);
                pbxTemplateImg.Image = tImage;

                matchingMtiae = null;
                double score2 = minutiaMatcher.Match(qFeatures, tFeatures, out matchingMtiae);
                stScore = score2.ToString();

                if (qFeatures is List <Minutia> && tFeatures is List <Minutia> )
                {
                    pbxQueryImg.Image = qImage.Clone() as Bitmap;
                    Graphics g1 = Graphics.FromImage(pbxQueryImg.Image);
                    ShowBlueMinutiae(qFeatures as List <Minutia>, g1);
                    //pbxQueryImg.Invalidate();

                    pbxTemplateImg.Image = tImage.Clone() as Bitmap;
                    Graphics g2 = Graphics.FromImage(pbxTemplateImg.Image);
                    ShowBlueMinutiae(tFeatures as List <Minutia>, g2);
                    //pbxTemplateImg.Invalidate();

                    if (score2 == 0 || matchingMtiae == null)
                    {
                        MessageBox.Show(string.Format("Similarity: {0}.", score2));
                    }
                    else
                    {
                        List <Minutia> qMtiae = new List <Minutia>();
                        List <Minutia> tMtiae = new List <Minutia>();
                        foreach (MinutiaPair mPair in matchingMtiae)
                        {
                            qMtiae.Add(mPair.QueryMtia);
                            tMtiae.Add(mPair.TemplateMtia);
                        }
                        IFeatureDisplay <List <Minutia> > display = new MinutiaeDisplay();

                        display.Show(qMtiae, g1);
                        pbxQueryImg.Invalidate();

                        display.Show(tMtiae, g2);
                        pbxTemplateImg.Invalidate();

                        MessageBox.Show(string.Format("Full name: {0}\nInformation: {1}\nSimilarity: {2}. Matching minutiae: {3}.", tbxFullname.Text.ToString(), tbxInformation.Text.ToString(), score2, matchingMtiae.Count), "Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("Full name: {0}\nInformation: {1}\nSimilarity: {2}. Matching minutiae: {3}.", tbxFullname.Text.ToString(), tbxInformation.Text.ToString(), score2, matchingMtiae.Count), "Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowResults(score2, matchingMtiae);
                }
            }
            else
            {
                double score = matcher.Match(qFeatures, tFeatures);
            }
            ShowTime();
        }
        private void btnMatch_Click(object sender, EventArgs e)
        {
            if (qImage == null)
            {
                MessageBox.Show("Unable to match fingerprints: Unassigned query fingerprint!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (tImage == null)
            {
                MessageBox.Show("Unable to match fingerprints: Unassigned template fingerprint!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Matching features
            List<MinutiaPair> matchingMtiae = null;
            double score;
            IMinutiaMatcher minutiaMatcher = matcher as IMinutiaMatcher;
            if (minutiaMatcher != null)
            {
                score = minutiaMatcher.Match(qFeatures, tFeatures, out matchingMtiae);

                if (qFeatures is List<Minutia> && tFeatures is List<Minutia>)
                {
                    pbxQueryImg.Image = qImage.Clone() as Bitmap;
                    Graphics g1 = Graphics.FromImage(pbxQueryImg.Image);
                    ShowBlueMinutiae(qFeatures as List<Minutia>, g1);
                    //pbxQueryImg.Invalidate();

                    pbxTemplateImg.Image = tImage.Clone() as Bitmap;
                    Graphics g2 = Graphics.FromImage(pbxTemplateImg.Image);
                    ShowBlueMinutiae(tFeatures as List<Minutia>, g2);
                    //pbxTemplateImg.Invalidate();

                    if (score == 0 || matchingMtiae == null)
                        MessageBox.Show(string.Format("Similarity: {0}.", score));
                    else
                    {
                        List<Minutia> qMtiae = new List<Minutia>();
                        List<Minutia> tMtiae = new List<Minutia>();
                        foreach (MinutiaPair mPair in matchingMtiae)
                        {
                            qMtiae.Add(mPair.QueryMtia);
                            tMtiae.Add(mPair.TemplateMtia);
                        }
                        IFeatureDisplay<List<Minutia>> display = new MinutiaeDisplay();

                        display.Show(qMtiae, g1);
                        pbxQueryImg.Invalidate();

                        display.Show(tMtiae, g2);
                        pbxTemplateImg.Invalidate();

                        MessageBox.Show(string.Format("Similarity: {0}. Matching minutiae: {1}.", score,
                                                      matchingMtiae.Count));
                    }
                }
                else
                    ShowResults(score, matchingMtiae);
            }
            else
                score = matcher.Match(qFeatures, tFeatures);
        }