dartcv4 2.3.0 copy "dartcv4: ^2.3.0" to clipboard
dartcv4: ^2.3.0 copied to clipboard

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

dartcv #

OpenCV Bindings for Dart Language.

Star on Github License: Apache-2.0
Native Assets Build Discord Server

Important

The minimum required dart sdk version is 3.10 (Flutter 3.38) that supports hooks (Native-Assets).

Note

WIP, contributions are welcome!

Example #

example

Supported Platforms #

Platform Supported Tested Prebuilt Binaries
Android x86_64, arm64-v8a, armeabi-v7a
iOS arm64, x64+arm64(Simulator)
Linux x64
Windows x64
macOS x64, arm64

Status #

Core Modules #

module Binding status Test status description
core Core module
calib3d Calib3D module
dnn DNN module
features2d Features2D module
gapi GAPI module
highgui HighGUI module
imgcodecs ImageCodecs module
imgproc ImageProc module
ml ML module
objdetect Object Detection module
photo Photo module
stitching ☑️ ☑️ Stitching module
svd SVD module
video Video module
videoio VideoIO module

Contrib Modules #

module Binding status Test status description
aruco ArUco module
img_hash Image hashing module
cuda
wechat_qrcode
bgsegm
superres
xfeatures2d
ximgproc
xobjdetect
xphoto
quality
freetype
  • ❌ : not finished
  • ☑️ : partially supported
  • ✅ : finished
  • modules not in the above table are not considered, contributions are welcome
  • VideoIO and HighGUI modules dynamically linked FFMPEG, you should be careful with the license, this project takes no responsibility for the license.

Usage #

Pure Dart

import 'package:dartcv4/dartcv.dart' as cv;

void main() {
  final img = cv.imread("test/images/lenna.png", flags: cv.IMREAD_COLOR);
  final gray = cv.cvtColor(img, gray, cv.COLOR_BGR2GRAY);
  print("${img.rows}, ${img.cols}");

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

Asynchronous

import 'package:dartcv4/dartcv.dart' as cv;
import 'dart:async';
void main() async {
  final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR);
  final gray = await cv.cvtColorAsync(img, cv.COLOR_BGR2GRAY);
  print("${img.rows}, ${img.cols}");

  await cv.imwriteAsync("test_cvtcolor.png", gray);
}

Flutter

see example

More examples are on the way... see awesome-opencv_dart and share yours

Configure hooks options

dartcv4 now supports hooks options, you can configure it in pubspec.yaml

hooks:
  user_defines:
    dartcv4:
      # debug: true
      # treeshake: true # tree-shaking unused symbols, onyl works in AOT mode and Dart 3.13+.
      include_modules: # `core` is always included
        - imgcodecs
        - imgproc
        # ...
      exclude_modules:
        - contrib
        - dnn
        # ...
      # whether to build OpenCV with OpenCL support, per platform
      windows:
        use_opencl: false
      linux:
        use_opencl: true
  • debug: enable debug mode, default is false, if enabled, all messages will be printed to stderr.
  • treeshake: enable linker dead-code elimination, default is false. When enabled, the native library is compiled with function-level sections and the linker garbage-collects code that is not reachable from the exported symbols.
  • use_opencl: whether to build OpenCV with OpenCL support, default is false for all platforms. It can be configured per platform under a platform key (windows, linux, macos, android, ios). OpenCL is always disabled on ios since iOS does not support it. Enabling OpenCL may accelerate some operations (e.g. dnn), but it is disabled by default because the OpenCV OpenCL runtime can cause a racy hang-at-exit during process teardown; enable it only if you need the acceleration.
  • valid modules:
    • core: always included
    • included by default:
      • imgproc
      • imgcodecs
    • excluded by default:
      • calib3d
      • features2d
      • flann
      • dnn
      • freetype
      • highgui
      • video
      • videoio
      • objdetect
      • photo
      • stitching
      • aruco
      • img_hash
      • quality
      • wechat_qrcode
      • ximgproc
      • xobjdetect
  • Note: even a module is excluded, it's dart code is still available, but throws a symbol not found exception when called.
  • videoio and highgui will introduce FFMPEG dynamic libraries (except for ios, ffmpeg is not supported on ios for now). FFMPEG is no longer available with dartcv >= 2.2.0

TODO #

  • ✅ compile libs for android, linux
  • ✅ support for iOS, macOS
  • ✅ add more examples
  • ❌ documentation
  • ✅ modify C wrapper to catch exceptions
  • ✅ Native Assets
  • ✅ async?
  • ✅ more/full test coverage
  • ✅ directly include opencv source code, refactor cmakelists.txt

Contributors #

rainyl
rainy liu
abdelaziz-mahdy
Abdelaziz Mahdy
einsitang
爱因斯唐
Gold872
Gold87
Jiinwoo
JinWoo Jung
westito
westito
dupuchba
Baptiste DUPUCH
Escaton615
Escaton615
mdeleau
mdeleau
lennartalff
Thies Lennart Alff
totemat
Matteo T.

Acknowledgement #

Star History #

Star History Chart

License #

Apache-2.0 License

16
likes
150
points
7.59k
downloads

Documentation

API reference

Publisher

verified publisherrainyl.dev

Weekly Downloads

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

Repository (GitHub)
View/report issues
Contributing

Topics

#opencv #image #ffi #flutter

License

Apache-2.0 (license)

Dependencies

code_assets, ffi, hooks, logging, meta, native_toolchain_cmake, record_use

More

Packages that depend on dartcv4