I need to pass the image that comes from the camera through a model with tensorflow, in the _extractFacePixels function the image gets there but the originalImage comes out as null
// Verificar se os bytes estão disponíveis
print('entrou no extract');
if (inputImage.bytes == null) {
print('primeiro if');
throw Exception('No image bytes available.');
}
// Converter os bytes da imagem para uma imagem utilizável pela biblioteca `image`
final img.Image? originalImage = img.decodeImage(Uint8List.fromList(inputImage.bytes!));
if (originalImage == null) {
print('segundo if');
//print(inputImage.bytes);
print('Tamanho dos bytes da imagem: ${inputImage.bytes!.length}');
throw Exception('Could not decode image.');
}
// Extrair a região do rosto
final faceBoundingBox = face.boundingBox;
final faceRegion = img.copyCrop(
originalImage,
faceBoundingBox.left.toInt(),
faceBoundingBox.top.toInt(),
faceBoundingBox.width.toInt(),
faceBoundingBox.height.toInt(),
);
// Redimensionar para 128x128 pixels
final resizedFace = img.copyResize(
faceRegion,
width: 128,
height: 128,
);
// Normalizar os valores dos pixels
List<double> normalizedPixels = [];
for (var y = 0; y < resizedFace.height; y++) {
for (var x = 0; x < resizedFace.width; x++) {
final pixel = resizedFace.getPixel(x, y);
final r = img.getRed(pixel) / 255.0;
final g = img.getGreen(pixel) / 255.0;
final b = img.getBlue(pixel) / 255.0;
normalizedPixels.add(r);
normalizedPixels.add(g);
normalizedPixels.add(b);
}
}
return normalizedPixels;
}
How can I resolve this?