opencv_dart 0.5.0 copy "opencv_dart: ^0.5.0" to clipboard
opencv_dart: ^0.5.0 copied to clipboard

OpenCV4 bindings for Dart language and Flutter, using dart:ffi. The most complete OpenCV bindings for Dart!

opencv_dart #

OpenCV Bindings for Dart Language.

!!!This package is experiment and APIs may change in the future!!!

Many tests unfinished, contributions are welcome!

Prebuilt binaries for Android(arm64-v8a, armeabi-v7a, x86_64), Linux(x64) and Windows(x64) are available,for other platforms, you have to build them your self.

IMPORTANT #

After added to pubspec.yaml or install by commandline, please run dart run opencv_dart:setup -p <platform> -a <arch> to download prebuilt binaries.

  • platform: auto android linux windows
  • arch: auto x86 x64 x86_64(android only) arm64-v8a(android only) armeabi-v7a(android only)

Please use v0.3.0 and later version.

Status #

module Binding status Test status description
aruco ArUco module
core Core module
features2d Features2D module
highgui HighGUI module
imgcodecs ImageCodecs module
imgproc ImageProc module
objdetect Object Detection module
svd SVD module
video Video module
videoio VideoIO module
asyncarray AsyncArray module
calib3d Calib3D module
dnn DNN module
photo Photo module
cuda CUDA module
contrib Contrib module
  • ❌ : not finished
  • ☑️ : almost finished
  • ✅ : finished
  • videoio: cv.VideoCapture from file is not supported yet supported now.

Usage #

import 'package:opencv_dart/opencv_dart.dart' as cv;

final img = cv.imread("test/images/lenna.png", flags: cv.IMREAD_COLOR);
final gray = cv.Mat.empty();

cv.cvtColor(img, gray, cv.COLOR_BGR2GRAY);
print("${img.rows}, ${img.cols}");

cv.imwrite("test_cvtcolor.png", gray);

More examples are on the way...

TODO #

  • compile libs for android, linux
  • support for iOS, macOS
  • add more examples
  • modify C wrapper to catch exceptions
  • Native Assets
  • async?

For Developers #

This package is in heavy development, dynamic libraries for Windows and linux have been compiled, for other platforms, you need to compile it yourself.

How to compile #

  1. prepare a compiler.

    windows: Install Visual Studio 2019 or Later

    ubuntu: reference opencv official build guide to install

  2. install dependencies: cmake, python, add to PATH

  3. clone this repo, git clone https://github.com/rainyl/opencv_dart.git

  4. cd opencv_dart and git submodule update --init

  5. compile opencv

    for windows:

    python .\scripts\build.py --opencv --os linux --arch x64 --build-dir build --src src
    

    for linux:

    python ./scripts/build.py --opencv --os linux --arch x64 --build-dir build --src src
    

    for android, you need to download android ndk and opencv for android sdk, extract opencv sdk and copy and rename OpenCV-android-sdk to build/android directory.

  6. compile this package along with gocv, windows: ./scripts/build.ps1, linux: ./scripts/build.sh, this will generate libopencv_dart.dll or libopencv_dart.so

  7. copy libs to corresponding platform directorys, i.e., libopencv_dart.dll to windows, libopencv_dart.so to linux. this is necessary for dart and flutter to load the dynamic library.

  8. If you want to test using vscode, add dynamic library path to "dart.env" in settings.json

Acknowledgement #

License #

Apache-2.0 License

39
likes
0
pub points
91%
popularity

Publisher

verified publisherrainyl.dev

OpenCV4 bindings for Dart language and Flutter, using dart:ffi. The most complete OpenCV bindings for Dart!

Repository (GitHub)
View/report issues

Topics

#opencv #image #ffi #flutter

License

unknown (LICENSE)

Dependencies

archive, args, equatable, ffi, flutter, path, plugin_platform_interface, w_common, yaml

More

Packages that depend on opencv_dart