I have a thousand fingerprints stored in my database in a Byte[] array, and I'm trying to make a 1 to N verification of the fingerprint, which means that I need to compare the fingerprint given by the sensor and the ones in the array.
But the process is taking too long, I'm using a forEach loop to iterate through all of the fingerprints in the array and calling the verification method to compare the 2 arrays to find the match.
Is there a way I can make the process of finding the match faster? In worst case scenario where the match is the last item in the array. Or near the bottom.
Fingerprint List
List<Huellas> ListaHuellas = new List<Huellas>();
public class Huellas
{
public int idUsuario;
public Byte[] Huella;
}
Searching the match
foreach (Huellas h in ListaHuellas) {
// Por cada huella... la almacenamos en un MemoryStream como arreglo de bytes.
MemoryStream fingerprintData = new MemoryStream(h.Huella);
// Creamos una plantilla a partir de esos bytes...
DPFP.Template templateIterando = new DPFP.Template(fingerprintData);
// Extraemos las caracteristicas de la plantilla
DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);
// Verificamos que las caracteristicas sean buenas
if (features != null) {
// Compare the feature set with our template
DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
Verificator.Verify(features, templateIterando, ref result);
// Y vemos si el resultado es valido o no, (verified)
// Si es verified, significa que el dedo escaneado ya existia en la base de datos.
if (result.Verified) {
MessageBox.Show(new Form { TopMost = true }, "Usuario encontrado: ID " + h.idUsuario);
// Por ultimo se cierra el programa.
this.Invoke(new MethodInvoker(delegate { this.Close(); }));
}
}
}
Sorry 'bout the spanish comments.