Creating InputImageData from Uint8List or Image Object For Google ML Kit Face Detection

Viewed 94

Ho do we create an InputImage if all we have is Uint8List or Image object? How do we create the Plane object needed to initialize the InputImageData?

//imageFile is an XFile dataType (From Camera Package) 

Uint8List imageData = await imageFile.readAsBytes();

The link below from the Google ML Kit GitHub page doesn't describe how we can create an Input Image if we only have Uint8List object.

CREATING INPUT IMAGE

1 Answers

What you have named "imageData" in your code is not actually an ImageData. It's a list of bytes. You say that you got this list of bytes this way:

//imageFile is an XFile dataType (From Camera Package) 

Uint8List imageData = await imageFile.readAsBytes();

So clearly, you have an XFile that you have called "imageFile".

On this page, from your package:

https://github.com/bharat-biradar/Google-Ml-Kit-plugin/blob/master/packages/google_ml_kit/example/lib/vision_detector_views/camera_view.dart

you find, for example:

final path = pickedFile?.path;  // Where pickedFile is an XFile, like your imageFile
//...
final inputImage = InputImage.fromFilePath(path);

This should work with your imageFile! If it doesn't, please explain what happens.

PS On the same page, you can also see how to get planeData from a CameraImage... but that's not the same as an XFile, so. It may not be so relevant, to you.

Related