PIBIO_SENSOR_FINISH_CAPTURE_FN回呼函式 (winbio_adapter.h)
由 Windows 生物特徵辨識架構呼叫,以等候 SensorAdapterStartCapture 函式起始的擷取作業完成。
語法
PIBIO_SENSOR_FINISH_CAPTURE_FN PibioSensorFinishCaptureFn;
HRESULT PibioSensorFinishCaptureFn(
[in, out] PWINBIO_PIPELINE Pipeline,
[out] PWINBIO_REJECT_DETAIL RejectDetail
)
{...}
參數
[in, out] Pipeline
與執行作業之生物特徵辨識單位相關聯的 WINBIO_PIPELINE 結構的指標。
[out] RejectDetail
WINBIO_REJECT_DETAIL值的指標,接收擷取生物特徵辨識樣本失敗的其他資訊。 如果作業成功,此參數會設定為零。 以下是針對指紋樣本定義的值:
- 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
傳回值
如果函式成功,則會傳回S_OK。 如果函式失敗,它會傳回 指出錯誤的 HRESULT 值。 Windows 生物特徵辨識架構會辨識下列值。
傳回碼 | Description |
---|---|
|
無法擷取範例。 如果您傳回這個錯誤碼,您也必須在 RejectDetail 參數中指定值,指出問題的本質。 |
|
感測器驅動程式傳回 ERROR_CANCELLED 或 ERROR_OPERATION_ABORTED。 |
|
裝置失敗。 |
|
Pipeline 自變數所指向之WINBIO_PIPELINE結構的 SensorContext 成員為 NULL,或 SensorHandle 成員設定為 INVALID_HANDLE_VALUE。 |
備註
Windows 生物特徵辨識架構會在成功呼叫 SensorAdapterStartCapture 或呼叫 SensorAdapterCancel 之後呼叫此函式。 如果 對 SensorAdapterStartCapture 的呼叫失敗,它就不會呼叫此函式。
當此函式的實作傳回時,管線中的數據應該準備好進行 後續呼叫,例如 SensorAdapterPushDataToEngine 或 SensorAdapterExportSensorData。
這是封鎖函式,只有在感測器 I/O 作業成功、失敗或已取消之後才會傳回。 一般而言,您會將感測器配接器內容中的 OVERLAPPED 結構傳遞至 GetOverlappedResult 函式,讓此函式成為區塊。 當 SensorAdapterFinishCapture 傳回時,重疊結構中的 hEvent 句柄必須發出訊號。 GetOverlappedResult 函式會在偵測到感測器 I/O 作業結束時自動設定此句柄。 如果您的配接器使用其他機制來偵測 I/O 完成,您必須自行發出訊號。
範例
下列虛擬程式代碼顯示此函式的一個可能實作。 此範例不會編譯。 您必須調整它以符合您的用途。
//////////////////////////////////////////////////////////////////////////////////////////
//
// SensorAdapterFinishCapture
//
// Purpose:
// Waits for the completion of a capture operation initiated by the
// SensorAdapterStartCapture function.
//
// Parameters:
// Pipeline - Pointer to a WINBIO_PIPELINE structure associated with
// the biometric unit.
// RejectDetail - Pointer to a WINBIO_REJECT_DETAIL value that receives
// additional information about the failure to capture a
// biometric sample.
//
static HRESULT
WINAPI
SensorAdapterFinishCapture(
__inout PWINBIO_PIPELINE Pipeline,
__out PWINBIO_REJECT_DETAIL RejectDetail
)
{
HRESULT hr = S_OK;
WINBIO_SENSOR_STATUS sensorStatus = WINBIO_SENSOR_FAILURE;
WINBIO_CAPTURE_PARAMETERS captureParameters = {0};
BOOL result = TRUE;
DWORD bytesReturned = 0;
// Verify that pointer arguments are not NULL.
if (!ARGUMENT_PRESENT(Pipeline) ||
!ARGUMENT_PRESENT(RejectDetail))
{
hr = E_POINTER;
goto cleanup;
}
// Retrieve the context from the pipeline.
PWINBIO_SENSOR_CONTEXT sensorContext =
(PWINBIO_SENSOR_CONTEXT)Pipeline->SensorContext;
// Verify the state of the pipeline.
if (sensorContext == NULL ||
Pipeline->SensorHandle == INVALID_HANDLE_VALUE)
{
return WINBIO_E_INVALID_DEVICE_STATE;
}
// Initialize the RejectDetail argument.
*RejectDetail = 0;
// Wait for I/O completion. This sample assumes that the I/O operation was
// started using the code example shown in the SensorAdapterStartCapture
// documentation.
SetLastError(ERROR_SUCCESS);
result = GetOverlappedResult(
Pipeline->SensorHandle,
&sensorContext->Overlapped,
&bytesReturned,
TRUE
);
if (!result)
{
// There was an I/O error.
return _AdapterGetHresultFromWin32(GetLastError());
}
if (bytesReturned == sizeof (DWORD))
{
// The buffer is not large enough. This can happen if a device needs a
// bigger buffer depending on the purpose. Allocate a larger buffer and
// force the caller to reissue their I/O request.
DWORD allocationSize = sensorContext->CaptureBuffer->PayloadSize;
// Allocate at least the minimum buffer size needed to retrieve the
// payload structure.
if (allocationSize < sizeof(WINBIO_CAPTURE_DATA))
{
allocationSize = sizeof(WINBIO_CAPTURE_DATA);
}
// Free the old buffer and allocate a new one.
_AdapterRelease(sensorContext->CaptureBuffer);
sensorContext->CaptureBuffer = NULL;
sensorContext->CaptureBuffer =
(PWINBIO_CAPTURE_DATA)_AdapterAlloc(allocationSize);
if (sensorContext->CaptureBuffer == NULL)
{
sensorContext->CaptureBufferSize = 0;
return E_OUTOFMEMORY;
}
sensorContext->CaptureBufferSize = allocationSize;
return WINBIO_E_BAD_CAPTURE;
}
// Normalize the status value before sending it back to the biometric service.
if (sensorContext->CaptureBuffer != NULL &&
sensorContext->CaptureBufferSize >= sizeof (WINBIO_CAPTURE_DATA))
{
switch (sensorContext->CaptureBuffer->SensorStatus)
{
case WINBIO_SENSOR_ACCEPT:
// The capture was acceptable.
break;
case WINBIO_SENSOR_REJECT:
// The capture was not acceptable. Overwrite the WinBioHresult value
// in case it has not been properly set.
sensorContext->CaptureBuffer->WinBioHresult = WINBIO_E_BAD_CAPTURE;
break;
case WINBIO_SENSOR_BUSY:
// The device is busy. Reset the WinBioHresult value in case it
// has not been properly set.
sensorContext->CaptureBuffer->WinBioHresult = WINBIO_E_DEVICE_BUSY;
break;
case WINBIO_SENSOR_READY:
case WINBIO_SENSOR_NOT_CALIBRATED:
case WINBIO_SENSOR_FAILURE:
default:
// There has been a device failure. Reset the WinBioHresult value
// in case it has not been properly set.
sensorContext->CaptureBuffer->WinBioHresult = WINBIO_E_INVALID_DEVICE_STATE;
break;
}
*RejectDetail = sensorContext->CaptureBuffer->RejectDetail;
hr = sensorContext->CaptureBuffer->WinBioHresult;
}
else
{
// The buffer is not large enough or the buffer pointer is NULL.
hr = WINBIO_E_INVALID_DEVICE_STATE;
}
return hr;
}
規格需求
需求 | 值 |
---|---|
最低支援的用戶端 | Windows 7 [僅限傳統型應用程式] |
最低支援的伺服器 | Windows Server 2008 R2 [僅限桌面應用程式] |
目標平台 | Windows |
標頭 | winbio_adapter.h (包含 Winbio_adapter.h) |