Live image processing using flutter

491

Since flutter is kinda new, it still doesn't have a fixed way to perform real-time image processing. IF you just need to use the firebase ML vision you can go with this plugin: https://pub.dev/packages/firebase_livestream_ml_vision

However, if you need something more specific, I suggest you to use a method channel and run some platform-specific code. In particular, if you are developing for android, I suggest you give a look at the CameraX library.

I give you an example of how I used it to retrieve a barcode

void _launchCameraX(BuildContext context) async {
    String result = await MethodChannel("CAMERA_X").invokeMethod('SCAN');
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => NewPage(result),
      ),
 );

In android Main activity:

 private final static String CAMERA_X_CHANNEL = "CAMERA_X";

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getComponents();
        setUpResultsHandlers();
        new MethodChannel(getFlutterView(), CAMERA_X_CHANNEL).setMethodCallHandler((call, result) -> {
            if (call.method.equals(SCAN_METHOD)) {
                Intent intent = new Intent(this, ScannerActivity.class);
                this.result = result;
                startActivityForResult(intent, qrRequestCode);
            }
        });
        GeneratedPluginRegistrant.registerWith(this);
    }

//AND then I used camera X

Share:
491
ruuuyin
Author by

ruuuyin

Updated on December 26, 2022

Comments

  • ruuuyin
    ruuuyin over 1 year

    I have project where I am going to develop an application using Flutter. The app requires face recognition and live image processing. It is similar to Instagram story where the app can modify the image live such as changing the background or overlaying some text etc.

    I just want to ask if there is a way to do that? Or if there is, what are the things that I can use (libraries, guides or prerequisites) to develop such app. I already search on google but I got only few results and they are all a little bit overwhelming for me or hard to understand.

  • AndreaCostanzo1
    AndreaCostanzo1 over 3 years
    If you want to see how I implemented it just look at this class and the related reference in android of this repo: github.com/AndreaCostanzo1/FlutterApp/blob/master/android/ap‌​p/…
  • ruuuyin
    ruuuyin over 3 years
    Hello! thank you for your response. I'm gonna give it a shot.