DartCv
OpenCV bindings for Dart language.
dartcv4 is only for pure dart, for Flutter, use opencv_core, if videoio module is required, use opencv_dart
Install
dart pub add dartcv4
or Add dartcv4 topubspec.yaml
- Prepare libraries for your platform, you have 2 options (macos: please build from source.)
- Setup environment variables
- windows: append the above path to
PATH
- linux: append the above path to
LD_LIBRARY_PATH
- macos: append the above path to
DYLD_FALLBACK_LIBRARY_PATH
- windows: append the above path to
Usage
Synchronous
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, 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);
}
Q&A
- Refer to #212 or open new issues.
More examples
Refer to tests
Screenshots
see Demos
Build libdartcv from source
Refer to dartcv