PIBIO_ENGINE_IDENTIFY_FEATURE_SET_FN função de retorno de chamada (winbio_adapter.h)

Chamado pela Estrutura Biométrica do Windows para criar um modelo do conjunto de recursos atual e localizar um modelo correspondente no banco de dados. Se uma correspondência puder ser encontrada, o adaptador do mecanismo deverá preencher os parâmetros Identity, SubFactor, PayloadBlob com as informações apropriadas do modelo armazenado.

Sintaxe

PIBIO_ENGINE_IDENTIFY_FEATURE_SET_FN PibioEngineIdentifyFeatureSetFn;

HRESULT PibioEngineIdentifyFeatureSetFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [out]     PWINBIO_IDENTITY Identity,
  [out]     PWINBIO_BIOMETRIC_SUBTYPE SubFactor,
  [out]     PUCHAR *PayloadBlob,
  [out]     PSIZE_T PayloadBlobSize,
  [out]     PUCHAR *HashValue,
  [out]     PSIZE_T HashSize,
  [out]     PWINBIO_REJECT_DETAIL RejectDetail
)
{...}

Parâmetros

[in, out] Pipeline

Ponteiro para uma estrutura WINBIO_PIPELINE associada à unidade biométrica que executa a operação.

[out] Identity

Ponteiro para uma estrutura WINBIO_IDENTITY que contém o GUID ou SID do modelo recuperado do banco de dados. Esse valor será retornado somente se uma correspondência for encontrada.

[out] SubFactor

Um valor WINBIO_BIOMETRIC_SUBTYPE que recebe o subfator associado ao modelo no banco de dados. Para obter mais detalhes, consulte a seção Comentários. Esse valor será retornado somente se uma correspondência for encontrada.

[out] PayloadBlob

Endereço de uma variável que recebe um ponteiro para os dados de conteúdo salvos com o modelo. Se não houver dados de conteúdo, defina esse valor como NULL.

[out] PayloadBlobSize

Ponteiro para uma variável que recebe o tamanho, em bytes, do buffer especificado pelo parâmetro PayloadBlob . Se não houver dados de conteúdo, defina esse valor como zero.

[out] HashValue

Endereço de uma variável que recebe um ponteiro para o valor de hash gerado para o modelo. Se o adaptador do mecanismo não der suporte à geração de hash, defina esse valor como NULL.

[out] HashSize

Ponteiro para uma variável que recebe o tamanho, em bytes, do buffer especificado pelo parâmetro HashValue . Se o adaptador do mecanismo não der suporte à geração de hash, defina esse valor como zero.

[out] RejectDetail

Ponteiro para uma variável que receberá informações adicionais se uma falha de captura impedir que o mecanismo execute uma operação de correspondência. Se a captura mais recente tiver sido bem-sucedida, defina esse parâmetro como zero. Os seguintes valores são definidos para captura de impressão digital:

  • WINBIO_FP_TOO_HIGH
  • WINBIO_FP_TOO_LOW
  • WINBIO_FP_TOO_LEFT
  • WINBIO_FP_TOO_RIGHT
  • WINBIO_FP_TOO_FAST
  • WINBIO_FP_TOO_SLOW
  • WINBIO_FP_POOR_QUALITY
  • WINBIO_FP_TOO_SKEWED
  • WINBIO_FP_TOO_SHORT
  • WINBIO_FP_MERGE_FAILURE

Valor retornado

Se a função for bem-sucedida, ela retornará S_OK para indicar que a última atualização foi bem-sucedida e nenhum conjunto de recursos adicional será necessário para concluir o modelo. Se a função falhar, ela deverá retornar um dos seguintes valores HRESULT para indicar o erro.

Código de retorno Descrição
E_POINTER
O parâmetro Pipeline é NULL.
WINBIO_E_BAD_CAPTURE
O conjunto de recursos não atendeu aos requisitos internos do adaptador do mecanismo para uma operação de identificação. Mais informações sobre a falha são especificadas pelo parâmetro RejectDetail .
WINBIO_E_UNKNOWN_ID
O conjunto de recursos no pipeline não corresponde a nenhuma identidade no banco de dados.

Comentários

O algoritmo usado para gerar o hash de modelo é aquele que foi selecionado pela chamada mais recente, neste pipeline, para EngineAdapterSetHashAlgorithm.

O valor de hash retornado por essa função, se houver, é o hash do modelo de registro encontrado no banco de dados, não o modelo correspondente anexado ao pipeline.

Os buffers PayloadBlob e HashValue são de propriedade e gerenciados pelo adaptador do mecanismo depois que a função EngineAdapterIdentifyFeatureSet retorna com êxito. O adaptador do mecanismo deve manter o endereço do buffer válido, para esse pipeline, até a próxima chamada para EngineAdapterClearContext.

Exemplos

O pseudocódigo a seguir mostra uma implementação possível dessa função. O exemplo não é compilado. Você deve adaptá-lo para se adequar ao seu propósito.

//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterIdentifyFeatureSet
//
// Purpose:
//      Build a template from the current feature set and locate a matching 
//      template in the database.
//
// Parameters:
//      Pipeline        - Pointer to a WINBIO_PIPELINE structure associated 
//                        with the biometric unit performing the operation
//      Identity        - The GUID or SID of the template recovered from the 
//                        database
//      SubFactor       - Sub-factor associated with the template in the 
//                        database
//      PayloadBlob     - Payload data saved with the template
//      PayloadBlobSize - Size, in bytes, of the buffer specified by the 
//                        PayloadBlob parameter. 
//      HashValue       - Hash value for the template
//      HashSize        - Size, in bytes, of the buffer specified by the 
//                        HashValue parameter.
//      RejectDetail    - Receives additional information if a capture 
//                        failure prevents the engine from performing a matching 
//                        operation.
//      
static HRESULT
WINAPI
EngineAdapterIdentifyFeatureSet(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PWINBIO_IDENTITY Identity,
    __out PWINBIO_BIOMETRIC_SUBTYPE SubFactor,
    __out PUCHAR *PayloadBlob,
    __out PSIZE_T PayloadBlobSize,
    __out PUCHAR *HashValue,
    __out PSIZE_T HashSize,
    __out PWINBIO_REJECT_DETAIL RejectDetail
    )
{
    HRESULT hr = S_OK;
    SIZE_T recordCount = 0;
    SIZE_T index = 0;
    WINBIO_STORAGE_RECORD thisRecord;
    BOOLEAN match = FALSE;
    DWORD indexVector[NUMBER_OF_TEMPLATE_BINS] = {0};

    // Verify that pointer arguments are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline) ||
        !ARGUMENT_PRESENT(Identity) ||
        !ARGUMENT_PRESENT(SubFactor) ||
        !ARGUMENT_PRESENT(PayloadBlob) ||
        !ARGUMENT_PRESENT(PayloadBlobSize) ||
        !ARGUMENT_PRESENT(HashValue) ||
        !ARGUMENT_PRESENT(HashSize) ||
        !ARGUMENT_PRESENT(RejectDetail))
    {
        hr = E_POINTER;
        goto cleanup;
    }

    // Retrieve the context from the pipeline.
    PWINBIO_ENGINE_CONTEXT context = 
           (PWINBIO_ENGINE_CONTEXT)Pipeline->EngineContext;

    // Initialize the return values.
    ZeroMemory( Identity, sizeof(WINBIO_IDENTITY));
    Identity->Type = WINBIO_ID_TYPE_NULL;
    *SubFactor          = WINBIO_SUBTYPE_NO_INFORMATION;
    *PayloadBlob        = NULL;
    *PayloadBlobSize    = 0;
    *HashValue          = NULL;
    *HashSize           = 0;
    *RejectDetail       = 0;

    // The biometric unit cannot perform verification or identification
    // operations while it is performing an enrollment sequence.
    if (context->Enrollment.InProgress == TRUE)
    {
        hr = WINBIO_E_ENROLLMENT_IN_PROGRESS;
        goto cleanup;
    }

    // If your adapter supports index vectors to place templates into buckets,
    // call a custom function (_AdapterCreateIndexVector) to create an index 
    // vector from the template data in the feature set. In this example, the
    // engine adapter context attached to the pipeline contains a FeatureSet
    // member.
    hr = _AdapterCreateIndexVector(
                context, 
                context->FeatureSet,
                context->FeatureSetSize,
                indexVector, 
                NUMBER_OF_TEMPLATE_BINS, 
                RejectDetail
                );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Retrieve the records in the index vector. If your adapter does not support 
    // index vectors (the vector length is zero), calling the WbioStorageQueryByContent 
    // function will retrieve all records.
    // WbioStorageQueryByContent is a wrapper function in the Winbio_adapter.h 
    // header file.
    hr = WbioStorageQueryByContent(
            Pipeline,
            WINBIO_SUBTYPE_ANY,
            indexVector,
            NUMBER_OF_TEMPLATE_BINS
            );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Determine the size of the result set. WbioStorageGetRecordCount is a wrapper
    // function in the Winbio_adapter.h header file.
    hr = WbioStorageGetRecordCount( Pipeline, &recordCount);
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Point the result set cursor at the first record. WbioStorageFirstRecord
    // is a wrapper function in the Winbio_adapter.h header file.
    hr = WbioStorageFirstRecord( Pipeline );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Iterate through all records in the result set and determine which record
    // matches the current feature set. WbioStorageGetCurrentRecord is a wrapper
    // function in the Winbio_adapter.h header file.
    for (index = 0; index < recordCount; ++index)
    {
        hr = WbioStorageGetCurrentRecord( Pipeline, &thisRecord );
        if (FAILED(hr))
        {
            goto cleanup;
        }

        // Call a custom function (_AdapterCompareTemplateToCurrentFeatureSet) to
        // compare the feature set attached to the pipeline with the template
        // retrieved from storage.
        // If the template and feature set do not match, return WINBIO_E_NO_MATCH
        // and set the Match parameter to FALSE.
        // If your custom function cannot process the feature set, return 
        // WINBIO_E_BAD_CAPTURE and set extended error information in the 
        // RejectDetail parameter.
        hr = _AdapterCompareTemplateToCurrentFeatureSet( 
                    context, 
                    context->FeatureSet,
                    context->FeatureSetSize,
                    thisRecord.TemplateBlob, 
                    thisRecord.TemplateBlobSize,
                    &match,
                    RejectDetail 
                    );
        if (FAILED(hr) && hr != WINBIO_E_NO_MATCH)
        {
            goto cleanup;
        }
        if (match)
        {
            break;
        }

        hr = WbioStorageNextRecord( Pipeline );
        if (FAILED(hr))
        {
            if (hr == WINBIO_E_DATABASE_NO_MORE_RECORDS)
            {
                hr = S_OK;
                break;
            }
            else
            {
                goto cleanup;
            }
        }
    }

    if (match)
    {
        // If there is a match and if your engine adapter supports template
        // hashing, call a custom function (_AdapterGenerateHashForTemplate)
        // to calculate the hash. Save the hash value in the context area of
        // the engine adapter.
        // Skip this step if your adapter does not support template hashing.
        hr = _AdapterGenerateHashForTemplate(
                    context,
                    thisRecord.TemplateBlob, 
                    thisRecord.TemplateBlobSize,
                    context->HashBuffer,
                    &context->HashSize
                    );
        if (FAILED(hr))
        {
            goto cleanup;
        }

        // Return information about the matching template to the caller.
        CopyMemory( Identity, thisRecord.Identity, sizeof(WINBIO_IDENTITY));

        *SubFactor          = thisRecord.SubFactor;
        *PayloadBlob        = thisRecord.PayloadBlob;
        *PayloadBlobSize    = thisRecord.PayloadBlobSize;
        *HashValue          = &context->HashBuffer;
        *HashSize           = context->HashSize;
    }
    else
    {
        hr = WINBIO_E_UNKNOWN_ID;
    }

cleanup:

    if (hr == WINBIO_E_DATABASE_NO_RESULTS)
    {
        hr = WINBIO_E_UNKNOWN_ID;
    }
    return hr;
}

Requisitos

   
Cliente mínimo com suporte Windows 7 [somente aplicativos da área de trabalho]
Servidor mínimo com suporte Windows Server 2008 R2 [somente aplicativos da área de trabalho]
Plataforma de Destino Windows
Cabeçalho winbio_adapter.h (inclua Winbio_adapter.h)

Confira também

EngineAdapterVerifyFeatureSet

Funções de plug-in