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());