FaceDetector faceDetector = new FaceDetector(this);
Frame frame = new Frame();
frame.setBitmap(bitmap);
JSONObject jsonObject = faceDetector.detect(frame,null);
{
"resultCode": 0,
"faces": [{
"faceRect":
{
"height": 206,
"left": 587,
"top": 85,
"width": 171
},
"id": 0,
"landmarks": [{
"position": {
"x": 636,
"y": 187
},
"type": 0
}, {
"position":
{
"x": 705,
"y": 168
},
"type": 1
}, {
"position":
{
"x": 683,
"y": 222
},
"type": 2
}, {
"position":
{
"x": 655,
"y": 240
},
"type": 3
}, {
"position":
{
"x": 716,
"y": 226
},
"type": 4
}],
"pitch": -25.060776,
"probability":
0.9999994,
"roll": 15.092653,
"yaw": 1.7165642
},
{
"faceRect": {
"height": 201,
"left":
79,
"top": 189,
"width": 168
},
"id": 1,
"landmarks":
[{
"position": {
"x": 142,
"y": 280
},
"type": 0
},
{
"position": {
"x": 203,
"y": 261
},
"type": 1
},
{
"position": {
"x": 188,
"y": 308
},
"type": 2
},
{
"position": {
"x": 152,
"y": 335
},
"type": 3
},
{
"position": {
"x": 207,
"y": 319
},
"type": 4
}
],
"pitch": -19.327066,
"probability"
: 0.99999964,
"roll": 16.324646,
"yaw": -21.680126
}
]
}
可以的,在faceCompare()方法中会默认启动引擎,如果引擎已经启动则不会再次启动,开发者可以放心使用。
release()方法会卸载在NPU芯片中已经加载的模型,请在应用不再使用人脸检测时及时卸载模型,释放资源。