使用Windows生物识别框架在Windows 10上使用英特尔Realsense相机进行人脸识别 [英] Using Windows Biometric Framework to do face recognition on Window 10 with Intel Realsense camera

查看:245
本文介绍了使用Windows生物识别框架在Windows 10上使用英特尔Realsense相机进行人脸识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一台英特尔真实感相机,我可以用它在Window 10上设置Window Hello登录。现在我可以尝试使用面部  ;在窗口10上使用Window 生物识别框架以编程方式识别。 我找不到所需的文档
和样本来做到这一点,但我设法有一些代码来使用API​​。我有以下方法
EnrollSysPool,它被称为




hr = EnrollSysPool(TRUE,WINBIO_ANSI_385_FACE_FRONTAL_FULL);







HRESULT EnrollSysPool(



BOOL discardEnrollment



WINBIO_BIOMETRIC_SUBTYPE subFactor



{




HRESULT hr
=
S_OK ;



WINBIO_IDENTITY identity
= {0};



identity.Type =
WINBIO_ID_TYPE_GUID ;



WINBIO_SESSION_HANDLE sessionHandle
=
NULL ;



WINBIO_UNIT_ID unitId
= 1;



WINBIO_REJECT_DETAIL rejectDetail
= 0;



BOOLEAN isNewTemplate
=
TRUE ;



//连接到系统池。



hr = WinBioOpenSession(




WINBIO_TYPE_FACIAL_FEATURES
//服务提供商



// WINBIO_TYPE_THERMAL_FACE_IMAGE,// Service
provider



WINBIO_POOL_SYSTEM
//池类型



// WINBIO_POOL_PRIVATE,



WINBIO_FLAG_DEFAULT
//配置和访问



NULL
//生物识别单位ID数组



0, //生物识别单位ID计数



WINBIO_DB_DEFAULT
//数据库ID



& sessionHandle
// [out]会话句柄



);




if FAILED (hr))



{




wprintf_s( L" \ n WinBioOpenSession失败。
"
);



wprintf_s( L" hr = 0x%x \ n"
hr);



goto e_Exit;



}




//找到一个传感器。



/ * wprintf_s(L" \ n在
传感器上滑动手指... \ n");



hr = WinBioLocateSensor(sessionHandle,& unitId);


if(FAILED(hr))


{


wprintf_s(L" \ n WinBioLocateSensor failed.hr = 0x%x \ n",hr);


转到e_Exit;


} * /




//开始注册序列。



wprintf_s( L" \\ \\ n开始注册顺序... \ n" );



hr = WinBioEnrollBegin(




sessionHandle,
//打开生物识别会话的句柄


< span style ="color:#008000; font-size:small">


subFactor
//用于创建的模板



unitId //生物识别单位ID



);




if FAILED (hr))



{




wprintf_s( L" \\\
WinBioEnrollBegin失败。
hr = 0x%x \ n"
,hr);


< span style ="font-size:small">


goto e_Exit;



}




//用 :#008000; font-size:small">


//由 中的subFactor参数
标识的手指



// WinBioEnrollBegin函数。



for int faceCapture
= 1 ;; ++ faceCapture)



{




wprintf_s( L" \ n相机捕获%s面对
样本。"



(faceCapture == 1)?
L"第一个"
L" another" );



hr = WinBioEnrollCapture(




sessionHandle,
//打开生物识别会话的句柄



& rejectDetail
// [out]失败信息



);




wprintf_s( L" \ n从单位
编号%d中捕获的样本%d。"



faceCapture,


unitId);




< span style ="font-size:small"> if (hr
==
WINBIO_I_MORE_DATA



{




wprintf_s( L" \ n需要更多数据。\ n" );



continue ;



}




if FAILED (hr))



{




if (hr
==
WINBIO_E_BAD_CAPTURE



{




wprintf_s( L" \ n错误:捕获错误;原因:
%d"



rejectDetail);




continue ;



}




else



{




wprintf_s( L" \ n WinBioEnrollCapture失败。
hr = 0x%x"
,hr);



goto e_Exit;



}


}




else



{




wprintf_s( L" \ n模板已完成。\ n" );



break ;



}


}




//如果设置了适当的
标志,则丢弃注册。



//如果没有丢弃,则提交注册。



if discardEnrollment ==
TRUE



{




wprintf_s( L" \ n放弃注册... \\ n \ n" );



hr = WinBioEnrollDiscard (sessionHandle);




if(FAILED(hr))



{




wprintf_s(L"\n WinBioLocateSensor failed.
hr = 0 x%x\n"
, hr);



}




gotoe_Exit;



}




else



{




wprintf_s(L"\n Committing enrollment...\n");



hr = WinBioEnrollCommit(




sessionHandle,
// Handle to open biometric session



&identity,
// WINBIO_IDENTITY object for the user



&isNewTemplate);
// Is this a new template



if(FAILED(hr))



{




wprintf_s(L"\n WinBioEnrollCommit failed.
hr = 0x%x\n"
, hr);



gotoe_Exit;



}


}


 


e_Exit:




if(sessionHandle
!=
NULL)



{


WinBioCloseSession(sessionHandle);




sessionHandle =
NULL;



}




wprintf_s(L" Press any key to continue...");



_getch();




returnhr;



}


 It failed in calling WinBioEnrollCapture.



I also tried the WinBioVerify, it also failed.



So is there anything I need to set up to enable the Window Biometric Framework to connect to my camera. Or the face recognition is not actually working at all in Window Biometric Framework.


You help is greatly appreciated.



Sincerely,



Ping Tian


ping.tian@razerzone.com




解决方案

If the function fails, it returns an HRESULT value that indicates the error. So please provide your HRESULT value so that we can find the exact reason. There has a sample of calling WinBioEnrollCapture, you can refer to.


https://msdn.microsoft.com/en-us/library/windows/desktop/dd401618(v=vs.85).aspx







Hi,

I have an Intel Real sense Camera and I can use it to set up the Window Hello login on Window 10. Now I can trying to use the face recognition programmatically using Window Biometric Framework on window 10. I cannot find needed documentation and sample to do that, But I managed to have some code to use the API. I have following method EnrollSysPool and it called as

hr = EnrollSysPool(TRUE, WINBIO_ANSI_385_FACE_FRONTAL_FULL);

HRESULTEnrollSysPool(

BOOLdiscardEnrollment,

WINBIO_BIOMETRIC_SUBTYPEsubFactor)

{

HRESULThr = S_OK;

WINBIO_IDENTITYidentity = { 0 };

identity.Type = WINBIO_ID_TYPE_GUID;

WINBIO_SESSION_HANDLEsessionHandle = NULL;

WINBIO_UNIT_IDunitId = 1;

WINBIO_REJECT_DETAILrejectDetail = 0;

BOOLEANisNewTemplate = TRUE;

// Connect to the system pool.

hr = WinBioOpenSession(

WINBIO_TYPE_FACIAL_FEATURES, // Service provider

//WINBIO_TYPE_THERMAL_FACE_IMAGE, // Service provider

WINBIO_POOL_SYSTEM, // Pool type

//WINBIO_POOL_PRIVATE,

WINBIO_FLAG_DEFAULT, // Configuration and access

NULL, // Array of biometric unit IDs

0, // Count of biometric unit IDs

WINBIO_DB_DEFAULT, // Database ID

&sessionHandle // [out] Session handle

);

if(FAILED(hr))

{

wprintf_s(L"\n WinBioOpenSession failed. ");

wprintf_s(L"hr = 0x%x\n", hr);

gotoe_Exit;

}

// Locate a sensor.

/*wprintf_s(L"\n Swipe your finger on the sensor...\n");

hr = WinBioLocateSensor(sessionHandle, &unitId);

if (FAILED(hr))

{

wprintf_s(L"\n WinBioLocateSensor failed. hr = 0x%x\n", hr);

goto e_Exit;

}*/

// Begin the enrollment sequence.

wprintf_s(L"\n Starting enrollment sequence...\n");

hr = WinBioEnrollBegin(

sessionHandle, // Handle to open biometric session

subFactor, // Finger to create template for

unitId // Biometric unit ID

);

if(FAILED(hr))

{

wprintf_s(L"\n WinBioEnrollBegin failed. hr = 0x%x\n", hr);

gotoe_Exit;

}

// Capture enrollment information by swiping the sensor with

// the finger identified by the subFactor argument in the

// WinBioEnrollBegin function.

for(intfaceCapture = 1;; ++faceCapture)

{

wprintf_s(L"\n Camera to capture %s face sample.",

(faceCapture == 1) ? L"the first": L"another");

hr = WinBioEnrollCapture(

sessionHandle, // Handle to open biometric session

&rejectDetail // [out] Failure information

);

wprintf_s(L"\n Sample %d captured from unit number %d.",

faceCapture,

unitId);

if(hr == WINBIO_I_MORE_DATA)

{

wprintf_s(L"\n More data required.\n");

continue;

}

if(FAILED(hr))

{

if(hr == WINBIO_E_BAD_CAPTURE)

{

wprintf_s(L"\n Error: Bad capture; reason: %d",

rejectDetail);

continue;

}

else

{

wprintf_s(L"\n WinBioEnrollCapture failed. hr = 0x%x", hr);

gotoe_Exit;

}

}

else

{

wprintf_s(L"\n Template completed.\n");

break;

}

}

// Discard the enrollment if the appropriate flag is set.

// Commit the enrollment if it is not discarded.

if(discardEnrollment== TRUE)

{

wprintf_s(L"\n Discarding enrollment...\n\n");

hr = WinBioEnrollDiscard(sessionHandle);

if(FAILED(hr))

{

wprintf_s(L"\n WinBioLocateSensor failed. hr = 0x%x\n", hr);

}

gotoe_Exit;

}

else

{

wprintf_s(L"\n Committing enrollment...\n");

hr = WinBioEnrollCommit(

sessionHandle, // Handle to open biometric session

&identity, // WINBIO_IDENTITY object for the user

&isNewTemplate); // Is this a new template

if(FAILED(hr))

{

wprintf_s(L"\n WinBioEnrollCommit failed. hr = 0x%x\n", hr);

gotoe_Exit;

}

}

 

e_Exit:

if(sessionHandle != NULL)

{

WinBioCloseSession(sessionHandle);

sessionHandle = NULL;

}

wprintf_s(L" Press any key to continue...");

_getch();

returnhr;

}

 It failed in calling WinBioEnrollCapture.

I also tried the WinBioVerify, it also failed.

So is there anything I need to set up to enable the Window Biometric Framework to connect to my camera. Or the face recognition is not actually working at all in Window Biometric Framework.

You help is greatly appreciated.

Sincerely,

Ping Tian

ping.tian@razerzone.com

解决方案

If the function fails, it returns an HRESULT value that indicates the error. So please provide your HRESULT value so that we can find the exact reason. There has a sample of calling WinBioEnrollCapture, you can refer to.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd401618(v=vs.85).aspx




这篇关于使用Windows生物识别框架在Windows 10上使用英特尔Realsense相机进行人脸识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆