flutter-ml / google_ml_kit_flutter

A flutter plugin that implements Google's standalone ML Kit
MIT License
930 stars 707 forks source link

How to convert nv21 CameraImage to Flutter Image #543

Closed albertowao closed 10 months ago

albertowao commented 10 months ago

I can not find a way to convert nv21 frames in the flutter image format ( package:image/src/image.dart )

The Face Detection Package requires to use nv21 format in the CameraController on Android and i need to return the frame with the face detected with face detection package ( a CameraImage object ) but I couldn't find a conversion function from nv21 to flutter format anywhere

i found it for YUV420 and bgra8888, but not nv21

Do you have an example to show?

Thanks!

fbernaly commented 10 months ago

Example is here:

https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/example

this is how you configure your CameraController:

https://github.com/flutter-ml/google_ml_kit_flutter/blob/master/packages/example/lib/vision_detector_views/camera_view.dart#L260-L268

All of this is in the README:

https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/google_mlkit_commons#creating-an-inputimage