detectFaceForMatch method
Implementation
Future<List<FaceMatch>> detectFaceForMatch(
CameraImage image, List<FaceTemplate> templates) async {
List<int> strides = Int32List(image.planes.length * 2);
int index = 0;
final bytes = image.planes.map((plane) {
strides[index] = (plane.bytesPerRow);
index++;
strides[index] = (plane.bytesPerPixel)!;
index++;
return plane.bytes;
}).toList();
var ids = templates.map((e) => e.id).toList();
var eyes = templates.map((e) => e.eye).toList();
var faces = templates.map((e) => e.face).toList();
var data =
await platform.invokeMethod<List<Object?>>("detectFaceForMatch", {
'platforms': bytes,
'height': image.height,
'width': image.width,
'strides': strides,
'ids': ids,
'eyes': eyes,
'faces': faces,
});
var result = <FaceMatch>[];
if (data == null) {
return result;
}
for (var d in data) {
var items = d.toString().split('(,)');
result.add(FaceMatch(
id: items[0],
similarityEye: double.parse(items[1]),
similarityFace: double.parse(items[2]),
position: FacePosition(
x: int.parse(items[3]),
y: int.parse(items[4]),
width: int.parse(items[5]))));
}
return result;
}