LIPSFace™ SDK Developer Guide

Example Code Explanation

We provide the source code of sample app Ni2FaceRecognition in LIPS_Samples/Ni2FaceRecognition/Ni2FaceRecognition.cpp.

  • Initialize SDK and setup video streams

// Initialize SDK
openni::OpenNI::initialize()

// Connect to device
openni::Device devDevice;
devDevice.open(openni::ANY_DEVICE)

// Create video stream for camera preview
openni::VideoStream colorStream;
colorStream.create(devDevice, openni::SENSOR_COLOR)

// Get camera frame, convert to OpenCV format then display.
openni::VideoFrameRef colorFrame;
colorStream.readFrame(&colorFrame)
Mat imgColor( colorFrame.getHeight(), colorFrame.getWidth(), CV_8UC3, ( void* )colorFrame.getData() );
cvtColor( imgColor, imgColor, CV_RGB2BGR );
imshow( "Ni2FaceRecognition", imgColor );
  • Enroll Face

    Use threading when calling below functions. This can keep video stream running

unsigned short int param = 0x0000;
devDevice->setProperty(600, &param, sizeof( unsigned short));
unsigned short int enroll_result;
devDevice->getProperty(LIPS_FACE_REGISTRATION, &enroll_result);
printf("The result of LIPS_FACE_REGISTRATION is 0x%04X\n", enroll_result);
  • Recognize Face

    Use threading when calling below functions. This can keep video stream running

unsigned short param = 0x0000;
devDevice->setProperty(601, &param, sizeof( unsigned short));
unsigned short int recog_result;
devDevice->getProperty(LIPS_FACE_RECOGNITION, &recog_result);
printf("The result of LIPS_FACE_RECOGNITION is 0x%04X\n", recog_result);
  • Delete enrolled Face

    Use threading when calling below functions. This can keep video stream running

unsigned short face_id = 0xFFFF;
devDevice->setProperty(602, &face_id,sizeof( unsigned short));
unsigned short int delete_result;
devDevice->getProperty(LIPS_FACE_DELETE_DATABASE, &delete_result);
printf("The result of LIPS_FACE_DELETE_DATABASE is 0x%04X\n", delete_result);

Appendix

SDK Error Code

Code
Message

0xE001

Face Not Recognize

0xE002

No Face Detect

0xE003

Liveness Fail

0xE004

Mask Fail

0xE005

Liveness Fail

0xE006

Get Feature Fail

0xE00C

Has Shielding Fail

0xE00D

Eye Unclear

0xE00E

Low Confidence Landmark

Function Map to Realsense F455

Last updated