cutFaceFromCameraImage function
Cuts out the face from the CameraImage
Implementation
Image cutFaceFromCameraImage(CameraImage image, Rectangle rect) {
final imglib.Image img1 = convertCameraImageToImageColor(image);
final imglib.Image img2 = cutFaceFromImage(img1, rect);
imglib.PngEncoder pngEncoder = new imglib.PngEncoder(level: 0);
late List<int> png;
if (image.format.group == ImageFormatGroup.yuv420) {
png = pngEncoder.encode(imglib.copyRotate(img2, angle: -90));
} else {
png = pngEncoder.encode(img2);
}
return Image.memory((png as Uint8List));
}