GithubHelp home page GithubHelp logo

robinj0726 / flutter_native_opencv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from westracer/flutter_native_opencv

0.0 0.0 0.0 216 KB

Using OpenCV natively in C++ in a Flutter app with Dart FFI

Home Page: https://medium.com/flutter-community/integrating-c-library-in-a-flutter-app-using-dart-ffi-38a15e16bc14

License: MIT License

Java 3.36% Ruby 7.31% Swift 3.68% Objective-C 1.02% Dart 11.98% CMake 25.62% C++ 40.88% Shell 1.43% C 3.83% PowerShell 0.90%

flutter_native_opencv's Introduction

flutter_native_opencv

Using OpenCV natively in C++ in a Flutter app with Dart FFI. Tested with Flutter 2.5.2.

Read the full articles:

How to build & run

Android and iOS

Run init.sh script from a scripts folder or do the following steps manually:

  1. Download OpenCV for Android and iOS: https://opencv.org/releases/
  2. Copy or create symlinks:
    • opencv2.framework to native_opencv/ios
    • OpenCV-android-sdk/sdk/native/jni/include to native_opencv
    • Contents of OpenCV-android-sdk/sdk/native/libs/** to native_opencv/android/src/main/jniLibs/**

Windows

Run init_windows.ps1 PowerShell script from a scripts folder or do the following steps manually:

  1. Download OpenCV for Windows: https://opencv.org/releases/
  2. Unpack it. Set env. variable OpenCV_DIR to unpacked ...\opencv\build folder
  3. Create a hard link from native_opencv\ios\Classes\native_opencv.cpp to native_opencv_windows\windows\native_opencv.cpp
  4. Make sure native_opencv_windows\windows\CMakeLists.txt contains correct .dll names (OpenCV_DEBUG_DLL_NAME,OpenCV_RELEASE_DLL_NAME)

macOS

Before doing anything else, you need to download OpenCV source code and build a framework by running opencv/platforms/apple/build_xcframework.py script.

Run init_macos.sh script from a scripts folder or do the following steps manually:

  1. Create a hard link from native_opencv/ios/Classes/native_opencv.cpp to native_opencv_macos/macos/Classes/native_opencv.cpp
  2. Copy opencv2.xcframework to native_opencv/macos

Linux

Before doing anything else, you need to download OpenCV source code and build libraries by following the official tutorial.

After making a build, set up an environmental variable OpenCV_DIR to the build's folder.

Run init_linux.sh script from a scripts folder or do the following steps manually:

  1. Create a hard link from native_opencv/ios/Classes/native_opencv.cpp to native_opencv_linux/linux/native_opencv.cpp

Troubleshooting

  /snap/flutter/current/usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
  # include <gnu/stubs-32.h>
            ^~~~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

or

/snap/flutter/current/usr/bin/ld: warning: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crt1.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0008002
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Exception: Build process failed

Install flutter manually instead of from snap, see: https://flutter.dev/docs/get-started/install/linux#install-flutter-manually

flutter_native_opencv's People

Contributors

westracer avatar odrevet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.