Mastering Development

Show a Camera Activity which runs tflite on image frames in a flutter app

I have an android app having a CameraActivity which runs a tflite classifier periodically on image frames from the preview stream. The implementation of the Camera and tflite works great in the Android part and gives a good FPS.

I want to show this CameraActivity in my Flutter App as a Screen. The Flutter app has all the Frontend and UI part implemented already.

I’ve already tried using the official Flutter Camera plugin to implement the same by using camera.startImageStream but was unable to get matching FPS and the Camera Preview lags when calling the tflite model asynchronously using methodChannel.

I also came across AndroidView which embeds an Android view in the Widget hierarchy but the docs say it is an expensive operation and should be avoided when a Flutter equivalent is possible.

Is there a way to write a plugin for showing the CameraActivity (i.e. the UI) on the Flutter end similar to the way methodChannel is used for exchanging data between the Flutter and the Native codes. Or if there’s another possible way of achieving this, please let me know.

Thanks in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *