public void ConvertTemplate(FingerprintTemplate tpt, [Out] FingerprintTemplate newTpt, int context, GrTemplateFormat format)
 {
     IntPtr zero = IntPtr.Zero;
     IntPtr ptr2 = IntPtr.Zero;
     try
     {
         zero = Marshal.AllocHGlobal(tpt.Size);
         Marshal.Copy(tpt.Buffer, 0, zero, tpt.Size);
         ptr2 = Marshal.AllocHGlobal(0x2710);
         int newTptSize = 0x2710;
         this.ConvertTemplate(zero, ptr2, ref newTptSize, context, (int) format);
         ptr2 = Marshal.ReAllocHGlobal(ptr2, (IntPtr) newTptSize);
         newTpt = new FingerprintTemplate(ptr2, newTptSize);
     }
     catch (OutOfMemoryException exception)
     {
         throw new FingerprintException(-7, exception);
     }
     catch (NullReferenceException exception2)
     {
         throw new FingerprintException(-5, exception2);
     }
     catch (ArgumentException exception3)
     {
         throw new FingerprintException(-5, exception3);
     }
     finally
     {
         Marshal.FreeHGlobal(zero);
         Marshal.FreeHGlobal(ptr2);
     }
 }
 private void clearFields()
 {
     this.voterSurname.Text    = "";
     this.voterName.Text       = "";
     this.voterMiddleName.Text = "";
     this.voterPassword.Text   = "";
     this.voterRPassword.Text  = "";
     this.voterRegNo.Text      = "";
     this.voterPhoneNo.Text    = "";
     this.voterDept.Text       = "";
     template      = null;
     imageByte     = null;
     voterSex.Text = "";
     this.voterPictureBox.Image   = null;
     this.pictureBox1.Image       = null;
     this.FPquality.Text          = "";
     this.voterDept.SelectedIndex = -1;
     this.voterSex.SelectedIndex  = -1;
 }
        private void DisplayImage(GriauleFingerprintLibrary.DataTypes.FingerprintTemplate template, bool identify)
        {
            IntPtr hdc = FingerprintCore.GetDC();

            IntPtr image = new IntPtr();

            if (identify)
            {
                refFingercore.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_DEFAULT_CONTEXT);
            }
            else
            {
                refFingercore.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_NO_CONTEXT);
            }


            SetImage(Bitmap.FromHbitmap(image));

            FingerprintCore.ReleaseDC(hdc);
        }
Beispiel #4
0
 protected override void InternalSaveTemplate(byte fingerCode, GriauleFingerprintLibrary.DataTypes.FingerprintTemplate fingerPrintTemplate)
 {
     base.InternalSaveTemplate(fingerCode, fingerPrintTemplate);
     using (SqlCeCommand cmd = new SqlCeCommand())
     {
         try
         {
             cmd.Connection = (SqlCeConnection)Connection;
             string cmdStr = String.Format("SELECT COUNT(*) n FROM [{0}] WHERE [{1}]=@individual AND [{2}]=@finger",
                                           TemplateTable, IndividualFieldName, FingerFieldName);
             cmd.CommandText = cmdStr;
             cmd.Parameters.AddWithValue("@individual", ActiveIndividual);
             cmd.Parameters.AddWithValue("@finger", fingerCode);
             int cnt = (int)cmd.ExecuteScalar();
             if (cnt > 0) //Finger template already exists, update
             {
                 cmdStr = String.Format("UPDATE [{0}] SET [{1}]=@template, SET [{2}]=@quality WHERE [{3}]=@individual AND [{4}]=@finger",
                                        TemplateTable, TemplateFieldName, QualityFieldName, IndividualFieldName, FingerFieldName);
             }
             else //Finger template doesn't exist, insert
             {
                 cmdStr = String.Format("INSERT INTO [{0}] ([{1}],[{2}],[{3}],[{4}]) VALUES (@individual,@finger,@template,@quality)",
                                        TemplateTable, IndividualFieldName, FingerFieldName, TemplateFieldName, QualityFieldName);
             }
             cmd.CommandText = cmdStr;
             //cmd.Parameters.AddWithValue("@individual", ActiveIndividual); //Already set
             //cmd.Parameters.AddWithValue("@finger", fingerCode);           //Already set
             cmd.Parameters.AddWithValue("@template", fingerPrintTemplate.Buffer);
             cmd.Parameters.AddWithValue("@quality", fingerPrintTemplate.Quality);
             int rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new FPLibraryException(FPLibraryException.LibraryDalError, String.Format("Template not saved for individual {0} finger {1}", ActiveIndividual, fingerCode));
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
 public void ConvertTemplate(FingerprintTemplate tpt, [Out] FingerprintTemplate newTpt, GrTemplateFormat format)
 {
     this.ConvertTemplate(tpt, newTpt, 0, format);
 }
 public void IdentifyPrepare(FingerprintTemplate queryTemplate)
 {
     this.IdentifyPrepare(queryTemplate, 0);
 }
 public void IdentifyPrepare(FingerprintTemplate queryTemplate, int context)
 {
     IntPtr zero = IntPtr.Zero;
     try
     {
         zero = Marshal.AllocHGlobal(queryTemplate.Size);
         Marshal.Copy(queryTemplate.Buffer, 0, zero, queryTemplate.Size);
         this.IdentifyPrepare(zero, context);
     }
     catch (OutOfMemoryException exception)
     {
         throw new FingerprintException(-7, exception);
     }
     catch (ArgumentException exception2)
     {
         throw new FingerprintException(-5, exception2);
     }
     finally
     {
         Marshal.FreeHGlobal(zero);
     }
 }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] dataTemp;
            GriauleFingerprintLibrary.DataTypes.FingerprintTemplate templateTemp;

            int precision;

            try
            {
                string myConnection = "Data Source=.\\sqlexpress;Initial Catalog=testdb;Integrated Security=True";
                string querry       = "SELECT * FROM voters WHERE 1=1 AND regno = '" + this.voterRegNo_txt.Text + "' AND password='******'";
                SqlConnection myConn = new SqlConnection(myConnection);

                SqlCommand    cmd = new SqlCommand(querry, myConn);
                SqlDataReader dbr;
                if (template != null)
                {
                    core.IdentifyPrepare(template);
                }

                myConn.Open();
                dbr = cmd.ExecuteReader();

                if (voterRegNo_txt.Text == string.Empty & voterPass_txt.Text == string.Empty & template == null)
                {
                    MessageBox.Show("Enter your Reg. No and Password,\nThen Place Your Finger on the Sensor", "Invalid Login");
                    return;
                }
                else
                {
                    if ((voterRegNo_txt.Text == string.Empty))
                    {
                        MessageBox.Show("Enter your Reg. No");
                    }
                    else
                    {
                        if ((voterPass_txt.Text == string.Empty))
                        {
                            MessageBox.Show("Enter Your Password");
                        }
                        else
                        {
                            if ((template == null))
                            {
                                MessageBox.Show("Place Your Finger on the Fingerprint Device");
                            }
                            else
                            {
                                while (dbr.Read())
                                {
                                    dataTemp            = (byte[])dbr["fingerprint"];
                                    templateTemp        = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate();
                                    templateTemp.Buffer = dataTemp;
                                    templateTemp.Size   = dataTemp.Length;

                                    id       = dbr.GetInt32(0);
                                    regno    = dbr.GetString(7);
                                    password = dbr.GetString(8);

                                    if ((core.Identify(templateTemp, out precision)) == 1)
                                    {
                                        this.Hide();
                                        voterInterface voterInterface = new voterInterface();
                                        voterInterface.ShowDialog();
                                        return;
                                    }
                                }

                                if (voterRegNo_txt.Text == regno && voterPass_txt.Text == password)
                                {
                                    MessageBox.Show("The FingerPrint Does not Match that of: " + this.voterRegNo_txt.Text +
                                                    "\nPlease Try Again.", "Failed to Verify");
                                }
                                else
                                {
                                    MessageBox.Show("Invalid Details Entered!");
                                }
                                this.voterRegNo_txt.Text    = null;
                                this.voterPass_txt.Text     = null;
                                mainLoginPgFPImageBox.Image = null;
                                template     = null;
                                templateTemp = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #9
0
 protected virtual void ReadTemplate(IDataReader rdr, out Fingers finger, out FingerprintTemplate template)
 {
     byte[] buff = (byte[])rdr[TemplateFieldName];
       int quality = Convert.ToInt16(rdr[QualityFieldName]);
       template = new FingerprintTemplate { Size = buff.Length, Buffer = buff, Quality = quality };
       Byte fingerCode = Convert.ToByte(rdr[FingerFieldName]);
       finger = MatchFingerCode(fingerCode);
 }
 public int Verify(FingerprintTemplate queryTemplate, FingerprintTemplate referenceTemplate, out int verifyScore, int context)
 {
     int num;
     IntPtr zero = IntPtr.Zero;
     IntPtr destination = IntPtr.Zero;
     try
     {
         zero = Marshal.AllocHGlobal(queryTemplate.Size);
         Marshal.Copy(queryTemplate.Buffer, 0, zero, queryTemplate.Size);
         destination = Marshal.AllocHGlobal(referenceTemplate.Size);
         Marshal.Copy(referenceTemplate.Buffer, 0, destination, referenceTemplate.Size);
         num = this.Verify(zero, destination, out verifyScore, context);
     }
     catch (OutOfMemoryException exception)
     {
         throw new FingerprintException(-7, exception);
     }
     catch (NullReferenceException exception2)
     {
         throw new FingerprintException(-5, exception2);
     }
     catch (ArgumentException exception3)
     {
         throw new FingerprintException(-5, exception3);
     }
     finally
     {
         Marshal.FreeHGlobal(zero);
         Marshal.FreeHGlobal(destination);
     }
     return num;
 }
 void FPCore_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
 {
     try
       {
     if (ie.RawImage != null)
     {
       SetImage(ie.RawImage.Image);
       template = new FingerprintTemplate();
       int ret = (int)FPCore.Enroll(ie.RawImage, ref template, (GrTemplateFormat)Controller.DefaultTemplateFormat, FingerprintConstants.GR_DEFAULT_CONTEXT);
       if (ret >= FingerprintConstants.GR_ENROLL_SUFFICIENT)
       {
     DisplayImage(template, ie.RawImage);
     EnableCaptureButton(true);
     if (ret == FingerprintConstants.GR_ENROLL_SUFFICIENT)
     {
       ShowQuality(EnrollQuality.Sufficient);
       SetFingerLabel("Place finger again to improve quality", true);
     }
     else if (ret == FingerprintConstants.GR_ENROLL_GOOD)
     {
       ShowQuality(EnrollQuality.Good);
       SetFingerLabel("Click 'Capture' to record template", true);
     }
     else if (ret == FingerprintConstants.GR_ENROLL_VERY_GOOD)
     {
       ShowQuality(EnrollQuality.VeryGood);
       SetFingerLabel("Click 'Capture' to record template", true);
     }
     else if (ret == FingerprintConstants.GR_ENROLL_MAX_LIMIT_REACHED)
     {
       SetFingerLabel("Enrollment limit reached", true);
     }
       }
       else
       {
     SetFingerLabel("Place finger again", true);
     ShowQuality(EnrollQuality.Poor);
       }
       Thread.Sleep(100);
     }
       }
       catch (FingerprintException ex)
       {
     ShowFPError(ex);
       }
       catch (Exception e)
       {
     ShowError(e);
       }
 }
 public void ExtractEx(FingerprintRawImage fingerPrintRawImage, ref FingerprintTemplate fingerTemplate, GrTemplateFormat tptFormat)
 {
     this.ExtractEx(fingerPrintRawImage, ref fingerTemplate, 0, tptFormat);
 }
 public void ExtractEx(FingerprintRawImage fingerPrintRawImage, ref FingerprintTemplate fingerTemplate, int context, GrTemplateFormat tptFormat)
 {
     try
     {
         IntPtr destination = Marshal.AllocCoTaskMem(fingerPrintRawImage.Width * fingerPrintRawImage.Height);
         Marshal.Copy(fingerPrintRawImage.RawImage, 0, destination, fingerPrintRawImage.Width * fingerPrintRawImage.Height);
         this.ExtractEx(destination, fingerPrintRawImage.Width, fingerPrintRawImage.Height, fingerPrintRawImage.Resolution, ref fingerTemplate, context, (int) tptFormat);
         Marshal.FreeCoTaskMem(destination);
     }
     catch (OutOfMemoryException exception)
     {
         FingerprintException exception2 = new FingerprintException(-7, exception);
         throw exception2;
     }
 }
 public GrEnrollState Enroll(FingerprintRawImage rawImage, ref FingerprintTemplate tpt, GrTemplateFormat tptFormat, int context)
 {
     GrEnrollState state;
     IntPtr zero = IntPtr.Zero;
     try
     {
         int num = 0;
         int quality = -1;
         int cb = 0x2710 * Marshal.SizeOf(typeof(byte));
         zero = Marshal.AllocHGlobal(cb);
         IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height);
         Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height);
         num = this.Enroll(destination, rawImage.Width, rawImage.Height, rawImage.Resolution, zero, ref cb, ref quality, (int) tptFormat, context);
         Marshal.FreeCoTaskMem(destination);
         zero = Marshal.ReAllocHGlobal(zero, (IntPtr) cb);
         tpt = new FingerprintTemplate(zero, cb, quality);
         state = (GrEnrollState) num;
     }
     catch (OutOfMemoryException exception)
     {
         throw new FingerprintException(-7, exception);
     }
     catch (AccessViolationException exception2)
     {
         throw new FingerprintException(-113, exception2);
     }
     finally
     {
         Marshal.FreeHGlobal(zero);
     }
     return state;
 }
 public void Extract(FingerprintRawImage fingerPrintRawImage, ref FingerprintTemplate fingerTemplate)
 {
     this.Extract(fingerPrintRawImage, ref fingerTemplate, 0);
 }
 public GrEnrollState Enroll(FingerprintRawImage rawImage, ref FingerprintTemplate tpt, GrTemplateFormat tptFormat)
 {
     return this.Enroll(rawImage, ref tpt, tptFormat, 0);
 }
 public static FingerprintTemplate EncodeBase64(FingerprintTemplate referenceTemplate)
 {
     FingerprintTemplate template;
     IntPtr zero = IntPtr.Zero;
     IntPtr encodedBuffer = IntPtr.Zero;
     try
     {
         zero = Marshal.AllocHGlobal(referenceTemplate.Size);
         Marshal.Copy(referenceTemplate.Buffer, 0, zero, referenceTemplate.Size);
         int encodedSize = 0x2710;
         encodedBuffer = Marshal.AllocHGlobal(0x2710);
         EncodeBase64(zero, referenceTemplate.Size, ref encodedBuffer, ref encodedSize);
         template = new FingerprintTemplate(encodedBuffer, encodedSize);
     }
     catch (OutOfMemoryException exception)
     {
         throw new FingerprintException(-7, exception);
     }
     finally
     {
         Marshal.FreeHGlobal(zero);
         Marshal.FreeHGlobal(encodedBuffer);
     }
     return template;
 }
Beispiel #18
0
 /// <summary>
 /// Save a fingerprint template for the current individual
 /// </summary>
 /// <param name="finger">The finger to which the template belongs</param>
 /// <param name="fingerPrintTemplate">The template to be saved</param>
 public void SaveTemplate(Fingers finger, FingerprintTemplate fingerPrintTemplate)
 {
     if (Connection != null && Connection.State == ConnectionState.Open)
     if (ActiveIndividual != null)
       InternalSaveTemplate(FingerValueTable[finger], fingerPrintTemplate);
     else throw new FPLibraryException(FPLibraryException.LibraryDalError, "Active individual not set");
       else
     throw new FPLibraryException(FPLibraryException.LibraryDalError, "Connection is null or closed");
 }
Beispiel #19
0
 private bool CompareTemplate(int context, FingerprintTemplate template)
 {
     int verifyScore;
       return griauleLibrary.Identify(template, out verifyScore, context) == FingerprintConstants.GR_MATCH;
 }
 private void ExtractEx([In] IntPtr rawimage, int width, int height, int res, ref FingerprintTemplate fingerTemplate, int context, int tptFormat)
 {
     IntPtr zero = IntPtr.Zero;
     try
     {
         int cb = 0x2710 * Marshal.SizeOf(typeof(byte));
         zero = Marshal.AllocHGlobal(cb);
         int quality = FingerprintException.CheckError(GrFingerprintProxy.GrExtractEx(rawimage, width, height, res, zero, ref cb, context, tptFormat));
         zero = Marshal.ReAllocHGlobal(zero, (IntPtr) cb);
         fingerTemplate = new FingerprintTemplate(zero, cb, quality);
     }
     catch (OutOfMemoryException exception)
     {
         throw new FingerprintException(-7, exception);
     }
     finally
     {
         Marshal.FreeHGlobal(zero);
     }
 }
 public int Verify(FingerprintTemplate queryTemplate, FingerprintTemplate referenceTemplate, out int verifyScore)
 {
     return this.Verify(queryTemplate, referenceTemplate, out verifyScore, 0);
 }
Beispiel #22
0
 /// <summary>
 /// Extract a fingerprint template from a raw fingerprint image
 /// </summary>
 /// <param name="image">The image to extract the template from</param>
 /// <returns></returns>
 public FingerprintTemplate ExtractTemplate(FingerprintRawImage image)
 {
     var template = new FingerprintTemplate();
       griauleLibrary.ExtractEx(image, ref template, (GrTemplateFormat)DefaultTemplateFormat);
       return template;
 }
        private void DisplayImage(FingerprintTemplate template, FingerprintRawImage rawImage)
        {
            IntPtr hdc = FingerprintCore.GetDC();

              IntPtr image = new IntPtr();

              FPCore.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_NO_CONTEXT);

              SetBMapImage(Bitmap.FromHbitmap(image));

              FingerprintCore.ReleaseDC(hdc);
        }
 private void GetBiometricDisplay(FingerprintTemplate tptQuery, IntPtr rawImage, int width, int height, int res, IntPtr hdc, ref IntPtr handle, int matchContext)
 {
     IntPtr zero = IntPtr.Zero;
     try
     {
         zero = Marshal.AllocHGlobal(tptQuery.Size);
         Marshal.Copy(tptQuery.Buffer, 0, zero, tptQuery.Size);
         int errorCode = 0;
         try
         {
             errorCode = GrFingerprintProxy.GrBiometricDisplay(zero, rawImage, width, height, res, hdc, ref handle, matchContext);
         }
         catch (AccessViolationException exception)
         {
             FingerprintException exception2 = new FingerprintException(-113, exception);
             throw exception2;
         }
         FingerprintException.CheckError(errorCode);
     }
     catch (OutOfMemoryException exception3)
     {
         throw new FingerprintException(-7, exception3);
     }
     finally
     {
         Marshal.FreeHGlobal(zero);
     }
 }
        public void SaveTemplate(FingerprintTemplate fingerprintTemplate,int userID = 0)
        {
            using (dbConection)
                {
                    dbConection.Open();

                    string strCommand;
                    bool validUserID = userID > 0;

                    if (validUserID)
                        strCommand = "INSERT INTO ENROLL(template,quality,[ID_user]) VALUES (?,?,?)";
                    else
                        strCommand = "INSERT INTO ENROLL(template,quality) VALUES (?,?)";

                    OleDbCommand oleCommand = new OleDbCommand(strCommand, dbConection);
                    oleCommand.Parameters.Add(new OleDbParameter("@template", OleDbType.VarBinary, fingerprintTemplate.Size, ParameterDirection.Input, false, 0, 0, "ID", DataRowVersion.Current, fingerprintTemplate.Buffer));
                    oleCommand.Parameters.Add(new OleDbParameter("@quality", OleDbType.Integer));
                    oleCommand.Parameters["@quality"].Value = fingerprintTemplate.Quality;

                    if(validUserID)
                    {
                        oleCommand.Parameters.Add(new OleDbParameter("@user", OleDbType.Integer));
                        oleCommand.Parameters["@user"].Value = userID;
                    }

                    oleCommand.ExecuteNonQuery();
                }
        }
 public int Identify(FingerprintTemplate referenceTemplate, out int verifyScore)
 {
     return this.Identify(referenceTemplate, out verifyScore, 0);
 }
 public void GetBiometricDisplay(FingerprintTemplate tptQuery, FingerprintRawImage rawImage, IntPtr hdc, ref IntPtr handle, int matchContext)
 {
     try
     {
         IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height);
         Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height);
         this.GetBiometricDisplay(tptQuery, destination, rawImage.Width, rawImage.Height, rawImage.Resolution, hdc, ref handle, matchContext);
         Marshal.FreeCoTaskMem(destination);
     }
     catch (OutOfMemoryException exception)
     {
         FingerprintException exception2 = new FingerprintException(-7, exception);
         throw exception2;
     }
 }
Beispiel #28
0
 protected virtual void InternalSaveTemplate(byte fingerCode, FingerprintTemplate fingerPrintTemplate)
 {
 }