Skip to content

Commit

Permalink
Merge pull request #115 from abdelaziz-mahdy/async-objdetect
Browse files Browse the repository at this point in the history
async object detect
  • Loading branch information
rainyl committed Jun 28, 2024
2 parents 511320f + 45622bd commit a757c28
Show file tree
Hide file tree
Showing 21 changed files with 4,756 additions and 27 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/formatter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
push:
pull_request:

name: Format Code

jobs:
build:
name: format code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Flutter
uses: subosito/flutter-action@v1
- name: Format code
run: |
dart format --line-length 110 \
$(find lib test -name '*.dart' -not -name '*.g.dart' -and -not -name '*.freezed.dart')
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "dart format ✅"
branch: ${{ github.head_ref }}
1 change: 1 addition & 0 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 4 additions & 0 deletions ffigen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ headers:
- src/core/version.h
- src/dnn/asyncarray.h
- src/dnn/dnn.h
- src/dnn/dnn_async.h
- src/extra/aruco.h
- src/extra/img_hash.h
- src/extra/wechat_qrcode.h
Expand All @@ -36,6 +37,7 @@ headers:
- src/imgproc/imgproc.h
- src/imgproc/imgproc_async.h
- src/objdetect/objdetect.h
- src/objdetect/objdetect_async.h
- src/photo/photo.h
- src/stitching/stitching.h
- src/video/video.h
Expand All @@ -51,6 +53,7 @@ headers:
- src/core/version.h
- src/dnn/asyncarray.h
- src/dnn/dnn.h
- src/dnn/dnn_async.h
- src/extra/aruco.h
- src/extra/img_hash.h
- src/extra/wechat_qrcode.h
Expand All @@ -62,6 +65,7 @@ headers:
- src/imgproc/imgproc.h
- src/imgproc/imgproc_async.h
- src/objdetect/objdetect.h
- src/objdetect/objdetect_async.h
- src/photo/photo.h
- src/stitching/stitching.h
- src/video/video.h
Expand Down
2 changes: 2 additions & 0 deletions lib/opencv_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export 'src/core/scalar.dart';
export 'src/core/size.dart';
export 'src/core/vec.dart';
export 'src/dnn/dnn.dart';
export 'src/dnn/dnn_async.dart';
export 'src/features2d/features2d.dart';
export 'src/highgui/highgui.dart';
export 'src/imgcodecs/imgcodecs.dart';
Expand All @@ -36,6 +37,7 @@ export 'src/imgproc/clahe.dart';
export 'src/imgproc/imgproc.dart';
export 'src/imgproc/subdiv2d.dart';
export 'src/objdetect/objdetect.dart';
export 'src/objdetect/objdetect_async.dart';
export 'src/photo/photo.dart';
export 'src/stitching/stitching.dart';
export 'src/svd/svd.dart';
Expand Down
3 changes: 1 addition & 2 deletions lib/src/contrib/aruco_dict.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ class ArucoDictionary extends CvStruct<cvg.ArucoDictionary> {

@override
cvg.ArucoDictionary get ref => ptr.ref;
static final finalizer =
OcvFinalizer<cvg.ArucoDictionaryPtr>(CFFI.addresses.ArucoDictionary_Close);
static final finalizer = OcvFinalizer<cvg.ArucoDictionaryPtr>(CFFI.addresses.ArucoDictionary_Close);

void dispose() {
finalizer.detach(this);
Expand Down
22 changes: 22 additions & 0 deletions lib/src/core/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ Future<T> cvRunAsync3<T>(
return completer.future;
}

Future<T> cvRunAsync4<T>(
ffi.Pointer<cvg.CvStatus> Function(cvg.CvCallback_4 callback) func,
void Function(
Completer<T> completer,
VoidPtr p,
VoidPtr p1,
VoidPtr p2,
VoidPtr p3,
) onComplete,
) {
final completer = Completer<T>();
late final NativeCallable<cvg.CvCallback_4Function> ccallback;
void onResponse(VoidPtr p, VoidPtr p1, VoidPtr p2, VoidPtr p3) {
onComplete(completer, p, p1, p2, p3);
ccallback.close();
}

ccallback = ffi.NativeCallable.listener(onResponse);
throwIfFailed(func(ccallback.nativeFunction));
return completer.future;
}

Future<T> cvRunAsync5<T>(
ffi.Pointer<cvg.CvStatus> Function(cvg.CvCallback_5 callback) func,
void Function(Completer<T> completer, VoidPtr p, VoidPtr p1, VoidPtr p2, VoidPtr p3, VoidPtr p4) onComplete,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/dnn/dnn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class Net extends CvStruct<cvg.Net> {
finalizer.attach(this, ptr.cast(), detach: this);
}
}
factory Net.fromPointer(
cvg.NetPtr ptr, [
bool attach = true,
]) =>
Net._(ptr, attach);

factory Net.empty() {
final p = calloc<cvg.Net>();
Expand Down
Loading

0 comments on commit a757c28

Please sign in to comment.