AFR_FSDKInterface engine = new AFR_FSDKEngine(); //用來存放提取到的人臉信息, face_1 是註冊的人臉,face_2 是要識別的人臉 AFR_FSDKFace face1 = new AFR_FSDKFace(); AFR_FSDKFace face2 = new AFR_FSDKFace(); //初始化人臉識別引擎,使用時請替換申請的 APPID 和 SDKKEY AFR_FSDKError error = engine.AFR_FSDK_InitialEngine("APPID", "SDKKEY"); Log.d("com.arcsoft", "AFR_FSDK_InitialEngine = " + error.getCode()); //輸入的 data 數據爲 NV21 格式(如 Camera 裏 NV21 格式的 preview 數據);人臉座標通常使用人臉檢測返回的 Rect 傳入;人臉角度請按照人臉檢測引擎返回的值傳入。 error = engine.AFR_FSDK_ExtractFRFeature(data1, width, height, AFR_FSDKEngine.CP_PAF_NV21, new Rect(210, 178, 478, 446), AFR_FSDKEngine.AFR_FOC_0, face1); Log.d("com.arcsoft", "Face=" + face1.getFeatureData()[0]+ "," + face1.getFeatureData()[1] + "," + face1.getFeatureData()[2] + "," + error.getCode()); error = engine.AFR_FSDK_ExtractFRFeature(data1, width, height, AFR_FSDKEngine.CP_PAF_NV21, new Rect(210, 170, 470, 440), AFR_FSDKEngine.AFR_FOC_0, face2); Log.d("com.arcsoft", "Face=" + face2.getFeatureData()[0]+ "," + face2.getFeatureData()[1] + "," + face2.getFeatureData()[2] + "," + error.getCode()); //score 用於存放人臉對比的類似度值 AFR_FSDKMatching score = new AFR_FSDKMatching(); error = engine.AFR_FSDK_FacePairMatching(face1, face2, score); Log.d("com.arcsoft", "AFR_FSDK_FacePairMatching=" + error.getCode()); Log.d("com.arcsoft", "Score:" + score.getScore()); //銷燬人臉識別引擎 error = engine.AFR_FSDK_UninitialEngine(); Log.d("com.arcsoft", "AFR_FSDK_UninitialEngine : " + error.getCode());