Software Archive
Read-only legacy content

Face Recognition problem

tony2
Beginner
1,000 Views

Hello!

I've created a small face recognition program, based on the SDK documentation and I believe the detected user is not registering to the database as it should. The program only returns "New USER registered: -1" (which is the return value for QueryUserID() for an unregistered user) . I must be doing something wrong there...

I am pasting the code in here, can anyone help please?

PXCFaceConfiguration *facecfg = faceModule->CreateActiveConfiguration();
PXCFaceConfiguration::RecognitionConfiguration *rcfg = facecfg->QueryRecognition();
// Enable face recognition:
rcfg->Enable();
// Create a recognition database:
PXCFaceConfiguration::RecognitionConfiguration::RecognitionStorageDesc desc={};
desc.maxUsers =10;
rcfg->CreateStorage(L"DB1", &desc);
rcfg->UseStorage(L"DB1");
// Set the Face Registration Mode:
rcfg->SetRegistrationMode(PXCFaceConfiguration::RecognitionConfiguration::REGISTRATION_MODE_CONTINUOUS);
		
facecfg->EnableAllAlerts();
facecfg->ApplyChanges();
facecfg->Release();

PXCFaceData *fdata = faceModule->CreateOutput();
fdata->Update();

if (fdata == NULL)
{
	wprintf_s(L"PXCFaceData fdata is NULL!!!\n");
}
wprintf_s(L"Number of faces detected: %d \n", fdata->QueryNumberOfDetectedFaces());
if(fdata->QueryNumberOfDetectedFaces()>0)
{
	PXCFaceData::Face *faceData = fdata->QueryFaceByIndex(0);
	PXCFaceData::RecognitionData *recognitionData = faceData->QueryRecognition();

	if (recognitionData != NULL)
	{
	       // recognize the current face?
		pxcI32 uid = recognitionData->QueryUserID(); 
		if (uid >= 0)
		{
			// User recognized:
			wprintf_s(L"	USER recognized: %d\n", uid);
		} else
		{
			recognitionData->RegisterUser();
			wprintf_s(L"	New USER registered: %d\n", recognitionData->QueryUserID());
		}
	}		
}
		fdata->Release();

Thank you and Happy New Year!

0 Kudos
4 Replies
Linda_M_
Beginner
1,000 Views

Please see the link below which is the forum topic for the same:

https://software.intel.com/en-us/forums/topic/536453

 

 

0 Kudos
tony2
Beginner
1,000 Views

Hi Linda!

I understand the User ID incremental problem, which is described in your link, but the problem posted here is that I cannot register the user to the database... even if I perform RegisterUser() and straight afterwards I perform QueryUserID(), I still get -1 in return. 

Any ideas?

Thanks!

0 Kudos
Colleen_C_Intel
Employee
1,000 Views

Try on demand instead of continuous registration mode.

  •  
0 Kudos
tony2
Beginner
1,000 Views

Thanks Colleen!

I solved the problem: it was simply the mistake that I was creating the database in the  while (AcquireFrame) loop, thus having a new database each frame... 

Thank you!

0 Kudos
Reply