PIBIO_ENGINE_IDENTIFY_FEATURE_SET_FN
コールバックシグネチャ
HRESULT PIBIO_ENGINE_IDENTIFY_FEATURE_SET_FN(
WINBIO_PIPELINE* Pipeline,
WINBIO_IDENTITY* Identity,
BYTE* SubFactor,
BYTE** PayloadBlob,
UINT_PTR* PayloadBlobSize,
BYTE** HashValue,
UINT_PTR* HashSize,
DWORD* RejectDetail
);パラメーター
| フィールド | 型 | 説明 |
|---|---|---|
| Pipeline | WINBIO_PIPELINE* | 操作を実行するバイオメトリックユニットに関連付けられた WINBIO_PIPELINE 構造体へのポインター。 |
| Identity | WINBIO_IDENTITY* | データベースから取得されたテンプレートの GUID または SID を格納する WINBIO_IDENTITY 構造体へのポインター。この値は、一致するテンプレートが見つかった場合にのみ返されます。 |
| SubFactor | BYTE* | データベース内のテンプレートに関連付けられたサブファクターを受け取る WINBIO_BIOMETRIC_SUBTYPE 値。詳細については「解説」セクションを参照してください。この値は、一致するテンプレートが見つかった場合にのみ返されます。 |
| PayloadBlob | BYTE** | テンプレートとともに保存されたペイロードデータへのポインターを受け取る変数のアドレス。ペイロードデータがない場合は、この値を NULL に設定します。 |
| PayloadBlobSize | UINT_PTR* | PayloadBlob パラメーターで指定されたバッファーのサイズ (バイト単位) を受け取る変数へのポインター。ペイロードデータがない場合は、この値を 0 に設定します。 |
| HashValue | BYTE** | テンプレートに対して生成されたハッシュ値へのポインターを受け取る変数のアドレス。エンジンアダプターがハッシュ生成をサポートしていない場合は、この値を NULL に設定します。 |
| HashSize | UINT_PTR* | HashValue パラメーターで指定されたバッファーのサイズ (バイト単位) を受け取る変数へのポインター。エンジンアダプターがハッシュ生成をサポートしていない場合は、この値を 0 に設定します。 |
| RejectDetail | DWORD* | キャプチャの失敗によってエンジンが照合操作を実行できない場合に、追加情報を受け取る変数へのポインター。直近のキャプチャが成功した場合は、このパラメーターを 0 に設定します。指紋のキャプチャについては、次の値が定義されています。
|
公式ドキュメント
現在の特徴セットからテンプレートを構築し、データベース内で一致するテンプレートを検索するために、Windows Biometric Framework によって呼び出されます。一致するテンプレートが見つかった場合、エンジンアダプターは、格納されているテンプレートから取得した適切な情報を Identity、SubFactor、PayloadBlob の各パラメーターに設定する必要があります。
戻り値
関数が成功した場合は S_OK を返し、直前の更新が成功して、テンプレートを完成させるために追加の特徴セットが不要であることを示します。関数が失敗した場合は、エラーを示すために次のいずれかの HRESULT 値を返す必要があります。
| 戻り値 | 説明 |
|---|---|
| Pipeline パラメーターが NULL です。 | |
| 特徴セットが、識別操作に対するエンジンアダプターの内部要件を満たしていません。失敗に関する詳細情報は RejectDetail パラメーターで示されます。 | |
| パイプライン内の特徴セットが、データベース内のどの ID にも対応していません。 |
解説(Remarks)
テンプレートのハッシュの生成に使用されるアルゴリズムは、このパイプラインに対する直近の EngineAdapterSetHashAlgorithm の呼び出しで選択されたものです。
この関数が返すハッシュ値は、パイプラインに関連付けられた照合用テンプレートのものではなく、データベース内で見つかった登録テンプレートのハッシュです。
EngineAdapterIdentifyFeatureSet 関数が正常に復帰した後、PayloadBlob バッファーと HashValue バッファーはエンジンアダプターが所有および管理します。エンジンアダプターは、このパイプラインに対する次の EngineAdapterClearContext の呼び出しまで、バッファーのアドレスを有効に保つ必要があります。
例
次の擬似コードは、この関数の実装例の 1 つを示しています。この例はコンパイルできません。目的に合わせて適宜変更してください。
//////////////////////////////////////////////////////////////////////////////////////////
//
// 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;
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)