public Task <int> CriarTaskParaIdentificacaoBiometrica(byte[] template, IEnumerable <Biometria> biometrias) { var contextoIdentificacao = new ContextoParaIndentificacaoBiometrica(Id, biometrias, template); CancellationSource = new CancellationTokenSource(); var token = CancellationSource.Token; return(new Task <int>((parametroState) => { try { var contexto = parametroState as ContextoParaIndentificacaoBiometrica; Console.WriteLine($"{DateTime.Now} - {contexto.Id} - Localizando em {contexto.Biometrias.Count()} biometrias..."); if (token.IsCancellationRequested) { return 0; } var nitgenMainApi = new NBioBSP(); IIndexSearch nitgenSearchApi = nitgenMainApi.IndexSearch; foreach (var biometria in contexto.Biometrias) { nitgenSearchApi.AddFIR(biometria.TemplateFIR, biometria.Id); } Console.WriteLine($"{DateTime.Now} - {contexto.Id} - Iniciando identificação..."); var relogio = new Stopwatch(); relogio.Start(); nitgenSearchApi.IdentifyUser(template, 7); relogio.Stop(); Console.WriteLine($"{DateTime.Now} - {contexto.Id} - Localizado {nitgenSearchApi.UserID} em {relogio.Elapsed.TotalSeconds}"); return nitgenSearchApi.UserID; //if (nitgenSearchApi.UserID > 0 && nitgenSearchApi.ErrorCode == 0) //{ //} //Console.WriteLine($"ERRO NA IDENTIFICAÇÃO: {nitgenSearchApi.ErrorCode} - {nitgenSearchApi.ErrorDescription}"); //return 0; } catch (Exception ex) { Console.WriteLine(ex.Message); return 0; } }, contextoIdentificacao, token)); }
public int IdentificarBiometria(byte[] template) { //_data.Import(1, 0, 1, 7, 404, template); _indexSearch.IdentifyUser(template, 7); return(_indexSearch.UserID); }