opencv_dart

Creator: coderz1093

Last updated:

Add to Cart

Description:

opencv dart

opencv_dart #
OpenCV Bindings for Dart Language. Support both asynchronous and synchronous!










Important
For v1.0.6 and later, libs will be downloaded from
Releases automatically.

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)

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

flutter pub add opencv_dart or dart pub add opencv_dart
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
os64 (universal framework)




More questions: refer to #212 or open new issues.
If you are using flutter with Native Assets feature supported, consider using v2.x version, see more in native-assets branch



Note
WIP, APIs may change in the future, contributions are welcome!


opencv_dart

Example
Supported Platforms
Status

Core Modules
Contrib Modules
Usage

Pure Dart
Flutter


TODO


For Developers

How to compile

1. Install dependencies
2. clone this repo
3. compile
4. test




Contributors
Acknowledgement
Star History
License




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


cuda





wechat_qrcode





bgsegm





superres





xfeatures2d





ximgproc





xobjdetect





xphoto







❌ : 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 #

Warning
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);
copied to clipboard
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);
}
copied to clipboard
Flutter
see example
More examples are on the way... see awesome-opencv_dart and share yours
TODO #

✅ 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 #

Note
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
copied to clipboard
If you are usin Scoop:
scoop install conan
copied to clipboard


Linux: Ubuntu as example, note opencv.full is built on Ubuntu 22.04 with ffmpeg 4.4
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
copied to clipboard


macOS: XCode is required
brew install --force --overwrite ninja ffmpeg@6 conan
brew link --overwrite ffmpeg@6
conan profile detect -f
copied to clipboard


2. clone this repo
git clone https://github.com/rainyl/opencv_dart.git
cd opencv_dart
copied to clipboard
3. compile


Windows:
conan build . -b missing -s compiler.cppstd=20
copied to clipboard


Linux, macos:
conan build . -b missing
copied to clipboard


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 tools.android:ndk_path="<ABSOLUTE path for ndk>"
copied to clipboard


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


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/libopencv_dart.so
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

Contributors #








rainy liu






Abdelaziz Mahdy






爱因斯唐






JinWoo Jung






mdeleau






Matteo T.






Acknowledgement #

gocv project: https://github.com/hybridgroup/gocv License: Apache-2.0

Star History #

License #
Apache-2.0 License

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.