OpenCV Bindings for Dart Language.
[!IMPORTANT] For
v1.0.6
and later, auto setup is supported, 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)- iOS: support universal framework(
os64
, fat lib for x86_64 and arm64)- 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 theflutter 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:
flutter pub add opencv_dart
ordart 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
x64
arm64
- More questions: refer to #29 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, contributions are welcome!
Platform | Supported | Tested | Prebuilt Binaries |
---|---|---|---|
Android | :white_check_mark: | :ballot_box_with_check: | x86_64, arm64-v8a, armeabi-v7a |
iOS | :white_check_mark: | :ballot_box_with_check: | arm64, x64(Simulator) |
Linux | :white_check_mark: | :white_check_mark: | x64 |
Windows | :white_check_mark: | :white_check_mark: | x64 |
macOS | :white_check_mark: | :white_check_mark: | x64, arm64 |
module | Binding status | Test status | description |
---|---|---|---|
core | :white_check_mark: | :white_check_mark: | Core module |
calib3d | :white_check_mark: | :white_check_mark: | Calib3D module |
dnn | :white_check_mark: | :white_check_mark: | DNN module |
features2d | :white_check_mark: | :white_check_mark: | Features2D module |
gapi | :x: | :x: | GAPI module |
highgui | :white_check_mark: | :white_check_mark: | HighGUI module |
imgcodecs | :white_check_mark: | :white_check_mark: | ImageCodecs module |
imgproc | :white_check_mark: | :white_check_mark: | ImageProc module |
ml | :x: | :x: | ML module |
objdetect | :white_check_mark: | :white_check_mark: | Object Detection module |
photo | :white_check_mark: | :white_check_mark: | Photo module |
stitching | :ballot_box_with_check: | :ballot_box_with_check: | Stitching module |
svd | :white_check_mark: | :white_check_mark: | SVD module |
video | :white_check_mark: | :white_check_mark: | Video module |
videoio | :white_check_mark: | :white_check_mark: | VideoIO module |
module | Binding status | Test status | description |
---|---|---|---|
aruco | :white_check_mark: | :white_check_mark: | ArUco module |
img_hash | :white_check_mark: | :white_check_mark: | Image hashing module |
cuda | :x: | :x: | |
wechat_qrcode | :white_check_mark: | :white_check_mark: | |
bgsegm | :x: | :x: | |
superres | :x: | :x: | |
xfeatures2d | :x: | :x: | |
ximgproc | :x: | :x: | |
xobjdetect | :x: | :x: | |
xphoto | :x: | :x: |
cv.VideoCapture
from file is not supported yet[!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);
If you really need updates for
v0.6.x
, open PRs and it will be merged tov0.6
branch.
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
native-assets
branch[!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 setOpenCV_DIR
environment variable.
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
git clone https://github.com/rainyl/opencv_dart.git
cd opencv_dart
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 tools.android:ndk_path="<ABSOLUTE path for ndk>"
ios:
conan build . -b missing -pr:h profiles/ios-<arch>
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
"dart.env"
in settings.json
Compiling for linux aarch64 requires GCC 13 and newer, conan toolchain for linux arm is located in opencv.full, explore more there.
rainy liu |
Abdelaziz Mahdy |
JinWoo Jung |
mdeleau |
Matteo T. |
gocv
project: https://github.com/hybridgroup/gocv License: Apache-2.0Apache-2.0 License