opencv_dart 2.0.0-dev.3
opencv_dart: ^2.0.0-dev.3 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.
Important
v2.x is prepared for Native Assets, Use only if you know what you are doing!
Note
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 |
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
Usage #
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, gray, cv.COLOR_BGR2GRAY);
print("${img.rows}, ${img.cols}");
cv.imwrite("test_cvtcolor.png", gray);
}
Flutter
see example
More examples are on the way...
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
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 manually with conan #
-
prepare a compiler.
windows: Install Visual Studio 2019 or Later
ubuntu: reference opencv official build guide to install
sudo apt-get install build-essential libgtk-3-dev ffmpeg libavcodec-dev cmake \ ninja-build ccache nasm libavformat-dev libavutil-dev libswscale-dev \ libgflags-dev python3 libjpeg-dev libpng-dev libtiff-dev python3-pip
macos:
brew install --force --overwrite ninja ccache ffmpeg nasm cmake
from v0.6.4, build system has been migrated to conan
python3 -m pip install conan conan profile detect -f
-
clone this repo,
git clone https://github.com/rainyl/opencv_dart.git
-
cd opencv_dart
-
compile
for windows:
conan build . -b missing -s compiler.cppstd=20
for linux, macos:
conan build . -b missing
for android:
conan build . -b missing -pr:h profiles/android-<arch> -c tools.android:ndk_path="<ABSOLUTE path for ndk>"
for ios:
echo "tools.cmake.cmaketoolchain:user_toolchain=[\"`pwd`/profiles/ios.toolchain.cmake\"]" >> profiles/ios-<arch> conan build . -b missing -pr:h profiles/ios-<arch>
-
If you want to test using vscode, add dynamic library path to
"dart.env"
insettings.json
Acknowledgement #
gocv
project: https://github.com/hybridgroup/gocv License: Apache-2.0
Star History #
License #
Apache-2.0 License