コード例 #1
0
ファイル: Main.cs プロジェクト: shadrackkip/Biometric_system
        private void BtnCapture1_Click(object sender, EventArgs e)
        {
            Byte[] fp_image = new Byte[m_ImageWidth * m_ImageHeight];
            Int32  error    = (Int32)SGFPMError.ERROR_NONE;
            Int32  img_qlty = 0;
            Int32  info;


            if (m_DeviceOpened)
            {
                error = m_FPM.GetImage(fp_image);
            }
            else
            {
                error = GetImageFromFile(fp_image);
            }

            if (error == (Int32)SGFPMError.ERROR_NONE)
            {
                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
                progressBar_R1.Value = img_qlty;

                DrawImage(fp_image, pictureBoxR1);

                SGFPMFingerInfo finger_info = new SGFPMFingerInfo();
                //   finger_info.FingerNumber = (SGFPMFingerPosition)comboBoxSelFinger.SelectedIndex;
                finger_info.ImageQuality   = (Int16)img_qlty;
                finger_info.ImpressionType = (Int16)SGFPMImpressionType.IMPTYPE_LP;
                finger_info.ViewNumber     = 1;

                // CreateTemplate
                info = m_FPM.CreateTemplate(finger_info, fp_image, m_RegMin1);

                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    StatusBar.Text = "Image is captured";
                }
                else
                {
                    StatusBar.Text = "GetMinutiae() Error : " + error;
                }
            }
            else
            {
                StatusBar.Text = "GetImage() Error . Try again: " + error;
            }
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                Int32  iError;
                Byte[] fp_image;
                Int32  img_qlty;

                fp_image = new Byte[m_ImageWidth * m_ImageHeight];
                img_qlty = 0;

                iError = m_FPM.GetImage(fp_image);

                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);


                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    DrawImage(fp_image, pictureBox3);
                    iError = m_FPM.CreateTemplate(fp_image, m_RegMin1);

                    if (iError == (Int32)SGFPMError.ERROR_NONE)
                    {
                        pictureBox3.Image.Save(@"Finger\" + textBox1.Text + ".jpg");
                        SqlCommand cmd = new SqlCommand("Insert into Voter (UserId,Name,Mobile,Address,Image,Template) Values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + @"Image\" + textBox1.Text + ".jpg" + "',@data)", con);
                        con.Open();
                        cmd.Parameters.AddWithValue("@data", fp_image);
                        cmd.ExecuteNonQuery();
                        con.Close();
                        DialogResult d = MessageBox.Show("Voter Registred Successfully", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (d == DialogResult.OK)
                        {
                            textBox1.Text     = "";
                            textBox2.Text     = "";
                            textBox3.Text     = "";
                            textBox4.Text     = "";
                            pictureBox2.Image = null;
                            pictureBox3.Image = null;
                        }
                    }
                    else
                    {
                        DisplayError("CreateTemplate()", iError);
                    }
                }
                else
                {
                    MessageBox.Show("Finger Capturing Failed", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("please Enter User Id", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        private void btnR1_Click(object sender, EventArgs e)
        {
            try
            {
                Int32  iError;
                Byte[] fp_image;
                Int32  img_qlty;

                m_RegMin1 = new Byte[400];
                fp_image  = new Byte[m_ImageWidth * m_ImageHeight];
                img_qlty  = 0;


                iError = m_FPM.GetImage(fp_image);

                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
                prgR1.Value = img_qlty;

                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    DrawImage(fp_image, picR1);
                    iError = m_FPM.CreateTemplate(fp_image, m_RegMin1);

                    if (iError == (Int32)SGFPMError.ERROR_NONE)
                    {
                        StatusBars.Text = "First image is captured";
                    }
                    else
                    {
                        DisplayError("CreateTemplate()", iError);
                    }
                }
                else
                {
                    DisplayError("GetImage()", iError);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        public FingerPrintInfo Capture(int fingerPosition, out string err, bool populateImagebytes = false)
        {
            InitializeDevice();
            err = "";

            var fp_image = new Byte[m_ImageWidth * m_ImageHeight];
            var m_fingerprinttemplate = new Byte[max_template_size];

            var error    = (int)SGFPMError.ERROR_NONE;
            var img_qlty = 0;

            if (m_DeviceOpened)
            {
                error = m_FPM.GetImage(fp_image);
            }

            if (error == (int)SGFPMError.ERROR_NONE)
            {
                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);


                var finger_info = new SGFPMFingerInfo
                {
                    FingerNumber   = (SGFPMFingerPosition)fingerPosition,
                    ImageQuality   = (short)img_qlty,
                    ImpressionType = (short)SGFPMImpressionType.IMPTYPE_LP,
                    ViewNumber     = 1
                };

                // CreateTemplate
                error = m_FPM.CreateTemplate(finger_info, fp_image, m_fingerprinttemplate);

                if (error == (int)SGFPMError.ERROR_NONE)
                {
                    return(new FingerPrintInfo
                    {
                        Manufacturer = "",
                        Model = "",
                        SerialNumber = "",
                        ImageWidth = m_ImageWidth,
                        ImageHeight = m_ImageHeight,
                        ImageDPI = m_Dpi,
                        ImageQuality = img_qlty,
                        Image = ToBase64String(fp_image, ImageFormat.Bmp),
                        ImageByte = populateImagebytes ? fp_image : null,
                        Template = Convert.ToBase64String(m_fingerprinttemplate),
                        FingerPositions = (FingerPositions)fingerPosition
                    });
                }
            }
            err = DisplayError(error);
            return(null);
        }
コード例 #5
0
        public FingerPrintInfo Capture(int fingerPosition, out string err, bool populateImagebytes = false)
        {
            InitializeDevice();
            err = "";

            Byte[] fp_image = new Byte[m_ImageWidth * m_ImageHeight];
            Byte[] m_fingerprinttemplate = new Byte[max_template_size];

            Int32 error    = (Int32)SGFPMError.ERROR_NONE;
            Int32 img_qlty = 0;

            if (m_DeviceOpened)
            {
                error = m_FPM.GetImage(fp_image);
            }

            if (error == (Int32)SGFPMError.ERROR_NONE)
            {
                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);


                SGFPMFingerInfo finger_info = new SGFPMFingerInfo();
                finger_info.FingerNumber   = (SGFPMFingerPosition)fingerPosition;
                finger_info.ImageQuality   = (Int16)img_qlty;
                finger_info.ImpressionType = (Int16)SGFPMImpressionType.IMPTYPE_LP;
                finger_info.ViewNumber     = 1;

                // CreateTemplate
                error = m_FPM.CreateTemplate(finger_info, fp_image, m_fingerprinttemplate);

                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    return(new FingerPrintInfo
                    {
                        Manufacturer = "",
                        Model = "",
                        SerialNumber = "",
                        ImageWidth = m_ImageWidth,
                        ImageHeight = m_ImageHeight,
                        ImageDPI = m_Dpi,
                        ImageQuality = img_qlty,
                        Image = ToBase64String(fp_image, ImageFormat.Bmp),
                        ImageByte = populateImagebytes ? fp_image : null,
                        Template = Convert.ToBase64String(m_fingerprinttemplate),
                        FingerPositions = (FingerPositions)fingerPosition
                    });
                }
            }
            err = "Error : " + ((SGFPMError)error).ToString();
            return(null);
            // throw new ApplicationException("Error : " + ((SGFPMError)error).ToString());
        }
コード例 #6
0
ファイル: AccountForm.cs プロジェクト: theZetrax/LeafSecurity
        // Fingerprint Methods
        private void captureFingerprint()
        {
            // Getting fp image as byte[]
            byte[] fp_image_byte = new Byte[img_w * img_h];
            iError = m_FPM.GetImage(fp_image_byte);

            if (iError == (Int32)SGFPMError.ERROR_NONE)
            {
                DrawFingerprint(fp_image_byte, FingerprintPreviewBox);
            }

            generateHashString();
        }
コード例 #7
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            Status.Text = "";
            Int32 iError;

            Byte[] fp_image;
            Int32  img_qlty;

            fp_image = new Byte[_mImageWidth * _mImageHeight];
            img_qlty = 0;

            iError = _mFpm.GetImage(fp_image);

            _mFpm.GetImageQuality(_mImageWidth, _mImageHeight, fp_image, ref img_qlty);

            if (iError == (int)SGFPMError.ERROR_NONE)
            {
                DrawImage(fp_image, pictureBox1);
                iError = _mFpm.CreateTemplate(fp_image, _mRegMin1);
                if (iError == (int)SGFPMError.ERROR_NONE)
                {
                    var voters = Verify(_mRegMin1, _mRegMin1, _mRegMin1);
                    if (voters.VoterPin != null)
                    {
                        lblName.Text         = voters.Firstname + @" " + voters.Lastname;
                        lblVoterPin.Text     = voters.VoterPin;
                        picImage.Image       = voters.VoterImg;
                        radioButton4.Checked = false;
                        radioButton3.Checked = false;
                        radioButton2.Checked = false;
                        radioButton1.Checked = false;
                        btnCastVote.Enabled  = false;
                        metroPanel3.Visible  = true;
                    }
                    else
                    {
                        MetroMessageBox.Show(this, @"Your record not found in the database", @"eVoting System",
                                             MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
                else
                {
                    Status.Text = _error.DisplayError("CreateTemplate()", iError);
                }
            }
            else
            {
                Status.Text = _error.DisplayError("CreateTemplate()", iError);
            }
        }
コード例 #8
0
 protected override void WndProc(ref Message message)
 {
     if (message.Msg == (int)SGFPMMessages.DEV_AUTOONEVENT)
     {
         if (message.WParam.ToInt32() == (Int32)SGFPMAutoOnEvent.FINGER_ON)
         {
             image = new Byte[width * height];
             fpm.GetImage(image);
             Byte[] scan = new Byte[400];
             fpm.CreateTemplate(image, scan);
             String matchFound = FindMatch(scan);
             if (matchFound.Length == 0)
             {
                 File.WriteAllBytes("./" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".tmp", scan);
                 MessageBox.Show("No match found, saving...");
             }
             else
             {
                 MessageBox.Show(matchFound);
             }
         }
     }
     base.WndProc(ref message);
 }
        private void btnCaptureR1_Click(object sender, EventArgs e)
        {
            Int32 iError;

            Byte[] fpImage;
            Int32  imgQlty;

            _mRegMin1 = new Byte[400];
            fpImage   = new Byte[_mImageWidth * _mImageHeight];
            imgQlty   = 0;


            iError = _mFpm.GetImage(fpImage);

            _mFpm.GetImageQuality(_mImageWidth, _mImageHeight, fpImage, ref imgQlty);
            pgbR1.Value = imgQlty;

            if (iError == (Int32)SGFPMError.ERROR_NONE)
            {
                DrawImage(fpImage, imgR1);
                iError = _mFpm.CreateTemplate(fpImage, _mRegMin1);

                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    statusBar.Text = @"First image is captured";
                }
                else
                {
                    statusBar.Text = _error.DisplayError("CreateTemplate()", iError);
                }
            }
            else
            {
                statusBar.Text = _error.DisplayError("GetImage()", iError);
            }
        }
コード例 #10
0
        private void button3_Click(object sender, EventArgs e)
        {
            fp_image = new Byte[m_ImageWidth * m_ImageHeight];
            Int32 error    = (Int32)SGFPMError.ERROR_NONE;
            Int32 img_qlty = 0;

            if (m_DeviceOpened)
            {
                error = m_FPM.GetImage(fp_image);
            }
            else
            {
                error = GetImageFromFile(fp_image);
            }

            if (error == (Int32)SGFPMError.ERROR_NONE)
            {
                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
                progressBar1.Value = img_qlty;

                DrawImage(fp_image, pictureBox1);

                SGFPMFingerInfo finger_info = new SGFPMFingerInfo();
                finger_info.FingerNumber   = (SGFPMFingerPosition)1;
                finger_info.ImageQuality   = (Int16)img_qlty;
                finger_info.ImpressionType = (Int16)SGFPMImpressionType.IMPTYPE_LP;
                finger_info.ViewNumber     = 1;

                // CreateTemplate
                error = m_FPM.CreateTemplate(finger_info, fp_image, m_RegMin1);

                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    label1.Text = "First image is captured";
                }
                else
                {
                    label1.Text = "GetMinutiae() Error : " + error;
                }
            }
            else
            {
                label1.Text = "GetImage() Error : " + error;
            }
        }
コード例 #11
0
        private Task <bool> Prepare(byte[] m_RegMin)
        {
            return(Task.Run <bool>(() =>
            {
                var fp_image = new Byte[m_ImageWidth * m_ImageHeight];

                var iError = m_FPM.GetImage(fp_image);

                iError = m_FPM.GetImageEx(fp_image, timeout: 10000, dispWnd: 0, quality: 50);

                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    iError = m_FPM.CreateTemplate(fp_image, m_RegMin);

                    if (iError == (Int32)SGFPMError.ERROR_NONE)
                    {
                        return true;
                    }
                }
                return false;
            }));
        }
コード例 #12
0
 protected override void WndProc(ref Message message)
 {
     if (message.Msg == (int)SGFPMMessages.DEV_AUTOONEVENT)
     {
         if (message.WParam.ToInt32() == (Int32)SGFPMAutoOnEvent.FINGER_ON)
         {
             image = new Byte[width * height];
             fpm.GetImage(image);
             Byte[] scan = new Byte[400];
             fpm.CreateTemplate(image, scan);
             Int32 matchFound = FindMatch(scan);
             if (matchFound == 0)
             {
                 NoMatch();
             }
             else
             {
                 Clock(matchFound);
             }
         }
     }
     base.WndProc(ref message);
 }
コード例 #13
0
        private void button3_Click(object sender, EventArgs e)
        {
            SqlDataAdapter da = new SqlDataAdapter("Select UserID,Name,Image,Template from Voter", con);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            if (ds.Tables[0].Rows.Count <= 0)
            {
                con.Close();
                MessageBox.Show("No Data Present", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Int32  iError;
                Byte[] fp_image;
                Int32  img_qlty;
                string id = "";

                fp_image = new Byte[m_ImageWidth * m_ImageHeight];
                img_qlty = 0;

                iError = m_FPM.GetImage(fp_image);

                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);


                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    DrawImage(fp_image, pictureBox3);
                    iError = m_FPM.CreateTemplate(fp_image, m_RegMin1);

                    if (iError == (Int32)SGFPMError.ERROR_NONE)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            fp_image = (byte[])(ds.Tables[0].Rows[i][3]);

                            iError = m_FPM.CreateTemplate(fp_image, m_VrfMin);

                            MemoryStream       ms       = new MemoryStream();
                            bool               matched1 = false;
                            SGFPMSecurityLevel secu_level;

                            secu_level = (SGFPMSecurityLevel)5;

                            iError = m_FPM.MatchTemplate(m_RegMin1, m_VrfMin, secu_level, ref matched1);

                            if (iError == (Int32)SGFPMError.ERROR_NONE)
                            {
                                if (matched1)
                                {
                                    id = ds.Tables[0].Rows[i][0].ToString();
                                }
                            }
                            else
                            {
                                DisplayError("MatchTemplate()", iError);
                            }
                        }
                    }
                }
                if (id != "")
                {
                    SqlCommand cmd = new SqlCommand("Select Name,Image from Voter where UserId='" + id + "'", con);
                    con.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    dr.Read();
                    textBox1.Text             = id;
                    textBox2.Text             = dr[0].ToString();
                    pictureBox2.ImageLocation = dr[1].ToString();
                    con.Close();
                    panel4.Enabled    = false;
                    groupBox1.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Sorry No Match Found Please Re-Scan the Finger", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }



            /*
             * if (textBox1.Text != "")
             * {
             *  SqlCommand cmd = new SqlCommand("Select Name,Image,Template from Voter where UserId='" + textBox1.Text + "'", con);
             *  con.Open();
             *  SqlDataReader dr = cmd.ExecuteReader();
             *  if (!dr.HasRows)
             *  {
             *      con.Close();
             *      MessageBox.Show("invalid User ID", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  }
             *  else
             *  {
             *      dr.Read();
             *      textBox2.Text = dr[0].ToString();
             *      con.Close();
             *      Int32 iError;
             *      Byte[] fp_image;
             *      Int32 img_qlty;
             *
             *      fp_image = new Byte[m_ImageWidth * m_ImageHeight];
             *      img_qlty = 0;
             *
             *      iError = m_FPM.GetImage(fp_image);
             *
             *      m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
             *
             *
             *      if (iError == (Int32)SGFPMError.ERROR_NONE)
             *      {
             *          DrawImage(fp_image, pictureBox3);
             *          iError = m_FPM.CreateTemplate(fp_image, m_RegMin1);
             *
             *          if (iError == (Int32)SGFPMError.ERROR_NONE)
             *          {
             *              cmd = new SqlCommand("Select Image,Template from Voter where UserId='" + textBox1.Text + "'", con);
             *              con.Open();
             *              dr = cmd.ExecuteReader();
             *              if (dr.HasRows)
             *              {
             *                  dr.Read();
             *                  string s = dr[0].ToString();
             *
             *                  fp_image = (byte[])(dr[1]);
             *
             *                  iError = m_FPM.CreateTemplate(fp_image, m_VrfMin);
             *
             *                  pictureBox2.ImageLocation = s;
             *                  con.Close();
             *
             *
             *                  MemoryStream ms = new MemoryStream();
             *                  //pictureBox4.Image.Save(ms, pictureBox4.Image.RawFormat);
             *                  //ms.Position = 0;
             *                  //byte[] m_VrfMin = ms.ToArray();
             *
             *                  bool matched1 = false;
             *                  SGFPMSecurityLevel secu_level;
             *
             *                  secu_level = (SGFPMSecurityLevel)5;
             *
             *                  iError = m_FPM.MatchTemplate(m_RegMin1, m_VrfMin, secu_level, ref matched1);
             *
             *                  if (iError == (Int32)SGFPMError.ERROR_NONE)
             *                  {
             *                      if (matched1)
             *                      {
             *                          panel4.Enabled = false;
             *                          groupBox1.Enabled = true;
             *                      }
             *                      else
             *                      {
             *                          MessageBox.Show("Login Failed", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *                      }
             *                  }
             *                  else
             *                      DisplayError("MatchTemplate()", iError);
             *              }
             *              else
             *              {
             *                  con.Close();
             *                  MessageBox.Show("Invalid UserId", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *              }
             *          }
             *          else
             *              DisplayError("CreateTemplate()", iError);
             *      }
             *      else
             *      {
             *          MessageBox.Show("Finger Capturing Failed", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *      }
             *  }
             * }
             * else
             * {
             *  MessageBox.Show("Please Enter User ID/Pin", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             * }
             */
        }
コード例 #14
0
        private void button2_Click(object sender, EventArgs e)
        {
            SqlDataAdapter da = new SqlDataAdapter("Select Name,Bal,Temp,BankAC,BankName,Pin from Reg where BankName = '" + comboBox1.Text + "' AND Pin = '" + textBox6.Text + "'", con);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            if (ds.Tables[0].Rows.Count <= 0)
            {
                con.Close();
                MessageBox.Show("No Data Present", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Int32  iError;
                Byte[] fp_image;
                Int32  img_qlty;

                fp_image = new Byte[m_ImageWidth * m_ImageHeight];
                img_qlty = 0;

                iError = m_FPM.GetImage(fp_image);

                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);


                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    DrawImage(fp_image, pictureBox1);
                    iError = m_FPM.CreateTemplate(fp_image, m_RegMin1);

                    if (iError == (Int32)SGFPMError.ERROR_NONE)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            fp_image = (byte[])(ds.Tables[0].Rows[i][2]);

                            iError = m_FPM.CreateTemplate(fp_image, m_VrfMin);

                            MemoryStream       ms       = new MemoryStream();
                            bool               matched1 = false;
                            SGFPMSecurityLevel secu_level;

                            secu_level = (SGFPMSecurityLevel)5;

                            iError = m_FPM.MatchTemplate(m_RegMin1, m_VrfMin, secu_level, ref matched1);

                            if (iError == (Int32)SGFPMError.ERROR_NONE)
                            {
                                if (matched1)
                                {
                                    Name1    = ds.Tables[0].Rows[i][0].ToString();
                                    Bal      = ds.Tables[0].Rows[i][1].ToString();
                                    BankAC   = ds.Tables[0].Rows[i][3].ToString();
                                    BankName = ds.Tables[0].Rows[i][4].ToString();
                                    Pin      = ds.Tables[0].Rows[i][5].ToString();
                                }
                            }
                            else
                            {
                                DisplayError("MatchTemplate()", iError);
                            }
                        }
                    }
                }
                if (Name1 != "")
                {
                    comboBox1.Enabled = false;
                    textBox6.Enabled  = false;
                    button2.Enabled   = false;
                    panel1.Visible    = true;
                }
                else
                {
                    comboBox1.Enabled = true;
                    textBox6.Enabled  = true;
                    button2.Enabled   = true;
                    panel1.Visible    = false;
                    MessageBox.Show("Sorry No Match Found Please Re-Scan the Finger", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            Byte[] fp_image = new Byte[m_ImageWidth * m_ImageHeight];
            Int32  error    = (Int32)SGFPMError.ERROR_NONE;
            Int32  img_qlty = 0;
            Int32  info;


            if (m_DeviceOpened)
            {
                error = m_FPM.GetImage(fp_image);
            }


            if (error == (Int32)SGFPMError.ERROR_NONE)
            {
                m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
                progressBar1.Value = img_qlty;

                DrawImage(fp_image, pictureBox1);

                SGFPMFingerInfo finger_info = new SGFPMFingerInfo();
                //   finger_info.FingerNumber = (SGFPMFingerPosition)comboBoxSelFinger.SelectedIndex;
                finger_info.ImageQuality   = (Int16)img_qlty;
                finger_info.ImpressionType = (Int16)SGFPMImpressionType.IMPTYPE_LP;
                finger_info.ViewNumber     = 1;

                // CreateTemplate
                info = m_FPM.CreateTemplate(finger_info, fp_image, m_RegMin1);

                Image myImage = pictureBox1.Image;

                using (MemoryStream ms = new MemoryStream())
                {
                    myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                    data = ms.ToArray();
                }
                try
                {
                    string sql = string.Empty;
                    string con = string.Empty;
                    //  byte[] id1 = (byte[])(m_RegMin2);

                    con = "Server=127.0.0.1; port=3306; Uid=root; Database=students; Password="******"SELECT f_id,f_id2,RegistrationNumber,Fullnames,YearOfStudy,PhoneNumber,Course, Photo,Department, fingerprint FROM users";
                    using (MySqlConnection sqlcon = new MySqlConnection(con))
                    {
                        sqlcon.Open();
                        string[] sub_Item = new string[7];
                        using (MySqlCommand com = new MySqlCommand(sql, sqlcon))
                        {
                            using (MySqlDataReader read = com.ExecuteReader())
                            {
                                if (read.HasRows)
                                {
                                    while (read.Read())
                                    {
                                        byte[] f_id = (byte[])(read["fingerprint"]);
                                        byte[] id   = (byte[])(read["f_id"]);

                                        byte[] id2 = (byte[])(read["f_id2"]);


                                        bool  matched = false;
                                        Int32 err     = 0;
                                        err = m_FPM.MatchTemplate(id, m_RegMin1, m_SecurityLevel, ref matched);
                                        if (matched)
                                        {
                                            sub_Item[0] = read["RegistrationNumber"].ToString();
                                            sub_Item[1] = read["Fullnames"].ToString();
                                            sub_Item[2] = read["YearOfStudy"].ToString();
                                            sub_Item[3] = read["PhoneNumber"].ToString();
                                            sub_Item[4] = read["Course"].ToString();
                                            sub_Item[5] = read["Department"].ToString();
                                            byte[] img = (byte[])(read["Photo"]);

                                            MemoryStream ms = new MemoryStream(img);
                                            pictureBox2.Image = new Bitmap(ms);
                                            pictureBox2.Image = Image.FromStream(ms);

                                            MemoryStream ms1 = new MemoryStream(img);
                                            pictureBox2.Image = Image.FromStream(ms1);
                                            // photo.Image
                                            ms.Dispose();

                                            //populate the text boxes
                                            textBox1.Text = sub_Item[0];
                                            textBox2.Text = sub_Item[1];
                                            textBox3.Text = sub_Item[4];
                                            textBox4.Text = sub_Item[2];
                                            listUnits();
                                        }
                                        else
                                        {
                                            bool  matched1 = false;
                                            Int32 err2     = 0;
                                            err2 = m_FPM.MatchTemplate(id2, m_RegMin1, m_SecurityLevel, ref matched1);
                                            if (matched1)
                                            {
                                                sub_Item[0] = read["RegistrationNumber"].ToString();
                                                sub_Item[1] = read["Fullnames"].ToString();
                                                sub_Item[2] = read["YearOfStudy"].ToString();
                                                sub_Item[3] = read["PhoneNumber"].ToString();
                                                sub_Item[4] = read["Course"].ToString();
                                                sub_Item[5] = read["Department"].ToString();
                                                byte[] img = (byte[])(read["Photo"]);

                                                MemoryStream ms = new MemoryStream(img);
                                                pictureBox2.Image = new Bitmap(ms);
                                                pictureBox2.Image = Image.FromStream(ms);

                                                MemoryStream ms1 = new MemoryStream(img);
                                                pictureBox2.Image = Image.FromStream(ms1);
                                                // photo.Image
                                                ms.Dispose();

                                                //populate the text boxes
                                                textBox1.Text = sub_Item[0];
                                                textBox2.Text = sub_Item[1];
                                                textBox3.Text = sub_Item[4];
                                                textBox4.Text = sub_Item[2];
                                                listUnits();
                                            }
                                            else
                                            {
                                                // textBox5.Text = "No fingerprint match found";
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("No data found");
                                }
                            }
                        }
                        sqlcon.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    textBox5.Text = "Fingerprint Image  captured";
                }
                else
                {
                    textBox5.Text = "GetMinutiae() Error : " + error;
                }
            }
            else
            {
                textBox5.Text = "GetImage() Error : " + error;
            }
        }