none
Fingerprint verification RRS feed

  • Question

  • sir i have digitalpersonna u are u 4000b sensor and i have made c# interface using mysql when i enroll the record in sql it save it successfully 

    this code is for data enroll it works normally

                                                                             

    internal class EnrollmentResult
    {
    public NffvStatus engineStatus;
    public NffvUser engineUser;
    };


    private void btnEnroll_Click(object sender, EventArgs e)
    {


    try
    {
    RunWorkerCompletedEventArgs taskResult = BusyForm.RunLongTask("Waiting for fingerprint ...", new DoWorkEventHandler(doEnroll),
    false, null, new EventHandler(CancelScanningHandler));
    EnrollmentResult enrollmentResult = (EnrollmentResult)taskResult.Result;
    if (enrollmentResult.engineStatus == NffvStatus.TemplateCreated)
    {
                            NffvUser engineUser = enrollmentResult.engineUser;
                            pbExtractedImage.Image = engineUser.GetBitmap();



                            con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Arshad\\Documents\\MyWorkers.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
                            System.Data.SqlClient.SqlCommandBuilder cb;
                            cb = new System.Data.SqlClient.SqlCommandBuilder(da);

                            DataRow dRow = ds1.Tables["Workers"].NewRow();

                            dRow[1] = textBox1.Text;
                            dRow[2] = textBox2.Text;
                            dRow[3] = textBox3.Text;


                            MemoryStream ms = new MemoryStream();
                            //save the image into memory stream
                            pbExtractedImage.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                            //assign the byte array with total size of memorystream
                            photo = ms.ToArray();
                            dRow[4] = photo;

                            ds1.Tables["Workers"].Rows.Add(dRow);

                            MaxRows = MaxRows + 1;
                            inc = MaxRows - 1;


                            da.Update(ds1, "Workers");
                            MessageBox.Show("Entry Added sUccESsFully");



    }
    else
    {
    NffvStatus engineStatus = enrollmentResult.engineStatus;
    MessageBox.Show(string.Format("Enrollment was not finished. Reason: {0}", engineStatus));
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }

            }

     private void doEnroll(object sender, DoWorkEventArgs args)
            {
                EnrollmentResult enrollmentResults = new EnrollmentResult();
                enrollmentResults.engineUser = _engine.Enroll(20000, out enrollmentResults.engineStatus);
                args.Result = enrollmentResults;
            }

                                                                         

    respected sir following code is for verification but it not works .     it works on two images but not for fingerprints                                                   

     internal class VerificationResult
    {
                public NffvStatus engineStatus;
                public NffvUser engineUser;
    };

         private void btnVerify_Click(object sender, EventArgs e)
         {
             Bitmap img1, img2;
             int count1 = 0, count2 = 0;
             string img1_ref, img2_ref;
             bool flag = true; 

             con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Arshad\\Documents\\MyWorkers.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
             System.Data.SqlClient.SqlCommandBuilder cb;
             cb = new System.Data.SqlClient.SqlCommandBuilder(da);

             DataRow dRow = ds1.Tables["Workers"].Rows[28];
             byte[] mydata = new byte[0];

             mydata = (byte[])dRow[4];


             MemoryStream stream1 = new MemoryStream(mydata);
             pictureBox1.Image = Image.FromStream(stream1);
              img1 = new Bitmap(Image.FromStream(stream1));

              try
              {
                  RunWorkerCompletedEventArgs taskResult = BusyForm.RunLongTask("Waiting for fingerprint ...", new DoWorkEventHandler(doVerify),
                      false, null, new EventHandler(CancelScanningHandler));
                  VerificationResult verificationResult = (VerificationResult)taskResult.Result;



                  NffvUser engineUser = verificationResult.engineUser;
                 pbExtractedImage.Image = engineUser.GetBitmap();
                  img2 = new Bitmap(engineUser.GetBitmap());







               if (img1.Width == img2.Width && img1.Height == img2.Height)
                  {
                     for (int i = 0; i < img1.Width; i++)
                      {
                          for (int j = 0; j < img1.Height; j++)
                          {
                              img1_ref = img1.GetPixel(i, j).ToString();
                              img2_ref = img2.GetPixel(i, j).ToString();

                              if (img1_ref != img2_ref)
                              {
                                  count2++;
                                 // flag = false;
                                  break;
                              }

                               count1++;




                          }
                       //   progressBar1.Value++;
                      }

                      if (flag == false)
                          MessageBox.Show("Sorry, Images are not same , " + count2 + " wrong pixels found");
                      else
                          MessageBox.Show(" Images are same , " + count1 + " same pixels found  and " + count2 + " wrong pixels found");
                  }
                  else
                      MessageBox.Show("can not compare this images");


              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
         }



    private void doVerify(object sender, DoWorkEventArgs args)
    {
    VerificationResult verificationResult = new VerificationResult();
                verificationResult.engineUser = _engine.Enroll(20000, out verificationResult.engineStatus);
    args.Result = verificationResult;

    }

                                                                                                                                                                                                                                                  
    Saturday, October 20, 2012 8:22 AM

Answers

  • If you are getting the same results every time then yu aren't really looking at the image.  I think the problem is with these two lines of code

                              img1_ref = img1.GetPixel(i, j).ToString();
                              img2_ref = img2.GetPixel(i, j).ToString();

    You should not be using ToString().  ToString() will only return the name of the object not the contents of the object.  Try this instead

                              img1_ref = img1.GetPixel(i, j);
                              img2_ref = img2.GetPixel(i, j);

    GetPixel() will return a byte so img1_ref should be a byte[].


    jdweng

    Monday, October 22, 2012 9:35 AM

All replies

  • sir i have digitalpersonna u are u 4000b sensor and i have made c# interface using mysql when i enroll the record in sql it save it successfully 

    i used this function for storing image in data base

                           

     con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Arshad\\Documents\\MyWorkers.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
                            System.Data.SqlClient.SqlCommandBuilder cb;
                            cb = new System.Data.SqlClient.SqlCommandBuilder(da);

                            DataRow dRow = ds1.Tables["Workers"].NewRow();

                            dRow[1] = textBox1.Text;
                            dRow[2] = textBox2.Text;
                            dRow[3] = textBox3.Text;


                            MemoryStream ms = new MemoryStream();
                            //save the image into memory stream
                            pbExtractedImage.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                            //assign the byte array with total size of memorystream
                            photo = ms.ToArray();
                            dRow[4] = photo;

                            ds1.Tables["Workers"].Rows.Add(dRow);

    but whenever i verify this fingerprint it can not verify it please sir give me suggestions what should i do 

    • Merged by Alexander Sun Tuesday, October 23, 2012 9:00 AM Duplicate
    Monday, October 15, 2012 10:49 AM
  • Hi ArshadMaliik,

    Welcome to the MSDN forum.

    Could you please provide some code snippet about verification?

    Best Regards,


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, October 17, 2012 3:01 AM
  • Can you be more specific where the  code is failing?

    You may be timing out on the following statement

     con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Arshad\\Documents\\MyWorkers.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";


    jdweng

    Saturday, October 20, 2012 11:40 AM
  • no sir it can not compare my fingerprint which i storte in databbase and when i want to verify it  

    when i compare stored fingerprint with my fingerprint or any other fp it shows same result

    e.g               

      Images are same , 3600 same pixels found  and 200 wrong pixels found

    it shows this type of result with every comparison whether it is correct or not


    Monday, October 22, 2012 8:42 AM
  • If you are getting the same results every time then yu aren't really looking at the image.  I think the problem is with these two lines of code

                              img1_ref = img1.GetPixel(i, j).ToString();
                              img2_ref = img2.GetPixel(i, j).ToString();

    You should not be using ToString().  ToString() will only return the name of the object not the contents of the object.  Try this instead

                              img1_ref = img1.GetPixel(i, j);
                              img2_ref = img2.GetPixel(i, j);

    GetPixel() will return a byte so img1_ref should be a byte[].


    jdweng

    Monday, October 22, 2012 9:35 AM