Silent living body detection is the face living body detection capability of Huawei HMS Core machine learning service, that is, without the user's cooperation to make mouth opening, head turning, blinking and other actions, it can capture the face in real time and quickly judge whether it is a living body. The user has convenient use process and better comprehensive experience.
Technical principle
The ability of silent living detection uses RGB camera to distinguish whether the detection object in front of the camera is a real face or a fake face attack such as face remake picture, face remake screen, face mask and so on. At the same time, the in vivo data of silent in vivo detection capability covers scenes such as lighting, facial accessories, gender, hairstyle and mask material, analyzes the macro environment of human face, and eliminates scenes where it is obviously impossible to have human face.
At the same time, the linear calculation of the model is transformed into a single convolution or full connection module in the reasoning stage through the idea of heavy parameterization. The deployment of the model adopts mindspore Lite reasoning framework to cut the operator to achieve the ultimate package size, which is more conducive to developers' integrated application.
Application scenario
In vivo detection technology is usually applied before face comparison technology. For example, when the face recognition mobile phone is unlocked, it is necessary to first judge whether the face in front of the machine is a real face or a false face through the in vivo detection technology, and then compare whether the current face is the same as the face entered by the system, so as to prevent someone from impersonating the party to unlock the mobile phone in the absence of the party, Causing serious losses such as personal information disclosure.
So, how can we integrate the ability of silent in vivo detection?
Integration steps
1. Development preparation
For detailed steps, please refer to the application development introduction on the official website of Huawei developer Alliance: https://developer.huawei.com/...
There are two calling methods for silent living body detection. You can choose the corresponding calling method to build living body detection service according to your needs.
2. Default scanning interface
2.1 create a silent living body test result callback to obtain the test results.
private MLLivenessCapture.Callback callback = new MLLivenessCapture.Callback() { @Override public void onSuccess(MLLivenessCaptureResult result) { // The processing logic of successful detection, and the detection result may be living or non living. } @Override public void onFailure(int errorCode) { // The detection is not completed, such as camera abnormality_ Error, add failed processing logic. } };
2.2 create a silent living body detection instance and start the detection.
MLLivenessCapture capture = MLLivenessCapture. getInstance(); capture.startDetect(activity, callback);
3. User defined scanning interface
3.1 create MLLivenessDetectView and load it into the Activity layout.
- 1. Bind the camera preview interface and set the living body recognition area.
In the camera preview stream, the silent living body detection will judge whether the face is in the middle of the image. In order to improve the passing rate of the living body, it is recommended that the face frame be placed in the middle of the screen, and the living body recognition area is slightly larger than the drawn face frame.
- II. Set whether to detect the mask.
- 3. Set the result callback.
- 4. Load MLLivenessDetectView into Activity.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_liveness_custom_detection); mPreviewContainer = findViewById(R.id.surface_layout); // ObtainLLivenessDetectView mlLivenessDetectView = new MLLivenessDetectView.Builder() .setContext(this) //Set whether to detect mask .setOptions(MLLiveness DetectView.DETECT_MASK) //Set Rect of face frame relative to MLLivenessDetectView .setFaceRect(new Rect(0, 0, 0, 200)) //Set result callback .setDetectCallback(new OnMLLivenessDetectCallback() { @Override public void onCompleted(MLLivenessCaptureResult result) { // Result callback when silent vivisection is completed } @Override public void onError(int error) { // Error code callback when an error occurs in vivo detection } @Override public void onInfo(int infoCode, Bundle bundle) { // Silent living body detection prompt information callback, which can be used for interface prompt // if(infoCode==MLLivenessDetectInfo.NO_FACE_WAS_DETECTED){ // No face is currently detected // } // ... } @Override public void onStateChange(int state, Bundle bundle) { // Silent living detection state switching callback // if(state==MLLivenessDetectStates.START_DETECT_FACE){ // Start face detection // } // ... } }).build(); mPreviewContainer.addView(mlInteractiveLivenessDetectView); mlInteractiveLivenessDetectView.onCreate(savedInstanceState); }
4. Set life process monitoring for MLLivenessDetectView.
@Override protected void onDestroy() { super.onDestroy(); mlLivenessDetectView.onDestroy(); } @Override protected void onPause() { super.onPause(); mlLivenessDetectView.onPause(); } @Override protected void onResume() { super.onResume(); mlLivenessDetectView.onResume(); } @Override protected void onStart() { super.onStart(); mlLivenessDetectView.onStart(); } @Override protected void onStop() { super.onStop(); mlLivenessDetectView.onStop(); }
For more information about machine learning services, please visit Official website of Huawei developer Alliance.
If you encounter problems when integrating SDK or applying to Huawei's application market, you can Online bill of lading.
Learn more > >
visit Official website of Huawei developer Alliance
obtain Development guidance document
Huawei mobile service open source warehouse address: GitHub,Gitee
Follow us and learn the latest technical information of HMS Core at the first time~