Full working example of YUV to RGB transform in Dart with native code(Java)
Full working example of YUV to RGB conversion in Dart with native code(Java)
Personally, I encountered a problem while making a real time recognition app, using a model i trained with the FastAI library.
Since the library requires an RGBA image type for prediction, and the Camera plugin produces YUV images, i got stuck for a few days searching for efficient conversion solution.
After reading a lot of half working examples of people stuck in the same situation as I, and with a lot of trial and error, I managed to get a decent solution for my purposes.
After trying a few examples, the best solution seemed to be using native code(Java) to convert the image. A MethodChanel is being opened upon page init, allowing a direct connection for transferring the content of the frame forwards and backwards, to and from the conversion function.
The conversion speed depends on the phone itself + the quality you chose for the CameraController.
Here are the results for 2 different physical devices tested:
Redmi Note 4:
Meizu 16:
minSdkVersion XX
to minSdkVersion 21
<uses-permission android:name="android.permission.CAMERA"/>
to the <manifest>
element.<application>
). It should be a direct child of the manifest element.When initializing the "CameraController" object, an enum called "ResolutionPreset" should be passed to define the camera quality.
Those are the values for each entry as shown in the official flutter site..