opencv_dart 1.0.9 copy "opencv_dart: ^1.0.9" to clipboard
opencv_dart: ^1.0.9 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.

Star on Github License: Apache-2.0 Native Assets Build


For v1.0.6 and later, auto setup is supported, libs will be downloaded from Releases automatically.

  1. If you want to setup manually, please set OPENCV_DART_DISABLE_AUTO_BUILD environment variable, e.g., export OPENCV_DART_DISABLE_AUTO_BUILD=1(for Unix-like) or $env:OPENCV_DART_DISABLE_AUTO_BUILD=1(for Windows)
  2. iOS: support universal framework(os64, fat lib for x86_64 and arm64)
  3. Android: all supported ABIs (x86_64 arm64-v8a armeabi-v7a) will be built, if you want to reduce the app size, please add --split-per-abi to the flutter build command, e.g., flutter build apk --release --target-platform android-arm64,android-x64 --split-per-abi, otherwise, all .so will be packaged to app.

For v1.0.4 and below, make sure run the following setup commands before running your app:

  1. flutter pub add opencv_dart or dart pub add opencv_dart
  2. dart run opencv_dart:setup <platform> --arch <arch>
platform arch
android x86_64 arm64-v8a armeabi-v7a
linux x64
windows x64
macos x64 arm64
ios x64 arm64


WIP, contributions are welcome!

Example #


Supported Platforms #

Platform Supported Tested Prebuilt Binaries
Android ☑️ x86_64, arm64-v8a, armeabi-v7a
iOS ☑️ arm64, x64(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
  • ❌ : not finished
  • ☑️ : partially supported
  • ✅ : finished
  • modules not in the above table are not considered, contributions are welcome
  • videoio: cv.VideoCapture from file is not supported yet supported now.

Usage #


Since v1.0.0, nearly ALL APIs were changed to compitable with opencv-python, for example:

// old API
void cvtColor(Mat src, Mat dst, int code);
// new API
Mat cvtColor(Mat src, int code, {Mat? dst});

// then usage will be changed from:
cvtColor(src, dst, cv.COLOR_BGR2GRAY);
// to:
final dst = cvtColor(src, cv.COLOR_BGR2GRAY);
// or:
cvtColor(src, cv.COLOR_BGR2GRAY, dst: dst);

If you really need updates for v0.6.x, open PRs and it will be merged to v0.6 branch.

Pure Dart

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

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

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


see example

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


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

For Developers #


since v1.0.1, to speed up compile in CI, opencv is precompiled in opencv.full, and this repo will download the prebuilt static libraries from it's release, if you want to compile entirely by yourself, you can compile opencv and explicitly set -o opencv_dir=<path to opencv> for the below commands or set OpenCV_DIR environment variable.

How to compile #

1. Install dependencies

  • Windows: Install Visual Studio 2019 or Later, install Conan

     python3 -m pip install conan
     conan profile detect -f

    If you are usin Scoop:

    scoop install conan
  • Linux: Ubuntu as example

    sudo apt-get install build-essential libgtk-3-dev ffmpeg libavcodec-dev cmake \
      ninja-build libavformat-dev libavutil-dev libswscale-dev \
      libgflags-dev python3 libjpeg-dev libpng-dev libtiff-dev python3-pip
    python3 -m pip install conan
    conan profile detect -f
  • macOS: XCode is required

    brew install --force --overwrite ninja ffmpeg@6 conan
    brew link --overwrite ffmpeg@6
    conan profile detect -f

2. clone this repo

git clone
cd opencv_dart

3. compile

  • Windows:

    conan build . -b missing -s compiler.cppstd=20
  • Linux, macos:

    conan build . -b missing
  • android

If you want to use your own NDK instead of conan maintained one, please set ANDROID_NDK_HOME or ANDROID_NDK_ROOT environment variable, e.g., export ANDROID_NDK_HOME=/opt/android-ndk-r26c

conan build . -b missing -pr:h profiles/android-<arch> -c"<ABSOLUTE path for ndk>"
  • ios:

    conan build . -b missing -pr:h profiles/ios-<arch>

4. test

  • Set OPENCV_DART_LIB_PATH environment variable to the path of the compiled dynamic library, e.g., export OPENCV_DART_LIB_PATH=pwd/linux/ or $ENV:OPENCV_DART_LIB_PATH=$PWD\windows\opencv_dart.dll
  • or append the lib path to the library search path of your system
  • If you want to test using vscode, add above variable to "dart.env" in settings.json

5. Cross-compile for linux aarch64

Compiling for linux aarch64 requires GCC 13 and newer, conan toolchain for linux arm is located in opencv.full, explore more there.

Contributors #

rainy liu
Abdelaziz Mahdy
JinWoo Jung
Matteo T.

Acknowledgement #

Star History #

Star History Chart

License #

Apache-2.0 License

pub points



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

Repository (GitHub)
View/report issues


#opencv #image #ffi #flutter


API reference


Apache-2.0 (LICENSE)


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


Packages that depend on opencv_dart