Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
private void button1_Click(object sender, EventArgs e)
        {

            SqlConnection cn = new SqlConnection(@"Data Source=SAZ-PC\SQLEXPRESS;Initial Catalog=Voted;Integrated Security=True");
            SqlCommand cmd1 = new SqlCommand("select FINGERPRINT from Regdmem ", cn);
            cn.Open();
            Byte[] barrImg = (Byte[])cmd1.ExecuteScalar();
            foreach (byte fp in barrImg)
            {
                Byte[] bytes = File.ReadAllBytes("D:\\Image.bmp");
                bool cmp = barrImg.SequenceEqual(bytes);

                if (cmp == true)
                {
                    Form3 f3 = new Form3();
                    f3.Show();
                    this.Hide();

                }
                else
                {
                    Application.Exit();
                }
            }

            cn.Close();
            }


I have a database in which there is a column named "FINGERPRINT" in that column multiple of images are stored and on the other hand i have an image stored in my drive("D:\\Image.bmp") .. so my point is to search my drive image in database if my image exist in the database go to next form else exit.. please help :(
Posted

To be honest, I think you are making some huge mistakes here.
Ignoring mechanics of changing your code to work with more than a single row in your database - which is pretty trivial, but will make for some serious sized data transfers and probably be so slow you can't use it - I don't think this is going to work in practice.

The problem is that unless the two images are identical down to the last tiny detail this will fail. And the only way - the absolutely, positively, definitely, only way - you will get that is if they are the same image. Not two different images of the same finger, but the same images. A tiny, unnoticeable change in position, angle or lighting will make the two images wildly different! So if you want to use this to detect fingerprints, then this is totally the wrong approach, and you really, really, shouldn't waste any more of your time on it.

If you must compare the images to just find the same image, then the first thing to do is not to retrieve any images! Instead, use MD5 or SHA (preferably the later, but it doesn't matter that MD5 is broken for this application) and store that as well as the image data, in a separate column. You then fetch all hash value columns and ids only, and compare that against the hash value you calculate for the image you want to check - only when you find a match do you retrieve the actual image data and compare it directly. This reduces the amount of data you are fetching and comparing to a near-trivial amount and will make your code a lot faster!
C#
using (SqlConnection cn = new SqlConnection(@"Data Source=SAZ-PC\SQLEXPRESS;Initial Catalog=Voted;Integrated Security=True"))
    {
    using (SqlCommand cmd1 = new SqlCommand("select ID, HashValue from Regdmem ", cn))
        {
        cn.Open();
        using (SqlDataReader reader = cmd1.ExecuteReader())
            {
            while (reader.Read())
                {
                int id = (int)reader["ID"];
                byte[] hash = (byte[])reader["HashValue"];
                // Compare the hashes here, and if them match, retrieve
                //    the image data from it's ID and compare those.
                //    If they don't, ignore it and try the next.

                }
            }
        }
    }
 
Share this answer
 
save image Hash value in other column
 
Share this answer
 

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