FaceAttributesDetector faceAttributes = new FaceAttributesDetector(mContext);
Frame frame = new Frame();
frame.setBitmap(mBitmap);
JSONObject jsonObject = faceAttributes.detectFaceAttributes(frame, null);
FaceAttributesInfo result = faceAttributes.convertResult(jsonObject);
{
"resultCode":0,
"face_attributes":"{
\"sex\":\"female\"
}"
}
可以的,在faceCompare()方法中会默认启动引擎,如果引擎已经启动则不会再次启动,开发者可以放心使用。
release()方法会卸载在NPU芯片中已经加载的模型,请在应用不再使用人脸属性时及时卸载模型,释放资源。