Windows QuickStart

Windows platform provides sample demos in C++ and Java. The sample file path is sdk\samples. Sample currently does not support Windows XP operating system. As the sample uses C++11 standard code, it is recommended to use Visual Studio 2012 version and above.

Note:Sample is only used to assist customers in understanding how to use the SDK interface, test basic functions and provide sample code. During actual development, customers can reference the code, change the sample code or rewrite the entire code.

C++ sample demo

1. Install or compile OpenCV library

Note:SDK itself does not rely on OpenCV. OpenCV is only used for sample demonstrations. Sample requires OpenCV 3.2 version library to operate.

a) Download OpenCV

From the OpenCV official website, download windows 3.2.0 version of OpenCV, download link

b) Extract installation files

After the download is completed, open the file and select a directory to install. The program will allow you to choose which file path to extract the OpenCV folder. For example, to extract to E drive, the file path is E:\opencv.

c) Add environment variables

Add OpenCV library file path to system environment variables and execute the following steps:

1) Right click My Computer --> Properties

2) Advanced System Settings

3) Advanced -> Environment Variable

4) Add Path Environment Variable:

d) Compile 32 bit OpenCV library

As OpenCV 3.2.0 version exe installation package only provides 64 bit version library, it is required to use OpenCV source code to compile 32 bit version OpenCV library. please refer to the compilation steps in the link (It is recommended to use source code compilation for 64 bit OpenCV library as well.)

2. C++ sample test configuration

SDK package provides Visual Studio test program. As the sample uses C++11 standard code, it is recommended to use Visual Studio 2012 version and above. Using sample_face_detect_1vs1 as example, test program configuration steps are as follows:

a) Open test program

Open Visual Studio 2012 version and above, select Tools --> Files --> Open --> Item\Solution, select sdk\samples\c++\sample_face_detect_1vs1\sample_face_detect_1vs1.vcxproj and click Open.

b) Header file and library directory configuration

Edit the Include Directories and Library Directories sequentially. Operating procedure: Solution Plan Resource Manager --> select Project --> right click on Properties --> VC++ Directory --> Include Directories\Library Directories.

Select the down arrow in Include Directories or Library Directories --> Edit.

Step 1 Add SDK Header file directory. Can use corresponding file path, for example: ../and../../../include;

Step 2 Add OpenCV header file directory. At this point, please make sure to add OpenCV header file directory's actual location. For example: E:\opencv\build\include, E:\opencv\build\include\opencv and E:\opencv\build\include\opencv2.

Step 3 Add SDK library file directory (can use corresponding file path) for example: sdk\libs\windows-x86_64 (in 32 bit system please select windows-x86);

Step 4 Add OpenCV library file directory: for example: E:\opencv\build\x64\vc14\lib.

c) Add SDK and OpenCV library file dependencies

Operating procedure: Solution Explorer --> select Project --> right click on Properties --> Linker --> Enter --> Additional Dependencies.

  • SDK library files

Add SDK library file, stidface_professional.lib.

  • OpenCV library files

OpenCV library files: if you are using self-compiled OpenCV library, In Release version, add:

opencv_core320.lib
opencv_highgui320.lib
opencv_imgproc320.lib
opencv_imgcodecs320.lib
opencv_videoio320.lib

In Debug version, add:

opencv_core320d.lib
opencv_highgui320d.lib
opencv_imgproc320d.lib
opencv_imgcodecs320d.lib
opencv_videoio320d.lib
  • Note:When running the program, save the dll library with the same file names as lib files corresponding to OpenCV under exe directory or system directory.

If you are directly using the OpenCV library extracted using exe, then in Debug version and Release version add:

opencv_world320.lib

When running the program save opencv_world320.dll under exe directory or system directory.

d) Build operation

After completing the above configurations, you can build the project. When running the program, you need to save the SDK library file stidface_professional.dll and exe files under the same directory.

e) SDK Authorization configurations

In this sample, you need to save the XXXXXX.lic authorization file into the license_filepath set in the sample configuration file (XXXXX.ini). When running the sample, the SDK authorization interface will load the authorization file XXX.lic in this file path. The authorization interface must be executed successfully first before any other interfaces can be used.

Special note: When running the sample, if the license file has been changed, please delete the senseid_facepro_sn folder (this folder corresponds to the activation_code_dir directory in the configuration file XXX.ini and can be customized) as well as all the activation code files in the folder. This is because the lic files and activation code files corresponds to each other.

Please reference the Authorization Interface Guide for authorization interface definitions. The sample below shows typical workflows for online activated license:

  1. stid_face_professional_online_activate_license to load provided license content.

  2. stid_face_professional_online_activate_license to connect to the web-activated license.

  3. stid_face_professional_online_activate_license to output the newly-activated license content.

  4. stid_face_professional_load_license_content to load new license content.

  5. stid_face_professional_load_license_content to return to STID_OK and confirm successful authentication.

  6. stid_license_release_content to release the license content and end the workflow.

To execute parameters, please reference the third section in this sample documentation - 'Introduction to Sample Functions and Test Walkthrough'.

Java sample demo

1.Install Java SDK and configure environment variables.

2.Compile and install OpenCV Java library and jar file.

a) Download OpenCV

From the official website, download Windows 3.2.0 version of OpenCV, download link.

b) Extract installation files

After the download is completed, open the file and select a directory to install. The program will extract the OpenCV folder to the directory you selected. For example, to extract to E drive, the file path is E:\opencv.

c) Copy OpenCV java library to system directory

For 32 bit system, copy E:\opencv\build\java\x86\opencv_java320.dll to C:\windows\system32. For 64 bit system, you need to copy twice: Copy E:\opencv\build\java\x86\opencv_java320.dll to C:\windows\syswow64, at the same time copy E:\opencv\build\java\x64\opencv_java320.dll to C:\windows\system32.

3.Java sample test configuration

SDK package provides eclipse test program. Using Detect_OneVSOne as example, the test program steps are as follow:

a) Import test program

Open eclipse, choose Tools -> File -> Import; select “General” -> “Existing Projects Into Workspace”, click Next; select “Select Root Directory” -> ”Browse..”, select Java sample in SDK file directory:SDK \samples\java\java_samples\Detect_OneVSOne and click confirm.

b) Configure the test program

(1) Configure JRE System Library

Right click demo project name --> Properties -> Java Build Path -> Libraries, select all options, right click on "Remove"; right click on "Add Library", a dialog box will pop up, select "JRE System Library", click below "Next"; select "Workspace default JRE", click "Finish".

(2) Add jar files required for test program

When testing java sample, you need to first download and parse out the jar file gson-2.3.1.jar in json file, download link.

Right click on Demo Project Name -> Properties -> Java Build Path -> Libraries -> Add External JARs...;

Select the jar file under OpenCV installation directory: opencv\build\java\opencv-320.jar;

Select jar file under sdk directory: sdk\samples\java\StidFaceProfessional.jar, and parse out the jar file gson-2.3.1.jar in json file;

Click below "Apply and Close".

(3) Copy SDK library to system directory

When running a sample, you need to copy sdk\libs\windows-x86_64(windows-x86)\stidface_professional.dll和samples\java\jni_libs\x86(x86_64)\jni_facepro.dll to windows system directory:

For 32 bit system, copy to C:\windows\system32.

For 64 bit system, you need to copy twice (stidface_professional.dll和jni_facepro.dll): Copy 32 bit library to C:\windows\syswow64,at the same time copy 64 bit library to C:\windows\system32;

(4) After completing the above configurations you can build the project. To execute parameters, please reference the third section in this sample documentation - 'Introduction to Sample Functions and Test Walkthrough'.

c) SDK Authorization configurations

In this sample, you need to save the XXXXXX.lic authorization file into the license_filepath set in the sample configuration file (XXXXX.ini). When running the sample, the SDK authorization interface will load the authorization file XXX.lic in this file path. The authorization interface must be executed successfully first before any other interfaces can be used.

Special note: When running the sample, if the license file has been changed, please delete the senseid_facepro_sn folder (this folder corresponds to the activation_code_dir directory in the configuration file XXX.ini and can be customized) as well as all the activation code files in the folder. This is because the lic files and activation code files corresponds to each other.

Please reference the Authorization Interface Guide for authorization interface definitions. The sample below shows typical workflows for online activated license:

  1. stid_face_professional_online_activate_license to load provided license content.

  2. stid_face_professional_online_activate_license to connect to the web-activated license.

  3. stid_face_professional_online_activate_license to output the newly-activated license content.

  4. stid_face_professional_load_license_content to load new license content.

  5. stid_face_professional_load_license_content to return to STID_OK and confirm successful authentication.

  6. stid_license_release_content to release the license content and end the workflow.

Introduction to Sample Functions and Parameters

Note: 1. Parameters can be classified into command type parameters and parameters in configuration files. Command type parameters provide the required parameters for specially-defined functions in sample; parameters in configuration files provide the basic configurations in various samples such as authorization file paths and model file paths. 2.When executing a sample, if the license files have been changed, please delete the senseid_facepro_sn folder as well as all the activation files within the folder.

a) sample_face_detect_1vs1 (corresponds to java sample with same function named Detect_OneVSOne)

1).Functions

Verify configuration instruction set, face test, facial feature extraction and face comparison functions.

2).Executing parameters

i).Command line:

[ini file path] [image A path] [image B path] ([image face orientation])

-ini file path: Configure file path

-image A path: File path of image A

-image B path: File path of image A

-image face orientation: Enable selection of parameters and input of face orientation in photos (by default it detects two photos with the same orientation). 0 represents up, 1 represents left, 2 represents right, 3 represents down; if no parameters exists, then it represents up orientation.

ii).Configuration files:

license_filepath: Authorization files

activation_code_dir: File path where the activation code is saved

alignment_model_filepath: Face test model file path

verify_model_filepath: Facial features extraction model file path

compare_model_filepath: Facial feature comparison model file path

detector_config: Face test model detector configuration: large face mode, small face mode or combination of large and small face mode

alignment_count: (can be selected) Key facial alignment iteration count. Increasing this count can raise the alignment accuracy but will decrease efficiency. Value range (0x1 ~ 0xff)

compare_threshold: Face comparison threshold. If the comparison score exceeds the threshold then evaluate the image as the same person. Value range (0,1)

3).Input and Output:

Input: two sets of photos and photo orientation

Output: Face comparison score and evaluate if the photos show the same person

b).sample_face_extract_image_feature_to_file(corresponding java sample name is ExtractFeature)

1).Functions

Verify face comparison. Facial feature extraction function. Save all the photo features in a particular folder as a json file. Provide face library for use by other face recognition sample.

2).Executing parameters

i).Command line:

[ini file path] [search image dir] [output feature file name] ([image face orientation])

-ini file path: configuration file path

-search image dir: photo folder where facial features for extraction are saved

-output feature file name: json file name for photo features

-image face orientation: Enable selection of parameters and input of face orientation in photos (by default it detects two photos with the same orientation) 0 represents up, 1 represents left, 2 represents right, 3 represents down; if no parameters exists, then it represents up orientation.

ii).Configuration files:

license_filepath: Authorization files

activation_code_dir: File path where the activation code is saved

alignment_model_filepath: Face test model file path

verify_model_filepath: Facial features extraction model file path

detector_config: Face test model detector configuration - large face mode, small face mode or combination of large and small face mode

alignment_count: (can be selected) Key facial alignment iteration count. Increasing this count can raise the alignment accuracy but will decrease efficiency. Value range (0x1 ~ 0xff)

3).Input and Output:

Input: Photo folder file name Output: Folder where photo feature json format files are saved

c).sample_face_singleliveness_1vsN(corresponding java sample name is SinglelivenessOneVSN)

1).Functions

Verify monocular tracking. Frame selection based on facial quality assessment. Monocular face assessment. Facial feature extraction. Facial feature 1vsN search function. Monocular camera liveness check. Comparison with facial feature library. Facial identity recognition simulation.

2).Executing parameters

i).Command line:

[ini file path] [feature file name]

-ini file path: Configuration file path

-feature file name: Facial feature json file name

ii).Configuration files:

license_filepath: Authorization files

activation_code_dir: File path where the activation code is saved

singleliveness_model_filepath: Monocular facial liveness model file path

calcpose_model_filepath: Model for calculation of face orientation

verify_model_filepath: Facial features extraction model file path

compare_model_filepath: Comparison model file path

singleliveness_track_config: Monocular tracking configuration. Only supports large face mode or small face mode.

rgb_camera_index: RGB camera index

camera_face_orientation: Camera and face orientation

hack_threshold: Liveness check threshold. If liveness score exceeds the threshold then evaluate the image as fake. Value range (0,1).

frame_selector_threshold: Face quality assessment configuration settings. Includes face quality and face orientation parameter range. For details of configuration info, please refer to header file and configuration file test.ini.

3).Input and Output

Input: Photo feature json file that provides N-comparison library Output: Returns monocular liveness check score to evaluate if person is real. Based on the comparison score, print out the names of photos with the highest scores compared to the photo being evaluated.

4).Function module designation:

In the sample, you can designate function modules: 1. Frame selection: Face quality assessment and face orientation calculation. 2. Frame selection + liveness check function. 3. Frame selection + liveness check + 1vsN search function.

i).C++ sample:

Use macro definition to open different function modules. Frame selection: open macro TRACK_FRAMESELECTOR.

Frame selection + liveness check: open macro TRACK_FRAMESELECTOR and macro TRACK_FRAMESELECTOR_LIVENESS.

Frame selection + liveness check + 1vsN search: open macro TRACK_FRAMESELECTOR, macro TRACK_FRAMESELECTOR_LIVENESS, macro TRACK_FRAMESELECTOR_LIVENESS_1VSN.

ii).Java sample:

Use static variable definition to open different function modules. Frame selection: TRACK_FRAMESELECTOR set as 1.

Frame selection + liveness check: TRACK_FRAMESELECTOR set as 1. TRACK_FRAMESELECTOR_SINGLELIVENESS set as TRACK_FRAMESELECTOR & 1.

Frame selection + liveness check + 1vsN search: TRACK_FRAMESELECTOR set as 1, TRACK_FRAMESELECTOR_SINGLELIVENESS set as TRACK_FRAMESELECTOR & 1;TRACK_FRAMESELECTOR_SINGLELIVENESS_1VSN set as TRACK_FRAMESELECTOR_SINGLELIVENESS & 1;

d).sample_face_binocularliveness_1vsN(corresponding java sample name is BinocularlivenessOneVSN)

1).Functions

Verify binocular tracking. Frame selection based on facial quality assessment. Binocular face assessment. Facial feature extraction. Facial feature 1vsN search function. Binocular camera liveness check. Comparison with facial feature library. Facial identity recognition simulation.

2).Executing parameters

i).Command line:

[ini file path] [feature file name]

-ini file path: Configuration file path

-feature file name: Facial feature json file name

ii).Configuration files:

license_filepath: Authorization files

activation_code_dir: File path where the activation code is saved

binocularliveness_model_filepath: Binocular liveness check model file path

calcpose_model_filepath: Model for calculation of face orientation

verify_model_filepath: Facial features extraction model file path

compare_model_filepath: Comparison model filepath

binocularliveness_track_config: Binocular tracking configuration. Only support large face model or small face model.

rgb_camera_index: RGB camera index

infrared_camera_index: Infrared camera index

camera_face_orientation: Camera and face orientation

hack_threshold: Liveness check threshold. If liveness score exceeds the threshold then evaluate the image as fake. Value range (0,1)

frame_selector_threshold: Face quality assessment configuration settings. Includes face quality and face orientation parameter range. For details of configuration info, please refer to header file and configuration file test.ini.

3).Input and Output:

4).Function module designation:

In the sample, you can designate function modules: 1. Frame selection: Face quality assessment and face orientation calculation. 2. Frame selection + liveness check function. 3. Frame selection + liveness check + 1vsN search function.

i).C++ sample:

Use macro definition to open different function modules. Frame selection: open macro TRACK_FRAMESELECTOR.

Frame selection + liveness check: open macro TRACK_FRAMESELECTOR and macro TRACK_FRAMESELECTOR_LIVENESS.

Frame selection + liveness check + 1vsN search: open macro TRACK_FRAMESELECTOR, macro TRACK_FRAMESELECTOR_LIVENESS, macro TRACK_FRAMESELECTOR_LIVENESS_1VSN.

ii).Java sample:

Use static variable definition to open different function modules. Frame selection: TRACK_FRAMESELECTOR set as 1.

Frame selection + liveness check: TRACK_FRAMESELECTOR set as 1, TRACK_FRAMESELECTOR_BINOCULARLIVENESS set as TRACK_FRAMESELECTOR & 1.

Frame selection + liveness check+ 1vsN search: TRACK_FRAMESELECTOR set as 1, TRACK_FRAMESELECTOR_BINOCULARLIVENESS set as TRACK_FRAMESELECTOR & 1;TRACK_FRAMESELECTOR_BINOCULARLIVENESS_1VSN set as TRACK_FRAMESELECTOR_BINOCULARLIVENESS & 1;

Note: It is recommended to use notepad++ to edit ini configuration files and save as utf-8 code format.

Last updated