How to recover and use a fingerprint template from database?

General information about Neurotechnology and its software

How to recover and use a fingerprint template from database?

Postby lchavez » Sep 01, 2017 22:15

Good day!

Again asking for your support to clarify a doubt.

I am currently working with the version of the SDK 10.0, and I have a fingerprint reader brand U.are.U 4500 Digital Persona, my question is aimed at the following:

The application that I am developing is to obtain the fingerprints of a subject and to store them in database of sql server 2014,

Code: Select all
<blockcode>

private int SaveFinger(NFinger dedo, int idSujeto)
        {
            int v = 0;
            string pos = dedo.Position.ToString();
            var buffer = dedo.BinarizedImage.Save().ToArray(); //dedo.Image.Save().ToArray();
            conection.ConnectionString = "Data Source= .; Initial Catalog= db_pruebas; Integrated Security=TRUE";
            int size = NuevaPersona.Fingers[0].Image.GetSize();//NuevaPersona.GetTemplateBuffer().Size.ToString();
            var fecha = DateTime.Now;
            string sql = string.Format("INSERT INTO Ejemplo3(IdSujeto, Plantilla, Posicion, Espacio, Fecha) VALUES (@IdSujeto, @Huella,@Position, @Size, @Fecha)", idSujeto, buffer, pos, size, fecha);
            try
            {
                cmd = new SqlCommand(sql, conection) { CommandType = CommandType.Text};
                cmd.Parameters.Add(new SqlParameter() { ParameterName = "@IdSujeto", SqlDbType = SqlDbType.Int, Value = idSujeto});
                cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Huella", SqlDbType = SqlDbType.VarBinary, Value = buffer });
                cmd.Parameters.Add(new SqlParameter() { ParameterName="@Position", SqlDbType = SqlDbType.VarChar, Size=20, Value = pos});
                cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Size", SqlDbType = SqlDbType.Int,  Value = size });
                cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Fecha", SqlDbType = SqlDbType.DateTime, Value = fecha });

                conection.Open();
                v= cmd.ExecuteNonQuery();
                conection.Close();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {

            }
            return v;
        }

</blockcode>



My question is: Is the way I'm storing the fingerprints correct?
How can I recover these stored tracks in database to be able to compare them with those of a new subject?

I have been trying to retrieve them in a datatable and send them to a list to later retrieve an object of the type NFINGER but I have not been lucky, I have been reading all the posts that are in this forum but none has a solution that helps me to continue with this project .

Code: Select all
<blockcode>

  private NFinger[] RecuperarSujeto()
        {
            NFinger nSujeto = new NFinger();
            string sql = "SELECT Plantilla FROM Ejemplo3 WHERE IdSujeto = 1";
            conection.ConnectionString = "Data Source= .; Initial Catalog= db_pruebas; Integrated Security=TRUE";
            cmd = new SqlCommand(sql, conection) { CommandType = CommandType.Text};
            dt = new DataTable();
            da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            nSujeto.Image = ? --> In this site I have no idea how to continue to recover the fingerprints
        }

        public List<NFinger> DatosSujeto()
        {
            List<NFinger> lstDatos = new List<NFinger>();
            foreach (var sujeto in RecuperarSujeto())
            {
                NFinger dedo = new NFinger(){ BinarizedImage = sujeto.BinarizedImage, Position = sujeto.Position };
                lstDatos.Add(dedo);
            }
            return lstDatos;
        }


</blockcode>


In the folder of tutorials, comes an example called IdentifyFinger and another VerifyFinger, but in both cases recover the fingerprint from a file, I require something similar but recovering the fingerprint from database.

Annex sample codes.

I remain attentive to your comments.

Best regards

Luis Raúl Chávez Trinidad
Mexico City
lchavez
 
Posts: 10
Joined: Jul 19, 2017 21:57

Re: How to recover and use a fingerprint template from datab

Postby Martynas » Sep 04, 2017 10:23

Hello,

first of all I need to mention that it is possible to configure the NBiometricClient to work directly with the database through the ODBC connection.
So, by using it, you can enroll fingerprint templates directly to the database.
Also the NBiometricClient will retrieve templates from the database automatically during its initialization.
And in such case there is no need to perform manual insertion/retrieval to/from database.

You can take a look at tutorials EnrollToSQLiteDatabase and IdentifyOnSQLiteDatabase tutorials. They are using SQLite database, but you can easily modify these tutorials to use your SQL Server ODBC connection by replacing the "biometricClient.SetDatabaseConnectionToSQLite" with "biometricClient.SetDatabaseConnectionToODBC".

Next, as i see from your code, you are saving not finger templates, but finger images. I need to mention, that in such case you will need to extract finger templates from finger images in such case, if you will be storing only images in your database. And this is time consuming operation. Thus we recommend to enroll finger templates into database instead of images.
But if you will decide to use images, then you need to set this retrieved image to NFinger, then add this NFinger to NSubject:

Code: Select all
NSubject subject = new NSubject();
NFinger finger = new NFinger();
finger.Image = NImage.FromMemory(your_image_bytes);
Best regards,

Martynas
Software Consultant
Neurotechnology
Martynas
Neurotechnology
 
Posts: 2192
Joined: Sep 19, 2008 10:02
Location: Vilnius, Lithuania

Re: How to recover and use a fingerprint template from datab

Postby lchavez » Sep 04, 2017 15:11

good day

First of all, I thank you for your answer, and I comment, if I knew that I could occupy the same sample application and that it was only necessary to change the connection string so that it stored in database, only that by company standards I can not do that, and well, here you have me struggling a bit with the development of this system.

Now I tell you, my initial idea was based on storing the template as you tell me, but what I do not quite clear is: in a template are stored the 10 fingerprints ?, Is there any way to create a template for each fingerprint ?.

Under the requirements of the project, I am requested to store up to 10 fingerprints of a clerk / employee, and subsequently with said fingerprints, to verify said fingerprints to measure times and operations performed by said employee or client.

I wonder if storing just one template, can I do the same task? or if I have to perform any additional tasks with this template in order to perform my validation tasks.

I keep an eye on your comments.

Best regards

Luis Raul Chavez
Mexico City
lchavez
 
Posts: 10
Joined: Jul 19, 2017 21:57

Re: How to recover and use a fingerprint template from datab

Postby Martynas » Sep 05, 2017 11:12

lchavez wrote:Now I tell you, my initial idea was based on storing the template as you tell me, but what I do not quite clear is: in a template are stored the 10 fingerprints ?, Is there any way to create a template for each fingerprint ?.


NTemplate can contain multiple records of the person fingers. So you can store all 10 fingers of each person into one template.
If your created templates contains only one finger of the person, then you can combine them into one template by using a code from tutorial "CreateMultiFingerTemplate".
Each fingerprint from the query template is matched with the database template in the following way:
• If fingerprint position is unknown, it is matched with all fingerprint templates in database and matching result with maximal score is returned.
• If fingerprint position is known, it is matched with all fingerprint templates in database. The matching result is one of these: the template which has the same fingerprint position or the template which has unknown fingerprint position with maximal matching score.
Best regards,

Martynas
Software Consultant
Neurotechnology
Martynas
Neurotechnology
 
Posts: 2192
Joined: Sep 19, 2008 10:02
Location: Vilnius, Lithuania

Re: How to recover and use a fingerprint template from datab

Postby lchavez » Sep 07, 2017 23:18

Hi good day!

I have a question, I currently store all the fingerprints in a database of sql server 2014 in a template.

I am currently testing the fingerprint verification part, and my serious doubt Is it possible to perform a quick check when entering a fingerprint?

That is, when a subject "x" enters his first fingerprint trigger an event and evaluate if that fingerprint already exists in the database?

I await your comments

Best regards

Excellent day

Luis Raul Chavez Trinidad
Mexico City
lchavez
 
Posts: 10
Joined: Jul 19, 2017 21:57

Re: How to recover and use a fingerprint template from datab

Postby Martynas » Sep 08, 2017 06:44

Hello,

in all cases you need to perform the matching. If you need to check if the first finger exist in the database, then you need to perform that fingerprint identification/verification against records in the database.
Best regards,

Martynas
Software Consultant
Neurotechnology
Martynas
Neurotechnology
 
Posts: 2192
Joined: Sep 19, 2008 10:02
Location: Vilnius, Lithuania


Return to Public

Who is online

Users browsing this forum: No registered users and 5 guests

cron