ARM Linux QuickStart

Note:The sample is only used to help customers understand how to call SDK interface, test basic functions, and to show some sample code. In actual development process, customers can refer to or change the sample code, or rewrite the entire program.

Linux platform provides sample demos written in C ++ and Java. We use Ubuntu system and OpenCV 3.2.0 as an example to show the configuration steps.

Note: SDK itself does not have any dependency on OpenCV library. OpenCV library is only necessary for sample demos and the required library is OpenCV 3.2.0. ARM platform provides a sample demo written in C ++. Linux firefly 3.10.0 ARMv7 system is used as an example to show how to configure and run the sample.

Install OpenCV library

1. Download OpenCV source code

OpenCV 2.4.10 is recommended for ARM platform download link.

2. Install cmake-gui

sudo apt-get install cmake-gui

Run "sudo apt-get update" if necessary.

3. Cross compilation configuration for OpenCV using cmake-gui

a). Open cmake-gui

sudo cmake-gui

b). Set the directories for source code and compiled library

Fill in the path for source code at "Where is the source"; fill in the path for generated make file at "Where to build the binaries", click Configure and select the last option "Specify options for cross-compiling", then click NEXT.

c). Configure cross compilation options

Select the target system of arm-linux using the Operating System option.

By Compilers, select cross compiler gcc and g++. Pay attention to which compilation method is used here and select the correct path for the compilation command accordingly. Find the directory for the installed compiler, for example: C:/usr/bin/arm-linux-gnueabihf-gcc; C++:/usr/bin/arm-linux-gnueabihf-g++.

"Select the header file directory (required for cross compilation) from Target Root in Find Program/Library/Include, press Finish".

d). Modify cmake configuration for compiling OpenCV

After the configuration is complete, a red area will appear, inside this area are the options that can be configured.

Check the options BUILD_JPEG and BUILD_PNG; uncheck WITH_TIFF if tiff is not installed.

Find the CMAKE_INSTALL_PREFIX option, modify the directory to be the same one as filled in by "where to build the binaries" in step b).

Uncheck WITH_CUDA if cuda library is not present in arm system.

Click Configure after configuration, then Generate, a Makefile should be generated in the OpenCV compilation directory.

e). Modify compilation configuration

Go to OpenCV installation directory to modify CMakeCache.txt. Add -lpthread -lrt -ldl to CMAKE_EXE_LINKER_FLAGS and save.

f). Compilation

Run:

make

During compilation, if an error of recompile with -fPIC appears, a corresponding error module should be looked for, such as zlib module. Add -fPIC to the directory of 3rdparty/zlib/CMakeFiles/zlib.dir/flags.make.

If the error cannot be found by multi-thread related functions, then add a head file into the source code modules\ts\src\ts_gtest.cpp:

#include <pthread.h>

g). Installation

Run:

sudo make install

Run C++ sample

Similar to how C++ sample in x86, x64 Linux systems is run:

1. Go to the directory of the sample: sdk\samples\c++_armv7

2. Run make command

3. SDK authorization configuration

Following this sample, the authorization file XXXXXX.lic should be saved in the directory of license_filepath, which is defined in the sample configuration file (XXXXX.ini). When running the sample, the SDK authorization interface will load the authorization file XXX.lic from this directory. The authorization interface must be called successfully before any other algorithm interface is called.

Special note: When running the sample, if the license file is replaced, the senseid_facepro_sn folder needs to be deleted (this folder corresponds to the activation_code_dir folder path inside the configuration file XXX.ini, which can be customized) and its activation file; lic file is corresponding to the activation file.

For the authorization interface definition, please refer to Authorization interface definition. Sample shows a commonly used method to call the online activation version license: 1. From the stid_face_professional_online_activate_license interface, load the license file. 2. From the stid_face_professional_online_activate_license interface, connect to network to activate the license. 3. From the stid_face_professional_online_activate_license interface, output the new license contents after activation. 4. From stid_face_professional_load_license_content interface, load the new license contents. 5. stid_face_professional_load_license_content interface returns STID_OK, authorization authentication process completed successfully. 6. stid_license_release_content releases the activated license contents, end of process.

4. Run sample

There are two ways to run the sample:

1). Run the .sh script corresponding to the sample file, run_sample_face_XXX.sh (sh does not have execute permission, need to run chmod +x to change its permission).

2). Set LD_LIBRARY_PATH to the path of the library folder sdk\libs\linux-x86_64, run test_sample_face_XXX (For example: LD_LIBRARY_PATH=../../libs/linux-x86_64 test_sample_face_XXX [parameters]).

For the parameters, please refer to the third section of this document: Sample function introduction and parameter description.

Sample function introduction and parameter description

Function introduction and parameter description

Note: The parameters include command line parameters and configuration parameters. Command line parameters provide parameters required for specific functions of the sample; configuration parameters provide basic settings for each sample, such as the path to the authorization file and the path to the model file. 2. When running the sample, if the license file is replaced, the senseid_facepro_sn folder needs to be deleted (this folder corresponds to the activation_code_dir folder path inside the configuration file XXX.ini, which can be customized) and its activation file.

a). sample_face_detect_1vs1 (inside the java sample, it is named as Detect_OneVSOne)

1). Functions

Verification setup instruction set, face detection, face feature extraction and face comparison.

2). Parameters

i). Command Line:

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

-ini file path: File path configuration

-image A path: Path to image A

-image B path: Path to image B

-image face orientation: Optional parameter, input the image face orientation (by default, the face orientations of the two images are the same); 0 indicates up, 1 indicates left, 2 indicates right, and 3 indicates down; the default orientation is up

ii). Configuration:

license_filepath: Path to the authorization file

activation_code_dir: Directory name of the activation file

alignment_model_filepath: Path to the face detection model

verify_model_filepath: Path to the face feature extraction model

compare_model_filepath: Path to the face feature comparison model

detector_config: Face detection mode configuration: large face mode, small face mode or large and small face combination mode

alignment_count: (Optional) Number of iterations for the face key points. Increasing the number can improve the accuracy of the key points, however, the efficiency will be decreased. Its value range is (0x1 ~ 0xff)

compare_threshold: Face comparison threshold. When the comparison score is greater than this value, it is considered as the same person

3). Input and output

Input: two images and picture orientation

Output: face comparison score, and whether the images belong to the same person

b). sample_face_extract_image_feature_to_file (inside the java sample, it is named as ExtractFeature)

1). Functions

Face verification comparison and face feature extraction. Save all the image features inside one particular folder into a json file, creating a face database that other face verification samples can also use.

2). Parameters

i). Command Line:

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

-ini file path: File path configuration

-search image dir: Name of the image folder from where the features are to be extracted

-output feature file name: Name of the json fie that saves the image features

-image face orientation: Optional parameter, input the image face orientation (by default, the face orientations of the two images are the same); 0 indicates up, 1 indicates left, 2 indicates right, and 3 indicates down; the default orientation is up.

ii). Configuration:

license_filepath: Path to the authorization file

activation_code_dir: Directory name of the activation file

alignment_model_filepath: Path to the face detection model

verify_model_filepath: Path to the face feature extraction model

detector_config: Face detection mode configuration: large face mode, small face mode or large and small face combination mode

alignment_count: (Optional) Number of iterations for the face key points. Increasing the number can improve the accuracy of the key points, however, the efficiency will be decreased. Its value range is (0x1 ~ 0xff)

3). Input and output:

Input: name of the folder where the images are stored Output: json file, in which the extracted features are saved

c). sample_face_singleliveness_1vsN (inside the java sample, it is named as SinglelivenessOneVSN)

1). Functions

Monocular face tracking verification, image frame selection through face quality detection, monocular face detection, face feature extraction, face feature 1toN search, monocular camera live face detection and detection-database comparison, and simulated face authentication.

2). Parameters

i). Command Line:

[ini file path] [feature file name]

-ini file path: File path configuration

-feature file name: Name of the json fie that saves the image features

ii). Configuration:

license_filepath: Path to the authorization file

activation_code_dir: Directory name of the activation file

singleliveness_model_filepath: Path to monocular face detection model

calcpose_model_filepath: Path to face angle calculation model

verify_model_filepath: Path to face feature extraction model

compare_model_filepath: Path to face feature comparison model

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

rgb_camera_index: Monocular camera index

camera_face_orientation: Camera face orientation

hack_threshold: Liveness detection threshold. When the liveness score is greater than this value, it is considered as a dummy; its value range is (0,1)

frame_selector_threshold: Face quality detection configurations, including parameter ranges for face quality and face angle. For detailed configuration information, please refer to the head file and the configuration file test.ini

3). Input and output:

Input: A json file contains image features, which provides the N-library for comparison Output: Return the monocular detection score and whether the detected image is of a real person; print out the names of the images that have the highest comparison scores

4). Function module specification:

Function modules can be specified in the sample: Image frame selection: face quality detection and face angle calculation; Image frame selection + liveness detection; Image frame selection + liveness detection + 1toN search.

i). C++ sample:

Use macro definitions to turn on different function modules. Frame selection: enable macro TRACK_FRAMESELECTOR.

Frame selection + liveness detection: Enable macro TRACK_FRAMESELECTOR and macro TRACK_FRAMESELECTOR_LIVENESS.

Frame selection + liveness detection + 1toN search: Enable macro TRACK_FRAMESELECTOR, macro TRACK_FRAMESELECTOR_LIVENESS, and macro TRACK_FRAMESELECTOR_LIVENESS_1VSN.

ii).Java sample:

Use static variable definitions to turn on different function modules. Frame selection: Set TRACK_FRAMESELECTOR to 1.

Frame selection + liveness detection: Set TRACK_FRAMESELECTOR to 1, set TRACK_FRAMESELECTOR_SINGLELIVENESS to TRACK_FRAMESELECTOR & 1.

Frame selection + liveness detection + 1toN search: Set TRACK_FRAMESELECTOR to 1, set TRACK_FRAMESELECTOR_SINGLELIVENESS to TRACK_FRAMESELECTOR & 1, and set TRACK_FRAMESELECTOR_SINGLELIVENESS_1VSN to TRACK_FRAMESELECTOR_SINGLELIVENESS & 1;

d). sample_face_binocularliveness_1vsN (inside the java sample, it is named as BinocularlivenessOneVSN)

1). Function

Binocular face tracking verification, image frame selection through face quality detection, binocular face detection, face feature extraction, face feature 1toN search, binocular camera live face detection and detection-database comparison, and simulated face authentication.

2). Parameters

i). Command Line:

[ini file path] [feature file name]

-ini file path: File path configuration.

-feature file name: Name of the json fie that saves the image features.

ii). Configuration:

license_filepath: Path to the authorization file

activation_code_dir: Directory name of the activation file

binocularliveness_model_filepath: Path to binocular face detection model

calcpose_model_filepath: Path to face angle calculation model

verify_model_filepath: Path to face feature extraction model

compare_model_filepath: Path to face feature comparison model

binocularliveness_track_config: Binocular tracking configuration, only supports large face mode or small face mode

rgb_camera_index: Visible light camera index

infrared_camera_index: Infrared camera index

camera_face_orientation: Camera face orientation

hack_threshold: Liveness detection threshold. When the liveness score is greater than this value, it is considered as a dummy; its value range is (0,1).

frame_selector_threshold: Face quality detection configurations, including parameter ranges for face quality and face angle. For detailed configuration information, please refer to the head file and the configuration file test.ini.

3). Input and output:

Input: A json file contains image features, which provides the N library for comparison. Output: Return the binocular detection score and whether the detected image is of a real person; print out the names of the pictures that have the highest comparison scores.

4). Function module specification:

Function modules can be specified in the sample: Image frame selection: face quality detection and face angle calculation; Image frame selection + liveness detection; Image frame selection + liveness detection + 1toN search.

i). C++ sample:

Use macro definitions to turn on different function modules. Frame selection: enable macro TRACK_FRAMESELECTOR.

Frame selection + liveness detection: Enable macro TRACK_FRAMESELECTOR and macro TRACK_FRAMESELECTOR_LIVENESS.

Frame selection + liveness detection + 1toN search: Enable macro TRACK_FRAMESELECTOR, macro TRACK_FRAMESELECTOR_LIVENESS, and macro TRACK_FRAMESELECTOR_LIVENESS_1VSN.

ii). Java sample:

Use static variable definitions to turn on different function modules. Frame selection: Set TRACK_FRAMESELECTOR to 1.

Frame selection + liveness detection: Set TRACK_FRAMESELECTOR to 1, set TRACK_FRAMESELECTOR_BINOCULARLIVENESS to TRACK_FRAMESELECTOR & 1.

Frame selection + liveness detection + 1toN search: Set TRACK_FRAMESELECTOR to 1, set TRACK_FRAMESELECTOR_BINOCULARLIVENESS to TRACK_FRAMESELECTOR & 1, and set TRACK_FRAMESELECTOR_BINOCULARLIVENESS_1VSN to TRACK_FRAMESELECTOR_BINOCULARLIVENESS & 1;

Note: notepad++ is recommended for the modification of the ini configuration file; and the file should be saved in UTF-8 encoding format.

Last updated