Click here to Skip to main content
15,896,387 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
hi i have a table named "image" in my database where i am storing fingerprints.
i have a matching and finding code in C# and both of them work perfectly well.
Let me give u an idea about how the matching is done...there are two images(picturebox) Query and Template....when i load both of these with fingerprint it matches perfectly.

i have created a folder in which there are many fingerprint images and when i load a query image and click match it gives me the perfect match (by scanning that folder) and returns the image name.

NOW
the problem is that i want to scan images from database i.e. i want that after loading the query image in the picturebox and when i click find , it should scan each image that i have stored in my database , find the perfect match and it should after matching retrieve all the data related to that image(Eg: ID,name,email,contact...etc)

below is the code for find button:
private void btnFind_Click(object sender, EventArgs e)
{
    {

        double score;
        {

            // timage = null;
            string path = @"D:\db";
            string dir = Path.GetFileNameWithoutExtension(path);
            string[] filess = Directory.GetFiles(path, "*.tif*" , System.IO.SearchOption.AllDirectories);
            MessageBox.Show(dir);




            for (var i = 0; i < filess.Length; i++)
            {

                var item = filess[i];
                //work with item here
                // MessageBox.Show(filess[i]);
                // pbxTemplateImg.Image = tImage;


                tImage = ImageLoader.LoadImage(filess[i]);
                pbxTemplateImg.Image = tImage;

                {
                    string shortFileName = Path.GetFileNameWithoutExtension(filess[i]);
                    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;
                    }
                }






                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();
                            if (score > 70)
                            {
                                MessageBox.Show(string.Format("Similarity: {0}. Matching minutiae: {1}.", score,
                                                              matchingMtiae.Count));
                            }
                        }
                    }
                    else
                        ShowResults(score, matchingMtiae);

                }
                else
                    score = matcher.Match(qFeatures, tFeatures);
                if (score < 70)
                {
                    //MessageBox.Show("match nt found");
                    //break;


                }
                else
                {

                    MessageBox.Show("match found");
                    break;
                }

            }
        }
    }
}
Posted
Updated 9-Mar-13 21:34pm
v2

1 solution

There are several methods to compare images. See this: http://stackoverflow.com/questions/843972/image-comparison-fast-algorithm[^].

Here is pretty good example: Simple image comparison in .NET[^]
 
Share this answer
 
Comments
Member 8657300 10-Mar-13 11:26am    
hi maciej
thanks for link , but as i mentioned above my code is for matching fingerprints...for which i have the above code...i just wanted to access the database , match each image with the query image that i will provide...and after finding the perfect match it should return other records....the code i have mentioned above matches perfectly but the problem is it matches fingerprints stored in a folder...i want it to match fingerprints stored in a database...
/////////////////////////////////////////////////////////////////////////////////////
string path = @"D:\db";
string dir = Path.GetFileNameWithoutExtension(path);
string[] filess = Directory.GetFiles(path, "*.tif*" , System.IO.SearchOption.AllDirectories);
MessageBox.Show(dir);
///////////////////////////////////////////////////////////////////////////////////
this is the code i am using for scanning the folder...you can also see the path i have mentioned(folder's)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900