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 生物识别框架将识别以下值。
返回代码 | 说明 |
---|---|
|
无法捕获示例。 如果返回此错误代码,还必须在 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 返回时,必须向 OVERLAPPED 结构中的 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) |