|
|
@ -16,7 +16,7 @@ Future<Uint8List> convertImage(CameraImage image) async { |
|
|
|
} else if (image.format.group == ImageFormatGroup.bgra8888) { |
|
|
|
} else if (image.format.group == ImageFormatGroup.bgra8888) { |
|
|
|
img = convertBGRA8888(image); |
|
|
|
img = convertBGRA8888(image); |
|
|
|
} |
|
|
|
} |
|
|
|
return img.toUint8List(); |
|
|
|
return img.getBytes(format: imglib.Format.luminance); //.toUint8List(); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
debugPrint('>>>>>>>>>>>> ERROR: $e'); |
|
|
|
debugPrint('>>>>>>>>>>>> ERROR: $e'); |
|
|
|
} |
|
|
|
} |
|
|
@ -25,10 +25,10 @@ Future<Uint8List> convertImage(CameraImage image) async { |
|
|
|
|
|
|
|
|
|
|
|
imglib.Image convertBGRA8888(CameraImage image) { |
|
|
|
imglib.Image convertBGRA8888(CameraImage image) { |
|
|
|
return imglib.Image.fromBytes( |
|
|
|
return imglib.Image.fromBytes( |
|
|
|
width: image.width, |
|
|
|
image.width, |
|
|
|
height: image.height, |
|
|
|
image.height, |
|
|
|
bytes: image.planes[0].bytes.buffer, |
|
|
|
image.planes[0].bytes, |
|
|
|
// format: imglib.Format.bgra, |
|
|
|
format: imglib.Format.bgra, |
|
|
|
// format: imglib.Format.int8, |
|
|
|
// format: imglib.Format.int8, |
|
|
|
// order: imglib.ChannelOrder.bgra, |
|
|
|
// order: imglib.ChannelOrder.bgra, |
|
|
|
); |
|
|
|
); |
|
|
@ -85,10 +85,11 @@ imglib.Image resizeToMaxSize(imglib.Image image, int? maxSize) { |
|
|
|
|
|
|
|
|
|
|
|
// get the bytes of the image in grayscale format (luminance) like v3 |
|
|
|
// get the bytes of the image in grayscale format (luminance) like v3 |
|
|
|
Uint8List grayscaleBytes(imglib.Image image) { |
|
|
|
Uint8List grayscaleBytes(imglib.Image image) { |
|
|
|
final imglib.Image imgRgba8 = image.convert( |
|
|
|
return image.getBytes(format: imglib.Format.luminance); |
|
|
|
format: imglib.Format.uint8, |
|
|
|
// final imglib.Image imgRgba8 = image.convert( |
|
|
|
numChannels: 1, |
|
|
|
// format: imglib.Format.uint8, |
|
|
|
); // Make sure it's an RGBA 32-bit image like v3 |
|
|
|
// numChannels: 1, |
|
|
|
imglib.grayscale(imgRgba8); // map the pixels to grayscale (luminance) |
|
|
|
// ); // Make sure it's an RGBA 32-bit image like v3 |
|
|
|
return imgRgba8.getBytes(); |
|
|
|
// imglib.grayscale(imgRgba8); // map the pixels to grayscale (luminance) |
|
|
|
|
|
|
|
// return imgRgba8.getBytes(); |
|
|
|
} |
|
|
|
} |
|
|
|