Android Arcface 2.0 Face Recognition Registration Failure

Keywords: SDK

Face recognition requires init initialization (in FaceServer) and unInit destruction when leaving; when an interface A containing face recognition jumps to another interface B containing face recognition, both initialization and destruction are synchronized (this) {} to the FaceServer class, causing registration to fail or registration to fail again.

In the FaceServer class:
Initialization:

public boolean init(Context context) {
        synchronized (this) {
            if (faceEngine == null && context != null) {
                faceEngine = new FaceEngine();
                int engineCode = faceEngine.init(context, FaceEngine.ASF_DETECT_MODE_IMAGE, FaceEngine.ASF_OP_0_HIGHER_EXT, 16, 1, FaceEngine.ASF_FACE_RECOGNITION | FaceEngine.ASF_FACE_DETECT);
                if (engineCode == ErrorInfo.MOK) {
                    initFaceList(context);
                    return true;
                } else {
                    faceEngine = null;
                    Log.e(TAG, "init: failed! code = " + engineCode);
                    return false;
                }
            }
            return false;
        }
    }

Destroy:

public void unInit() {
        synchronized (this) {
            if (faceRegisterInfoList != null) {
                faceRegisterInfoList.clear();
                faceRegisterInfoList = null;
            }
            if (faceEngine != null) {
                faceEngine.unInit();
                faceEngine = null;
            }
        }
    }

Both face recognition interfaces use the same FaceServer class, and synchronized results in new threads having to wait if other threads currently hold the lock, so

(1) Logging off A (uninit) after A jumps to B will cause the faceEngine object to exist at the time of initialization (init) in B, and then deleting the faceEngine object when A is logged off, which will cause face registration to fail.
SDK download address https://ai.arcsoft.com.cn/ucenter/user/reg?Utm_source=csdn1&utm_medium=referral

Posted by webster08 on Thu, 07 Nov 2019 11:18:05 -0800