robertvazan / sourceafis-java

Fingerprint recognition engine for Java that takes a pair of human fingerprint images and returns their similarity score. Supports efficient 1:N search.
https://sourceafis.machinezoo.com/java
Apache License 2.0
245 stars 100 forks source link

very long response time #43

Closed dmcsuporte closed 3 years ago

dmcsuporte commented 3 years ago

Hello, how are you? I have a problem with version 3.13... I think I might be doing something wrong... so I wanted your help if possible.

I'm facing a response time issue on this line, it takes a long time...

EX CODE :

double high = 0;
double threshold = 40;
Integer match = null;

          pstmt = conexao.prepareStatement("SELECT d.pessoa_id, d.FingerprintTemplate \n" + 
          "FROM pessoa as p \n" + 
          "inner JOIN digital as d on p.id = d.pessoa_id \n" + 
          "where p.tipo_pessoa_id in ("+ tipoPessoa +") " +
          "and FingerprintTemplate <> '' \n" + 
          "and p.libera_visitante <> 'bloqueado' "
          );
rs = pstmt.executeQuery();

//  (2500 FingerprintTemplate)
while (rs.next()) {
        byte[] serialized = rs.getBytes("FingerprintTemplate");
        FingerprintTemplate candidate = new FingerprintTemplate(serialized);

        // ******************* it's slow here
        double score = new FingerprintMatcher(probe).match(candidate);

        if (score > high) {
          high = score;
          match = rs.getInt("pessoa_id");
        }
}`

The templates are in a table. In previous versions I kept the template serialized, but I saw that it is already deprecated. Now I store the template in a blob field.

Am I doing this right?

thanks

robertvazan commented 3 years ago

Do not recreate FingerprintMatcher each time. Construct it once before the loop starts and then reuse it.

dmcsuporte commented 3 years ago

Thanks!!!!!!!!!!!!!!!!