Skip to content

Commit 03127a3

Browse files
authored
Merge pull request #101 from rainyl/async
Support Asynchronous
2 parents 3618405 + 8be288f commit 03127a3

File tree

168 files changed

+43016
-6816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+43016
-6816
lines changed

.github/workflows/build_test_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
channel: "stable"
7979

8080
build-ubuntu:
81-
name: build-ubuntu-android-armv7
81+
name: build-ubuntu
8282
runs-on: ubuntu-22.04
8383

8484
steps:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.0
2+
3+
- New: EXPERIMENTAL, Asynchronous support by @abdelaziz-mahdy and @rainyl, try it and open an issue if you have any problems.
4+
15
## 1.0.10+1
26

37
- Fix: setup commands error on linux

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ if(IOS)
8787
)
8888
endif(IOS)
8989

90+
if(APPLE)
91+
target_link_options(${LIBRARY_NAME} PRIVATE "LINKER:-ld_classic")
92+
endif(APPLE)
9093

9194
if(WIN32)
9295
set_target_properties(${LIBRARY_NAME} PROPERTIES

binary.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.10
1+
1.1.0

conanfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def build_requirements(self):
9797
self.tool_requires("cmake/3.28.1")
9898
if self.settings.os != "Windows":
9999
self.tool_requires("ninja/1.11.1")
100+
# if self.settings.os == "Linux":
101+
# self.tool_requires("ffmpeg/6.1")
100102
if self.settings.os == "Android":
101103
ndk_path = os.environ.get("ANDROID_NDK_HOME", None) or os.environ.get(
102104
"ANDROID_NDK_ROOT", None

example/lib/main.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ class _MyAppState extends State<MyApp> {
4040
gray = cv.cvtColor(im, cv.COLOR_BGR2GRAY);
4141
blur = cv.gaussianBlur(im, (7, 7), 2, sigmaY: 2);
4242
}
43-
return (
44-
cv.imencode(cv.ImageFormat.png.ext, gray),
45-
cv.imencode(cv.ImageFormat.png.ext, blur)
46-
);
43+
return (cv.imencode(".png", gray), cv.imencode(".png", blur));
4744
});
4845

46+
Future<(cv.Mat, cv.Mat)> heavyTaskAsync(cv.Mat im) async {
47+
late cv.Mat gray, blur;
48+
for (var i = 0; i < 1000; i++) {
49+
gray = await cv.cvtColorAsync(im, cv.COLOR_BGR2GRAY);
50+
blur = await cv.gaussianBlurAsync(im, (7, 7), 2, sigmaY: 2);
51+
}
52+
return (gray, blur);
53+
}
54+
4955
@override
5056
Widget build(BuildContext context) {
5157
return MaterialApp(
@@ -80,9 +86,13 @@ class _MyAppState extends State<MyApp> {
8086
final data = await DefaultAssetBundle.of(context).load("images/lenna.png");
8187
final bytes = data.buffer.asUint8List();
8288
// heavy computation
83-
final (gray, blur) = await heavyTask(bytes);
89+
// final (gray, blur) = await heavyTask(bytes);
90+
// setState(() {
91+
// images = [bytes, gray, blur];
92+
// });
93+
final (gray, blur) = await heavyTaskAsync(cv.imdecode(bytes, cv.IMREAD_COLOR));
8494
setState(() {
85-
images = [bytes, gray, blur];
95+
images = [bytes, cv.imencode(".png", gray), cv.imencode(".png", blur)];
8696
});
8797
},
8898
child: const Text("Process"),

example/test/widget_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

ffigen.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,80 @@ sort: true
1515
headers:
1616
entry-points:
1717
- src/calib3d/calib3d.h
18+
- src/calib3d/calib3d_async.h
1819
- src/core/core.h
20+
- src/core/core_async.h
1921
- src/core/exception.h
2022
- src/core/svd.h
23+
- src/core/svd_async.h
24+
- src/core/types.h
2125
- src/core/vec.h
2226
- src/core/version.h
2327
- src/dnn/asyncarray.h
2428
- src/dnn/dnn.h
29+
- src/dnn/dnn_async.h
2530
- src/extra/aruco.h
31+
- src/extra/aruco_async.h
2632
- src/extra/img_hash.h
33+
- src/extra/img_hash_async.h
2734
- src/extra/wechat_qrcode.h
35+
- src/extra/wechat_qrcode_async.h
2836
- src/features2d/features2d.h
37+
- src/features2d/features2d_async.h
38+
- src/gapi/gapi.h
2939
- src/highgui/highgui.h
3040
- src/imgcodecs/imgcodecs.h
41+
- src/imgcodecs/imgcodecs_async.h
3142
- src/imgproc/imgproc.h
43+
- src/imgproc/imgproc_async.h
3244
- src/objdetect/objdetect.h
45+
- src/objdetect/objdetect_async.h
3346
- src/photo/photo.h
47+
- src/photo/photo_async.h
3448
- src/stitching/stitching.h
49+
- src/stitching/stitching_async.h
3550
- src/video/video.h
51+
- src/video/video_async.h
3652
- src/video/videoio.h
53+
- src/video/videoio_async.h
3754
include-directives:
3855
- src/calib3d/calib3d.h
56+
- src/calib3d/calib3d_async.h
3957
- src/core/core.h
58+
- src/core/core_async.h
4059
- src/core/exception.h
4160
- src/core/svd.h
61+
- src/core/svd_async.h
4262
- src/core/vec.h
4363
- src/core/version.h
4464
- src/dnn/asyncarray.h
4565
- src/dnn/dnn.h
66+
- src/dnn/dnn_async.h
4667
- src/extra/aruco.h
68+
- src/extra/aruco_async.h
4769
- src/extra/img_hash.h
70+
- src/extra/img_hash_async.h
4871
- src/extra/wechat_qrcode.h
72+
- src/extra/wechat_qrcode_async.h
4973
- src/features2d/features2d.h
74+
- src/features2d/features2d_async.h
75+
- src/gapi/gapi.h
5076
- src/highgui/highgui.h
5177
- src/imgcodecs/imgcodecs.h
78+
- src/imgcodecs/imgcodecs_async.h
5279
- src/imgproc/imgproc.h
80+
- src/imgproc/imgproc_async.h
5381
- src/objdetect/objdetect.h
82+
- src/objdetect/objdetect_async.h
5483
- src/photo/photo.h
84+
- src/photo/photo_async.h
5585
- src/stitching/stitching.h
86+
- src/stitching/stitching_async.h
5687
- src/video/video.h
88+
- src/video/video_async.h
5789
- src/video/videoio.h
90+
- src/video/videoio_async.h
91+
5892
functions:
5993
symbol-address:
6094
include:

lib/opencv_dart.dart

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,62 @@
1-
export 'src/opencv.dart';
1+
library cv;
2+
3+
export 'src/calib3d/calib3d.dart';
4+
export 'src/calib3d/calib3d_async.dart';
5+
export 'src/calib3d/fisheye.dart';
6+
export 'src/constants.g.dart';
7+
8+
export 'src/contrib/aruco.dart';
9+
export 'src/contrib/aruco_async.dart';
10+
export 'src/contrib/aruco_dict.dart';
11+
export 'src/contrib/img_hash.dart';
12+
export 'src/contrib/wechat_qrcode.dart';
13+
export 'src/contrib/wechat_qrcode_async.dart';
14+
15+
export 'src/core/array.dart';
16+
export 'src/core/asyncarray.dart';
17+
export 'src/core/base.dart';
18+
export 'src/core/contours.dart';
19+
export 'src/core/core.dart';
20+
export 'src/core/core_async.dart';
21+
export 'src/core/cv_vec.dart';
22+
export 'src/core/dmatch.dart';
23+
export 'src/core/error_code.dart';
24+
export 'src/core/exception.dart';
25+
export 'src/core/keypoint.dart';
26+
export 'src/core/mat.dart';
27+
export 'src/core/mat_async.dart';
28+
export 'src/core/mat_type.dart';
29+
export 'src/core/moments.dart';
30+
export 'src/core/point.dart';
31+
export 'src/core/rect.dart';
32+
export 'src/core/rng.dart';
33+
export 'src/core/rng_async.dart';
34+
export 'src/core/scalar.dart';
35+
export 'src/core/size.dart';
36+
export 'src/core/termcriteria.dart';
37+
export 'src/core/vec.dart';
38+
39+
export 'src/dnn/dnn.dart';
40+
export 'src/dnn/dnn_async.dart';
41+
export 'src/features2d/features2d.dart';
42+
export 'src/features2d/features2d_async.dart';
43+
export 'src/highgui/highgui.dart';
44+
export 'src/imgcodecs/imgcodecs.dart';
45+
export 'src/imgcodecs/imgcodecs_async.dart';
46+
export 'src/imgproc/clahe.dart';
47+
export 'src/imgproc/clahe_async.dart';
48+
export 'src/imgproc/imgproc.dart';
49+
export 'src/imgproc/imgproc_async.dart';
50+
export 'src/imgproc/subdiv2d.dart';
51+
export 'src/imgproc/subdiv2d_async.dart';
52+
export 'src/objdetect/objdetect.dart';
53+
export 'src/objdetect/objdetect_async.dart';
54+
export 'src/photo/photo.dart';
55+
export 'src/photo/photo_async.dart';
56+
export 'src/stitching/stitching.dart';
57+
export 'src/stitching/stitching_async.dart';
58+
export 'src/svd/svd.dart';
59+
export 'src/video/video.dart';
60+
export 'src/video/video_async.dart';
61+
export 'src/video/videoio.dart';
62+
export 'src/video/videoio_async.dart';

lib/opencv_gapi.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
library cv.gapi;
2+
3+
export 'src/gapi/gapi.dart';
4+
export 'src/gapi/gcomputation.dart';
5+
export 'src/gapi/gmat.dart';
6+
export 'src/gapi/gscalar.dart';

0 commit comments

Comments
 (0)