diff --git a/.github/workflows/formatter.yaml b/.github/workflows/formatter.yaml new file mode 100644 index 00000000..be590a48 --- /dev/null +++ b/.github/workflows/formatter.yaml @@ -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 }} diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index e69de29b..8b137891 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -0,0 +1 @@ + diff --git a/ffigen.yaml b/ffigen.yaml index 2ba29f62..2fef60f4 100644 --- a/ffigen.yaml +++ b/ffigen.yaml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/lib/opencv_dart.dart b/lib/opencv_dart.dart index 7c7c1478..9d6b3a16 100644 --- a/lib/opencv_dart.dart +++ b/lib/opencv_dart.dart @@ -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'; @@ -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'; diff --git a/lib/src/contrib/aruco_dict.dart b/lib/src/contrib/aruco_dict.dart index e0ced4a6..6d5b6283 100644 --- a/lib/src/contrib/aruco_dict.dart +++ b/lib/src/contrib/aruco_dict.dart @@ -95,8 +95,7 @@ class ArucoDictionary extends CvStruct { @override cvg.ArucoDictionary get ref => ptr.ref; - static final finalizer = - OcvFinalizer(CFFI.addresses.ArucoDictionary_Close); + static final finalizer = OcvFinalizer(CFFI.addresses.ArucoDictionary_Close); void dispose() { finalizer.detach(this); diff --git a/lib/src/core/base.dart b/lib/src/core/base.dart index 5ab50a03..936fe887 100644 --- a/lib/src/core/base.dart +++ b/lib/src/core/base.dart @@ -151,6 +151,28 @@ Future cvRunAsync3( return completer.future; } +Future cvRunAsync4( + ffi.Pointer Function(cvg.CvCallback_4 callback) func, + void Function( + Completer completer, + VoidPtr p, + VoidPtr p1, + VoidPtr p2, + VoidPtr p3, + ) onComplete, +) { + final completer = Completer(); + late final NativeCallable 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 cvRunAsync5( ffi.Pointer Function(cvg.CvCallback_5 callback) func, void Function(Completer completer, VoidPtr p, VoidPtr p1, VoidPtr p2, VoidPtr p3, VoidPtr p4) onComplete, diff --git a/lib/src/dnn/dnn.dart b/lib/src/dnn/dnn.dart index c6c8bf0b..110abc27 100644 --- a/lib/src/dnn/dnn.dart +++ b/lib/src/dnn/dnn.dart @@ -95,6 +95,11 @@ class Net extends CvStruct { 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(); diff --git a/lib/src/dnn/dnn_async.dart b/lib/src/dnn/dnn_async.dart new file mode 100644 index 00000000..a8d6c008 --- /dev/null +++ b/lib/src/dnn/dnn_async.dart @@ -0,0 +1,416 @@ +library cv; + +import 'dart:ffi' as ffi; +import 'dart:typed_data'; +import 'package:ffi/ffi.dart'; +import './dnn.dart'; + +import '../core/base.dart'; +import '../core/mat.dart'; +import '../core/mat_type.dart'; +import '../core/rect.dart'; +import '../core/scalar.dart'; +import '../core/size.dart'; +import '../core/vec.dart'; +import '../opencv.g.dart' as cvg; + +extension LayerAsync on Layer { + Future get nameAsync async { + final rval = cvRunAsync( + (callback) => CFFI.Layer_GetName_Async(ref, callback), + (c, p) { + final rval = p.cast>().value.toDartString(); + calloc.free(p); + return c.complete(rval); + }, + ); + return rval; + } + + Future get typeAsync async { + final rval = cvRunAsync( + (callback) => CFFI.Layer_GetType_Async(ref, callback), + (c, p) { + final rval = p.cast>().value.toDartString(); + calloc.free(p); + return c.complete(rval); + }, + ); + return rval; + } + + Future inputNameToIndexAsync(String name) async { + final cName = name.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.Layer_InputNameToIndex_Async(ref, cName, callback), + (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }, + ); + calloc.free(cName); + + return rval; + } + + Future outputNameToIndexAsync(String name) async { + final cName = name.toNativeUtf8().cast(); + final rval = cvRunAsync( + (callback) => CFFI.Layer_OutputNameToIndex_Async(ref, cName, callback), + (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }, + ); + calloc.free(cName); + return rval; + } +} + +extension NetAsync on Net { + static Future emptyAsync() async { + final rval = await cvRunAsync(CFFI.Net_Create_Async, (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + + return rval; + } + + static Future fromFileAsync(String path, {String config = "", String framework = ""}) async { + final cPath = path.toNativeUtf8().cast(); + final cConfig = config.toNativeUtf8().cast(); + final cFramework = framework.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNet_Async(cPath, cConfig, cFramework, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + calloc.free(cPath); + calloc.free(cConfig); + calloc.free(cFramework); + + return rval; + } + + static Future fromBytesAsync(String framework, Uint8List bufferModel, + {Uint8List? bufferConfig}) async { + bufferConfig ??= Uint8List(0); + final cFramework = framework.toNativeUtf8().cast(); + final bufM = VecUChar.fromList(bufferModel); + final bufC = VecUChar.fromList(bufferConfig); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNetBytes_Async(cFramework, bufM.ref, bufC.ref, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + + calloc.free(cFramework); + + return rval; + } + + static Future fromCaffeAsync(String prototxt, String caffeModel) async { + final cProto = prototxt.toNativeUtf8().cast(); + final cCaffe = caffeModel.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNetFromCaffe_Async(cProto, cCaffe, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + calloc.free(cProto); + calloc.free(cCaffe); + + return rval; + } + + static Future fromCaffeBytesAsync(Uint8List bufferProto, Uint8List bufferModel) async { + final bufP = VecUChar.fromList(bufferProto); + final bufM = VecUChar.fromList(bufferModel); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNetFromCaffeBytes_Async(bufP.ref, bufM.ref, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + return rval; + } + + static Future fromOnnxAsync(String path) async { + final cpath = path.toNativeUtf8().cast(); + final rval = await cvRunAsync((callback) => CFFI.Net_ReadNetFromONNX_Async(cpath, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + calloc.free(cpath); + + return rval; + } + + static Future fromOnnxBytesAsync(Uint8List bufferModel) async { + final bufM = VecUChar.fromList(bufferModel); + final rval = + await cvRunAsync((callback) => CFFI.Net_ReadNetFromONNXBytes_Async(bufM.ref, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + return rval; + } + + static Future fromTensorflowAsync(String path, {String config = ""}) async { + final cpath = path.toNativeUtf8().cast(); + final cconf = config.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNetFromTensorflow_Async(cpath, cconf, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + calloc.free(cpath); + calloc.free(cconf); + + return rval; + } + + static Future fromTensorflowBytesAsync(Uint8List bufferModel, {Uint8List? bufferConfig}) async { + bufferConfig ??= Uint8List(0); + final bufM = VecUChar.fromList(bufferModel); + final bufC = VecUChar.fromList(bufferConfig); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNetFromTensorflowBytes_Async(bufM.ref, bufC.ref, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + return rval; + } + + static Future fromTFLiteAsync(String path) async { + final cpath = path.toNativeUtf8().cast(); + final rval = + await cvRunAsync((callback) => CFFI.Net_ReadNetFromTFLite_Async(cpath, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + calloc.free(cpath); + return rval; + } + + static Future fromTFLiteBytesAsync(Uint8List bufferModel) async { + final bufM = VecUChar.fromList(bufferModel); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNetFromTFLiteBytes_Async(bufM.ref, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + return rval; + } + + static Future fromTorchAsync(String path, {bool isBinary = true, bool evaluate = true}) async { + final cpath = path.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.Net_ReadNetFromTorch_Async(cpath, isBinary, evaluate, callback), (c, p) { + return c.complete(Net.fromPointer(p.cast())); + }); + calloc.free(cpath); + return rval; + } + + Future isEmptyAsync() async { + final rval = cvRunAsync( + (callback) => CFFI.Net_Empty_Async(ref, callback), + (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }, + ); + return rval; + } + + Future dumpAsync() async { + final rval = cvRunAsync( + (callback) => CFFI.Net_Dump_Async(ref, callback), + (c, p) { + final rval = p.cast>().value.toDartString(); + calloc.free(p); + return c.complete(rval); + }, + ); + return rval; + } + + Future setInputAsync(InputArray blob, {String name = ""}) async { + final cname = name.toNativeUtf8().cast(); + await cvRunAsync0( + (callback) => CFFI.Net_SetInput_Async(ref, blob.ref, cname, callback), + (c) { + return c.complete(); + }, + ); + calloc.free(cname); + } + + Future forwardAsync({String outputName = ""}) async { + final rval = cvRunAsync( + (callback) => CFFI.Net_Forward_Async(ref, outputName.toNativeUtf8().cast(), callback), + (c, result) => c.complete(Mat.fromPointer(result.cast())), + ); + return rval; + } + + Future forwardLayersAsync(List names) async { + final vecName = names.i8; + final rval = cvRunAsync( + (callback) => CFFI.Net_ForwardLayers_Async(ref, vecName.ref, callback), + (c, result) => c.complete(VecMat.fromPointer(result.cast())), + ); + return rval; + } + + Future setPreferableBackendAsync(int backendId) async { + await cvRunAsync0( + (callback) => CFFI.Net_SetPreferableBackend_Async(ref, backendId, callback), + (c) => c.complete(), + ); + } + + Future setPreferableTargetAsync(int targetId) async { + await cvRunAsync0( + (callback) => CFFI.Net_SetPreferableTarget_Async(ref, targetId, callback), + (c) => c.complete(), + ); + } + + Future getPerfProfileAsync() async { + final rval = cvRunAsync( + (callback) => CFFI.Net_GetPerfProfile_Async(ref, callback), + (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }, + ); + return rval; + } + + Future getUnconnectedOutLayersAsync() async { + final rval = cvRunAsync( + (callback) => CFFI.Net_GetUnconnectedOutLayers_Async(ref, callback), + (c, result) => c.complete(VecInt.fromPointer(result.cast())), + ); + return rval; + } + + Future> getLayerNamesAsync() async { + final rval = cvRunAsync>( + (callback) => CFFI.Net_GetLayerNames_Async(ref, callback), + (c, result) => c.complete(VecVecChar.fromPointer(result.cast()).asStringList()), + ); + return rval; + } + + Future<(VecFloat, VecInt)> getInputDetailsAsync() async { + final rval = cvRunAsync2<(VecFloat, VecInt)>( + (callback) => CFFI.Net_GetInputDetails_Async(ref, callback), + (c, sc, zp) => c.complete( + (VecFloat.fromPointer(sc.cast()), VecInt.fromPointer(zp.cast()))), + ); + return rval; + } + + Future getLayerAsync(int index) async { + final rval = cvRunAsync( + (callback) => CFFI.Net_GetLayer_Async(ref, index, callback), + (c, result) => c.complete(Layer.fromPointer(result.cast())), + ); + return rval; + } +} + +Future getBlobChannelAsync(Mat blob, int imgidx, int chnidx) async { + final rval = cvRunAsync( + (callback) => CFFI.Net_GetBlobChannel_Async(blob.ref, imgidx, chnidx, callback), + (c, result) => c.complete(Mat.fromPointer(result.cast())), + ); + return rval; +} + +Future getBlobSizeAsync(Mat blob) async { + final rval = cvRunAsync( + (callback) => CFFI.Net_GetBlobSize_Async(blob.ref, callback), + (c, result) => c.complete(Scalar.fromPointer(result.cast())), + ); + return rval; +} + +Future> NMSBoxesAsync( + VecRect bboxes, + VecFloat scores, + double scoreThreshold, + double nmsThreshold, { + double eta = 1.0, + int topK = 0, +}) async { + final rval = cvRunAsync>( + (callback) => CFFI.NMSBoxesWithParams_Async( + bboxes.ref, + scores.ref, + scoreThreshold, + nmsThreshold, + eta, + topK, + callback, + ), + (c, result) => c.complete(VecInt.fromPointer(result.cast()).toList()), + ); + return rval; +} + +Future blobFromImageAsync( + InputArray image, { + double scalefactor = 1.0, + (int, int) size = (0, 0), + Scalar? mean, + bool swapRB = false, + bool crop = false, + int ddepth = MatType.CV_32F, +}) async { + mean ??= Scalar.zeros; + final rval = await cvRunAsync( + (callback) => CFFI.Net_BlobFromImage_Async( + image.ref, + scalefactor, + size.cvd.ref, + mean!.ref, + swapRB, + crop, + ddepth, + callback, + ), + (c, mat) => c.complete(Mat.fromPointer(mat.cast())), + ); + return rval; +} + +Future blobFromImagesAsync( + VecMat images, { + double scalefactor = 1.0, + (int, int) size = (0, 0), + Scalar? mean, + bool swapRB = false, + bool crop = false, + int ddepth = MatType.CV_32F, +}) async { + mean ??= Scalar.zeros; + final rval = await cvRunAsync( + (callback) => CFFI.Net_BlobFromImages_Async( + images.ref, + scalefactor, + size.cvd.ref, + mean!.ref, + swapRB, + crop, + ddepth, + callback, + ), + (c, blob) => c.complete(Mat.fromPointer(blob.cast())), + ); + return rval; +} + +Future> imagesFromBlobAsync(Mat blob) async { + final rval = cvRunAsync>( + (callback) => CFFI.Net_ImagesFromBlob_Async(blob.ref, callback), + (c, result) => c.complete(VecMat.fromPointer(result.cast()).toList()), + ); + return rval; +} diff --git a/lib/src/objdetect/objdetect.dart b/lib/src/objdetect/objdetect.dart index b6630284..532cd4fb 100644 --- a/lib/src/objdetect/objdetect.dart +++ b/lib/src/objdetect/objdetect.dart @@ -21,6 +21,11 @@ class CascadeClassifier extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory CascadeClassifier.fromPointer( + cvg.CascadeClassifierPtr ptr, [ + bool attach = true, + ]) => + CascadeClassifier._(ptr, attach); factory CascadeClassifier.empty() { final p = calloc(); @@ -194,6 +199,11 @@ class HOGDescriptor extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory HOGDescriptor.fromPointer( + cvg.HOGDescriptorPtr ptr, [ + bool attach = true, + ]) => + HOGDescriptor._(ptr, attach); factory HOGDescriptor.empty() { final p = calloc(); @@ -454,6 +464,11 @@ class QRCodeDetector extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory QRCodeDetector.fromPointer( + cvg.QRCodeDetectorPtr ptr, [ + bool attach = true, + ]) => + QRCodeDetector._(ptr, attach); factory QRCodeDetector.empty() { final p = calloc(); @@ -619,6 +634,11 @@ class FaceDetectorYN extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory FaceDetectorYN.fromPointer( + cvg.FaceDetectorYNPtr ptr, [ + bool attach = true, + ]) => + FaceDetectorYN._(ptr, attach); /// Creates an instance of face detector class with given parameters. /// @@ -843,6 +863,11 @@ class FaceRecognizerSF extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory FaceRecognizerSF.fromPointer( + cvg.FaceRecognizerSFPtr ptr, [ + bool attach = true, + ]) => + FaceRecognizerSF._(ptr, attach); @Deprecated("Use FaceRecognizerSF.fromFile instead, will be removed in 1.1.0") factory FaceRecognizerSF.newRecognizer( diff --git a/lib/src/objdetect/objdetect_async.dart b/lib/src/objdetect/objdetect_async.dart new file mode 100644 index 00000000..203e7ff8 --- /dev/null +++ b/lib/src/objdetect/objdetect_async.dart @@ -0,0 +1,767 @@ +library cv; + +import 'dart:ffi' as ffi; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; + +import '../core/base.dart'; +import '../core/mat.dart'; +import '../core/point.dart'; +import '../core/rect.dart'; +import '../core/size.dart'; +import '../core/vec.dart'; +import '../opencv.g.dart' as cvg; +import './objdetect.dart'; + +extension CascadeClassifierAsync on CascadeClassifier { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.CascadeClassifier_New_Async(callback), + (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast()))); + + static Future fromFileAsync(String filename) async { + final cp = filename.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.CascadeClassifier_NewFromFile_Async(cp, callback), (c, p) { + return c.complete(CascadeClassifier.fromPointer(p.cast())); + }); + calloc.free(cp); + return rval; + } + + Future loadAsync(String name) async { + final cname = name.toNativeUtf8().cast(); + final rval = + cvRunAsync((callback) => CFFI.CascadeClassifier_Load_Async(ref, cname, callback), (c, p) { + final rval = p.cast().value != 0; + calloc.free(p); + return c.complete(rval); + }); + calloc.free(cname); + + return rval; + } + + Future detectMultiScaleAsync( + InputArray image, { + double scaleFactor = 1.1, + int minNeighbors = 3, + int flags = 0, + (int, int) minSize = (0, 0), + (int, int) maxSize = (0, 0), + }) async { + final rval = cvRunAsync( + (callback) => CFFI.CascadeClassifier_DetectMultiScaleWithParams_Async( + ref, + image.ref, + scaleFactor, + minNeighbors, + flags, + minSize.cvd.ref, + maxSize.cvd.ref, + callback, + ), (c, ret) { + return c.complete(VecRect.fromPointer(ret.cast())); + }); + return rval; + } + + Future<(VecRect objects, VecInt numDetections)> detectMultiScale2Async( + InputArray image, { + double scaleFactor = 1.1, + int minNeighbors = 3, + int flags = 0, + (int, int) minSize = (0, 0), + (int, int) maxSize = (0, 0), + }) async { + final rval = cvRunAsync2<(VecRect, VecInt)>( + (callback) => CFFI.CascadeClassifier_DetectMultiScale2_Async( + ref, + image.ref, + scaleFactor, + minNeighbors, + flags, + minSize.cvd.ref, + maxSize.cvd.ref, + callback, + ), (c, ret, pnums) { + return c.complete( + (VecRect.fromPointer(ret.cast()), VecInt.fromPointer(pnums.cast())), + ); + }); + return rval; + } + + Future<(VecRect objects, VecInt rejectLevels, VecDouble levelWeights)> detectMultiScale3Async( + InputArray image, { + double scaleFactor = 1.1, + int minNeighbors = 3, + int flags = 0, + (int, int) minSize = (0, 0), + (int, int) maxSize = (0, 0), + bool outputRejectLevels = false, + }) async { + final rval = cvRunAsync3<(VecRect, VecInt, VecDouble)>( + (callback) => CFFI.CascadeClassifier_DetectMultiScale3_Async( + ref, + image.ref, + scaleFactor, + minNeighbors, + flags, + minSize.cvd.ref, + maxSize.cvd.ref, + outputRejectLevels, + callback, + ), + (c, p1, p2, p3) => c.complete( + ( + VecRect.fromPointer(p1.cast()), + VecInt.fromPointer(p2.cast()), + VecDouble.fromPointer(p3.cast()) + ), + ), + ); + return rval; + } + + Future emptyAsync() async { + final rval = cvRunAsync((callback) => CFFI.CascadeClassifier_Empty_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } + + Future getFeatureTypeAsync() async { + final rval = + cvRunAsync((callback) => CFFI.CascadeClassifier_getFeatureType_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + + return c.complete(rval); + }); + return rval; + } + + Future<(int, int)> getOriginalWindowSizeAsync() async { + final rval = cvRunAsync<(int, int)>( + (callback) => CFFI.CascadeClassifier_getOriginalWindowSize_Async(ref, callback), (c, p) { + final size = p.cast().ref; + final ret = (size.width, size.height); + return c.complete(ret); + }); + return rval; + } + + Future isOldFormatCascadeAsync() async { + final rval = cvRunAsync( + (callback) => CFFI.CascadeClassifier_isOldFormatCascade_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } +} + +extension HOGDescriptorAsync on HOGDescriptor { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.HOGDescriptor_New_Async(callback), + (c, p) => c.complete(HOGDescriptor.fromPointer(p.cast()))); + + static Future fromFileAsync(String filename) async { + final cp = filename.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.HOGDescriptor_NewFromFile_Async(cp, callback), (c, p) { + return c.complete(HOGDescriptor.fromPointer(p.cast())); + }); + calloc.free(cp); + return rval; + } + + Future loadAsync(String name) async { + final cname = name.toNativeUtf8().cast(); + final rval = cvRunAsync((callback) => CFFI.HOGDescriptor_Load_Async(ref, cname, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + + return c.complete(rval); + }); + calloc.free(cname); + return rval; + } + + Future<(VecFloat descriptors, VecPoint locations)> computeAsync( + Mat img, { + (int, int) winStride = (0, 0), + (int, int) padding = (0, 0), + }) async { + final rval = cvRunAsync2<(VecFloat, VecPoint)>( + (callback) => CFFI.HOGDescriptor_Compute_Async( + ref, + img.ref, + winStride.cvd.ref, + padding.cvd.ref, + callback, + ), (c, descriptors, locations) { + return c.complete( + ( + VecFloat.fromPointer(descriptors.cast()), + VecPoint.fromPointer(locations.cast()) + ), + ); + }); + return rval; + } + + Future<(Mat grad, Mat angleOfs)> computeGradientAsync( + InputArray img, + Mat grad, + Mat angleOfs, { + (int, int) paddingTL = (0, 0), + (int, int) paddingBR = (0, 0), + }) async { + final rval = cvRunAsync0<(Mat, Mat)>( + (callback) => CFFI.HOGDescriptor_computeGradient_Async( + ref, + img.ref, + grad.ref, + angleOfs.ref, + paddingTL.cvd.ref, + paddingBR.cvd.ref, + callback, + ), (c) { + return c.complete((grad, angleOfs)); + }); + return rval; + } + + Future<(VecPoint foundLocations, VecDouble weights, VecPoint searchLocations)> detect2Async( + InputArray img, { + double hitThreshold = 0, + (int, int) winStride = (0, 0), + (int, int) padding = (0, 0), + }) async { + final rval = cvRunAsync3<(VecPoint, VecDouble, VecPoint)>( + (callback) => CFFI.HOGDescriptor_Detect_Async( + ref, + img.ref, + hitThreshold, + winStride.cvd.ref, + padding.cvd.ref, + callback, + ), (c, foundLocations, weights, searchLocations) { + return c.complete( + ( + VecPoint.fromPointer(foundLocations.cast()), + VecDouble.fromPointer(weights.cast()), + VecPoint.fromPointer(searchLocations.cast()) + ), + ); + }); + return rval; + } + + Future<(VecPoint foundLocations, VecPoint searchLocations)> detectAsync( + InputArray img, { + double hitThreshold = 0, + (int, int) winStride = (0, 0), + (int, int) padding = (0, 0), + }) async { + final rval = cvRunAsync2<(VecPoint, VecPoint)>( + (callback) => CFFI.HOGDescriptor_Detect2_Async( + ref, + img.ref, + hitThreshold, + winStride.cvd.ref, + padding.cvd.ref, + callback, + ), (c, foundLocations, searchLocations) { + return c.complete( + ( + VecPoint.fromPointer(foundLocations.cast()), + VecPoint.fromPointer(searchLocations.cast()) + ), + ); + }); + return rval; + } + + Future detectMultiScaleAsync( + InputArray image, { + double hitThreshold = 0, + int minNeighbors = 3, + (int, int) winStride = (0, 0), + (int, int) padding = (0, 0), + double scale = 1.05, + double groupThreshold = 2.0, + bool useMeanshiftGrouping = false, + }) async { + final rval = cvRunAsync( + (callback) => CFFI.HOGDescriptor_DetectMultiScaleWithParams_Async( + ref, + image.ref, + hitThreshold, + winStride.cvd.ref, + padding.cvd.ref, + scale, + groupThreshold, + useMeanshiftGrouping, + callback, + ), (c, rects) { + return c.complete(VecRect.fromPointer(rects.cast())); + }); + return rval; + } + + static Future getDefaultPeopleDetectorAsync() async { + final rval = cvRunAsync(CFFI.HOG_GetDefaultPeopleDetector_Async, (c, v) { + return c.complete(VecFloat.fromPointer(v.cast())); + }); + return rval; + } + + static Future getDaimlerPeopleDetectorAsync() async { + final rval = cvRunAsync(CFFI.HOGDescriptor_getDaimlerPeopleDetector_Async, (c, v) { + return c.complete(VecFloat.fromPointer(v.cast())); + }); + return rval; + } + + Future getDescriptorSizeAsync() async { + final rval = + cvRunAsync((callback) => CFFI.HOGDescriptor_getDescriptorSize_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } + + Future getWinSigmaAsync() async { + final rval = + cvRunAsync((callback) => CFFI.HOGDescriptor_getWinSigma_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } + + Future<(VecRect rectList, VecDouble weights)> groupRectanglesAsync( + VecRect rectList, + VecDouble weights, + int groupThreshold, + double eps, + ) async { + final rval = cvRunAsync0<(VecRect, VecDouble)>( + (callback) => CFFI.HOGDescriptor_groupRectangles_Async( + ref, + rectList.ref, + weights.ref, + groupThreshold, + eps, + callback, + ), (c) { + return c.complete((rectList, weights)); + }); + return rval; + } + + Future setSVMDetectorAsync(VecFloat det) async { + await cvRunAsync0((callback) => CFFI.HOGDescriptor_SetSVMDetector_Async(ref, det.ref, callback), + (c) { + return c.complete(); + }); + } +} + +Future groupRectanglesAsync( + VecRect rects, + int groupThreshold, + double eps, +) async { + final rval = cvRunAsync0( + (callback) => CFFI.GroupRectangles_Async(rects.ref, groupThreshold, eps, callback), (c) { + return c.complete(rects); + }); + return rval; +} + +extension QRCodeDetectorAsync on QRCodeDetector { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.QRCodeDetector_New_Async(callback), + (c, p) => c.complete(QRCodeDetector.fromPointer(p.cast()))); + + Future<(String rval, Mat straightQRcode)> decodeCurvedAsync( + InputArray img, + VecPoint points, + ) async { + final rval = cvRunAsync2<(String, Mat)>( + (callback) => CFFI.QRCodeDetector_decodeCurved_Async( + ref, + img.ref, + points.ref, + callback, + ), (c, prval, pstraightQRcode) { + // prval is a char ** pointer + final rval = prval.cast>().value.toDartString(); + calloc.free(prval); + return c.complete( + (rval, Mat.fromPointer(pstraightQRcode.cast())), + ); + }); + return rval; + } + + Future<(String rval, VecPoint points, Mat straightQRcode)> detectAndDecodeCurvedAsync( + InputArray img, + ) async { + final rval = cvRunAsync3<(String, VecPoint, Mat)>( + (callback) => CFFI.QRCodeDetector_detectAndDecodeCurved_Async( + ref, + img.ref, + callback, + ), (c, prval, points, straightQRcode) { + // prval is a char ** pointer + final rval = prval.cast>().value.toDartString(); + calloc.free(prval); + return c.complete( + ( + rval, + VecPoint.fromPointer(points.cast()), + Mat.fromPointer(straightQRcode.cast()), + ), + ); + }); + return rval; + } + + Future<(String ret, VecPoint points, Mat straightCode)> detectAndDecodeAsync(InputArray img) async { + final rval = cvRunAsync3<(String, VecPoint, Mat)>( + (callback) => CFFI.QRCodeDetector_DetectAndDecode_Async(ref, img.ref, callback), + (c, prval, points, straightCode) { + // prval is a char ** pointer + final rval = prval.cast>().value.toDartString(); + calloc.free(prval); + return c.complete( + ( + rval, + VecPoint.fromPointer(points.cast()), + Mat.fromPointer(straightCode.cast()), + ), + ); + }); + return rval; + } + + Future<(bool ret, VecPoint points)> detectAsync( + InputArray input, { + VecPoint? points, + }) async { + final rval = cvRunAsync2<(bool, VecPoint)>( + (callback) => CFFI.QRCodeDetector_Detect_Async(ref, input.ref, callback), (c, ret, points) { + final retValue = ret.cast().value; + calloc.free(ret); + return c.complete( + (retValue, VecPoint.fromPointer(points.cast())), + ); + }); + return rval; + } + + Future<(String ret, VecPoint? points, Mat? straightCode)> decodeAsync( + InputArray img, + ) async { + final rval = cvRunAsync3<(String, VecPoint, Mat)>( + (callback) => CFFI.QRCodeDetector_Decode_Async(ref, img.ref, callback), + (c, prval, points, straightCode) { + // prval is a char ** pointer + final rval = prval.cast>().value.toDartString(); + calloc.free(prval); + return c.complete( + ( + rval, + VecPoint.fromPointer(points.cast()), + Mat.fromPointer(straightCode.cast()), + ), + ); + }); + return rval; + } + + Future<(bool ret, VecPoint points)> detectMultiAsync( + InputArray img, + ) async { + final rval = cvRunAsync2<(bool, VecPoint)>( + (callback) => CFFI.QRCodeDetector_DetectMulti_Async(ref, img.ref, callback), (c, ret, points) { + final retValue = ret.cast().value; + calloc.free(ret); + return c.complete((retValue, VecPoint.fromPointer(points.cast()))); + }); + return rval; + } + + Future<(bool, List, VecPoint, VecMat)> detectAndDecodeMultiAsync( + InputArray img, + ) async { + final ret = cvRunAsync4<(bool, List, VecPoint, VecMat)>( + (callback) => CFFI.QRCodeDetector_DetectAndDecodeMulti_Async( + ref, + img.ref, + callback, + ), (c, rval, info, points, codes) { + final rvalValue = rval.cast().value; + calloc.free(rval); + final ret = ( + rvalValue, + VecVecChar.fromPointer(info.cast()).asStringList(), + VecPoint.fromPointer(points.cast()), + VecMat.fromPointer(codes.cast()) + ); + return c.complete(ret); + }); + return ret; + } + + Future setEpsXAsync(double epsX) async { + await cvRunAsync0((callback) => CFFI.QRCodeDetector_setEpsX_Async(ref, epsX, callback), (c) { + return c.complete(); + }); + } + + Future setEpsYAsync(double epsY) async { + await cvRunAsync0((callback) => CFFI.QRCodeDetector_setEpsY_Async(ref, epsY, callback), (c) { + return c.complete(); + }); + } + + Future setUseAlignmentMarkersAsync(bool useAlignmentMarkers) async { + await cvRunAsync0( + (callback) => CFFI.QRCodeDetector_setUseAlignmentMarkers_Async( + ref, + useAlignmentMarkers, + callback, + ), (c) { + return c.complete(); + }); + } +} + +extension FaceDetectorYNAsync on FaceDetectorYN { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.CascadeClassifier_New_Async(callback), + (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast()))); + + static Future fromFileAsync( + String model, + String config, + (int, int) inputSize, { + double scoreThreshold = 0.9, + double nmsThreshold = 0.3, + int topK = 5000, + int backendId = 0, + int targetId = 0, + }) async { + final cModel = model.toNativeUtf8().cast(); + final cConfig = config.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.FaceDetectorYN_New_Async(cModel, cConfig, inputSize.cvd.ref, scoreThreshold, + nmsThreshold, topK, backendId, targetId, callback), (c, p) { + return c.complete(FaceDetectorYN.fromPointer(p.cast())); + }); + calloc.free(cModel); + calloc.free(cConfig); + return rval; + } + + static Future fromBufferAsync( + String framework, + Uint8List bufferModel, + Uint8List bufferConfig, + (int, int) inputSize, { + double scoreThreshold = 0.9, + double nmsThreshold = 0.3, + int topK = 5000, + int backendId = 0, + int targetId = 0, + }) async { + final cFramework = framework.toNativeUtf8().cast(); + + final rval = await cvRunAsync( + (callback) => CFFI.FaceDetectorYN_NewFromBuffer_Async( + cFramework, + VecUChar.fromList(bufferModel).ref, + VecUChar.fromList(bufferConfig).ref, + inputSize.cvd.ref, + scoreThreshold, + nmsThreshold, + topK, + backendId, + targetId, + callback), (c, p) { + return c.complete(FaceDetectorYN.fromPointer(p.cast())); + }); + calloc.free(cFramework); + + return rval; + } + + Future<(int, int)> getInputSizeAsync() async { + final rval = + cvRunAsync<(int, int)>((callback) => CFFI.FaceDetectorYN_GetInputSize_Async(ref, callback), (c, p) { + final size = p.cast().ref; + final ret = (size.width, size.height); + return c.complete(ret); + }); + return rval; + } + + Future getScoreThresholdAsync() async { + final rval = + cvRunAsync((callback) => CFFI.FaceDetectorYN_GetScoreThreshold_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } + + Future getNmsThresholdAsync() async { + final rval = + cvRunAsync((callback) => CFFI.FaceDetectorYN_GetNMSThreshold_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } + + Future getTopKAsync() async { + final rval = cvRunAsync((callback) => CFFI.FaceDetectorYN_GetTopK_Async(ref, callback), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } + + Future detectAsync(Mat image) async { + final rval = + cvRunAsync((callback) => CFFI.FaceDetectorYN_Detect_Async(ref, image.ref, callback), (c, p) { + return c.complete(Mat.fromPointer(p.cast())); + }); + return rval; + } + + Future setInputSizeAsync((int, int) inputSize) async { + await cvRunAsync0( + (callback) => CFFI.FaceDetectorYN_SetInputSize_Async( + ref, + inputSize.cvd.ref, + callback, + ), (c) { + return c.complete(); + }); + } + + Future setScoreThresholdAsync(double scoreThreshold) async { + await cvRunAsync0( + (callback) => CFFI.FaceDetectorYN_SetScoreThreshold_Async( + ref, + scoreThreshold, + callback, + ), (c) { + return c.complete(); + }); + } + + Future setNMSThresholdAsync(double nmsThreshold) async { + await cvRunAsync0( + (callback) => CFFI.FaceDetectorYN_SetNMSThreshold_Async( + ref, + nmsThreshold, + callback, + ), (c) { + return c.complete(); + }); + } + + Future setTopKAsync(int topK) async { + await cvRunAsync0((callback) => CFFI.FaceDetectorYN_SetTopK_Async(ref, topK, callback), (c) { + return c.complete(); + }); + } +} + +extension FaceRecognizerSFAsync on FaceRecognizerSF { + static Future fromFileAsync( + String model, + String config, { + int backendId = 0, + int targetId = 0, + }) async { + final cModel = model.toNativeUtf8().cast(); + final cConfig = config.toNativeUtf8().cast(); + final rval = await cvRunAsync( + (callback) => CFFI.FaceRecognizerSF_New_Async( + cModel, + cConfig, + backendId, + targetId, + callback, + ), (c, p) { + return c.complete(FaceRecognizerSF.fromPointer(p.cast())); + }); + calloc.free(cModel); + calloc.free(cConfig); + return rval; + } + + Future alignCropAsync(Mat srcImg, Mat faceBox) async { + final rval = cvRunAsync( + (callback) => CFFI.FaceRecognizerSF_AlignCrop_Async( + ref, + srcImg.ref, + faceBox.ref, + callback, + ), (c, p) { + return c.complete(Mat.fromPointer(p.cast())); + }); + return rval; + } + + Future featureAsync(Mat alignedImg, {bool clone = false}) async { + final rval = cvRunAsync( + (callback) => CFFI.FaceRecognizerSF_Feature_Async( + ref, + alignedImg.ref, + clone, + callback, + ), (c, p) { + return c.complete(Mat.fromPointer(p.cast())); + }); + return rval; + } + + Future matchAsync( + Mat faceFeature1, + Mat faceFeature2, { + int disType = FaceRecognizerSF.FR_COSINE, + }) async { + final rval = cvRunAsync( + (callback) => CFFI.FaceRecognizerSF_Match_Async( + ref, + faceFeature1.ref, + faceFeature2.ref, + disType, + callback, + ), (c, p) { + final rval = p.cast().value; + calloc.free(p); + return c.complete(rval); + }); + return rval; + } +} diff --git a/lib/src/opencv.g.dart b/lib/src/opencv.g.dart index 68dc7002..c4450e2d 100644 --- a/lib/src/opencv.g.dart +++ b/lib/src/opencv.g.dart @@ -2715,6 +2715,44 @@ class CvNative { Size, Size)>(); + ffi.Pointer CascadeClassifier_DetectMultiScale2_Async( + CascadeClassifier self, + Mat img, + double scaleFactor, + int minNeighbors, + int flags, + Size minSize, + Size maxSize, + CvCallback_2 callback, + ) { + return _CascadeClassifier_DetectMultiScale2_Async( + self, + img, + scaleFactor, + minNeighbors, + flags, + minSize, + maxSize, + callback, + ); + } + + late final _CascadeClassifier_DetectMultiScale2_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + CascadeClassifier, + Mat, + ffi.Double, + ffi.Int, + ffi.Int, + Size, + Size, + CvCallback_2)>>('CascadeClassifier_DetectMultiScale2_Async'); + late final _CascadeClassifier_DetectMultiScale2_Async = + _CascadeClassifier_DetectMultiScale2_AsyncPtr.asFunction< + ffi.Pointer Function(CascadeClassifier, Mat, double, int, + int, Size, Size, CvCallback_2)>(); + ffi.Pointer CascadeClassifier_DetectMultiScale3( CascadeClassifier self, Mat img, @@ -2772,6 +2810,47 @@ class CvNative { Size, bool)>(); + ffi.Pointer CascadeClassifier_DetectMultiScale3_Async( + CascadeClassifier self, + Mat img, + double scaleFactor, + int minNeighbors, + int flags, + Size minSize, + Size maxSize, + bool outputRejectLevels, + CvCallback_3 callback, + ) { + return _CascadeClassifier_DetectMultiScale3_Async( + self, + img, + scaleFactor, + minNeighbors, + flags, + minSize, + maxSize, + outputRejectLevels, + callback, + ); + } + + late final _CascadeClassifier_DetectMultiScale3_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + CascadeClassifier, + Mat, + ffi.Double, + ffi.Int, + ffi.Int, + Size, + Size, + ffi.Bool, + CvCallback_3)>>('CascadeClassifier_DetectMultiScale3_Async'); + late final _CascadeClassifier_DetectMultiScale3_Async = + _CascadeClassifier_DetectMultiScale3_AsyncPtr.asFunction< + ffi.Pointer Function(CascadeClassifier, Mat, double, int, + int, Size, Size, bool, CvCallback_3)>(); + ffi.Pointer CascadeClassifier_DetectMultiScaleWithParams( CascadeClassifier self, Mat img, @@ -2810,6 +2889,59 @@ class CvNative { ffi.Pointer Function(CascadeClassifier, Mat, ffi.Pointer, double, int, int, Size, Size)>(); + ffi.Pointer CascadeClassifier_DetectMultiScaleWithParams_Async( + CascadeClassifier self, + Mat img, + double scale, + int minNeighbors, + int flags, + Size minSize, + Size maxSize, + CvCallback_1 callback, + ) { + return _CascadeClassifier_DetectMultiScaleWithParams_Async( + self, + img, + scale, + minNeighbors, + flags, + minSize, + maxSize, + callback, + ); + } + + late final _CascadeClassifier_DetectMultiScaleWithParams_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(CascadeClassifier, Mat, ffi.Double, + ffi.Int, ffi.Int, Size, Size, CvCallback_1)>>( + 'CascadeClassifier_DetectMultiScaleWithParams_Async'); + late final _CascadeClassifier_DetectMultiScaleWithParams_Async = + _CascadeClassifier_DetectMultiScaleWithParams_AsyncPtr.asFunction< + ffi.Pointer Function(CascadeClassifier, Mat, double, int, + int, Size, Size, CvCallback_1)>(); + + ffi.Pointer CascadeClassifier_DetectMultiScale_Async( + CascadeClassifier self, + Mat img, + CvCallback_1 callback, + ) { + return _CascadeClassifier_DetectMultiScale_Async( + self, + img, + callback, + ); + } + + late final _CascadeClassifier_DetectMultiScale_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(CascadeClassifier, Mat, + CvCallback_1)>>('CascadeClassifier_DetectMultiScale_Async'); + late final _CascadeClassifier_DetectMultiScale_Async = + _CascadeClassifier_DetectMultiScale_AsyncPtr.asFunction< + ffi.Pointer Function( + CascadeClassifier, Mat, CvCallback_1)>(); + ffi.Pointer CascadeClassifier_Empty( CascadeClassifier self, ffi.Pointer rval, @@ -2828,6 +2960,24 @@ class CvNative { ffi.Pointer Function( CascadeClassifier, ffi.Pointer)>(); + ffi.Pointer CascadeClassifier_Empty_Async( + CascadeClassifier self, + CvCallback_1 callback, + ) { + return _CascadeClassifier_Empty_Async( + self, + callback, + ); + } + + late final _CascadeClassifier_Empty_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(CascadeClassifier, + CvCallback_1)>>('CascadeClassifier_Empty_Async'); + late final _CascadeClassifier_Empty_Async = + _CascadeClassifier_Empty_AsyncPtr.asFunction< + ffi.Pointer Function(CascadeClassifier, CvCallback_1)>(); + ffi.Pointer CascadeClassifier_Load( CascadeClassifier self, ffi.Pointer name, @@ -2850,6 +3000,29 @@ class CvNative { ffi.Pointer Function( CascadeClassifier, ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer CascadeClassifier_Load_Async( + CascadeClassifier self, + ffi.Pointer name, + CvCallback_1 callback, + ) { + return _CascadeClassifier_Load_Async( + self, + name, + callback, + ); + } + + late final _CascadeClassifier_Load_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + CascadeClassifier, + ffi.Pointer, + CvCallback_1)>>('CascadeClassifier_Load_Async'); + late final _CascadeClassifier_Load_Async = + _CascadeClassifier_Load_AsyncPtr.asFunction< + ffi.Pointer Function( + CascadeClassifier, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer CascadeClassifier_New( ffi.Pointer rval, ) { @@ -2885,6 +3058,39 @@ class CvNative { ffi.Pointer Function( ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer CascadeClassifier_NewFromFile_Async( + ffi.Pointer filename, + CvCallback_1 callback, + ) { + return _CascadeClassifier_NewFromFile_Async( + filename, + callback, + ); + } + + late final _CascadeClassifier_NewFromFile_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + CvCallback_1)>>('CascadeClassifier_NewFromFile_Async'); + late final _CascadeClassifier_NewFromFile_Async = + _CascadeClassifier_NewFromFile_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, CvCallback_1)>(); + + ffi.Pointer CascadeClassifier_New_Async( + CvCallback_1 callback, + ) { + return _CascadeClassifier_New_Async( + callback, + ); + } + + late final _CascadeClassifier_New_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'CascadeClassifier_New_Async'); + late final _CascadeClassifier_New_Async = _CascadeClassifier_New_AsyncPtr + .asFunction Function(CvCallback_1)>(); + ffi.Pointer CascadeClassifier_getFeatureType( CascadeClassifier self, ffi.Pointer rval, @@ -2904,6 +3110,24 @@ class CvNative { ffi.Pointer Function( CascadeClassifier, ffi.Pointer)>(); + ffi.Pointer CascadeClassifier_getFeatureType_Async( + CascadeClassifier self, + CvCallback_1 callback, + ) { + return _CascadeClassifier_getFeatureType_Async( + self, + callback, + ); + } + + late final _CascadeClassifier_getFeatureType_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(CascadeClassifier, + CvCallback_1)>>('CascadeClassifier_getFeatureType_Async'); + late final _CascadeClassifier_getFeatureType_Async = + _CascadeClassifier_getFeatureType_AsyncPtr.asFunction< + ffi.Pointer Function(CascadeClassifier, CvCallback_1)>(); + ffi.Pointer CascadeClassifier_getOriginalWindowSize( CascadeClassifier self, ffi.Pointer rval, @@ -2923,6 +3147,24 @@ class CvNative { ffi.Pointer Function( CascadeClassifier, ffi.Pointer)>(); + ffi.Pointer CascadeClassifier_getOriginalWindowSize_Async( + CascadeClassifier self, + CvCallback_1 callback, + ) { + return _CascadeClassifier_getOriginalWindowSize_Async( + self, + callback, + ); + } + + late final _CascadeClassifier_getOriginalWindowSize_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(CascadeClassifier, + CvCallback_1)>>('CascadeClassifier_getOriginalWindowSize_Async'); + late final _CascadeClassifier_getOriginalWindowSize_Async = + _CascadeClassifier_getOriginalWindowSize_AsyncPtr.asFunction< + ffi.Pointer Function(CascadeClassifier, CvCallback_1)>(); + ffi.Pointer CascadeClassifier_isOldFormatCascade( CascadeClassifier self, ffi.Pointer rval, @@ -2942,6 +3184,24 @@ class CvNative { ffi.Pointer Function( CascadeClassifier, ffi.Pointer)>(); + ffi.Pointer CascadeClassifier_isOldFormatCascade_Async( + CascadeClassifier self, + CvCallback_1 callback, + ) { + return _CascadeClassifier_isOldFormatCascade_Async( + self, + callback, + ); + } + + late final _CascadeClassifier_isOldFormatCascade_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(CascadeClassifier, + CvCallback_1)>>('CascadeClassifier_isOldFormatCascade_Async'); + late final _CascadeClassifier_isOldFormatCascade_Async = + _CascadeClassifier_isOldFormatCascade_AsyncPtr.asFunction< + ffi.Pointer Function(CascadeClassifier, CvCallback_1)>(); + ffi.Pointer Circle( Mat img, Point center, @@ -3823,6 +4083,26 @@ class CvNative { late final _FaceDetectorYN_Detect = _FaceDetectorYN_DetectPtr.asFunction< ffi.Pointer Function(FaceDetectorYN, Mat, ffi.Pointer)>(); + ffi.Pointer FaceDetectorYN_Detect_Async( + FaceDetectorYN self, + Mat img, + CvCallback_1 callback, + ) { + return _FaceDetectorYN_Detect_Async( + self, + img, + callback, + ); + } + + late final _FaceDetectorYN_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, Mat, + CvCallback_1)>>('FaceDetectorYN_Detect_Async'); + late final _FaceDetectorYN_Detect_Async = + _FaceDetectorYN_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(FaceDetectorYN, Mat, CvCallback_1)>(); + ffi.Pointer FaceDetectorYN_GetInputSize( FaceDetectorYN self, ffi.Pointer input_size, @@ -3841,6 +4121,24 @@ class CvNative { _FaceDetectorYN_GetInputSizePtr.asFunction< ffi.Pointer Function(FaceDetectorYN, ffi.Pointer)>(); + ffi.Pointer FaceDetectorYN_GetInputSize_Async( + FaceDetectorYN self, + CvCallback_1 callback, + ) { + return _FaceDetectorYN_GetInputSize_Async( + self, + callback, + ); + } + + late final _FaceDetectorYN_GetInputSize_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, + CvCallback_1)>>('FaceDetectorYN_GetInputSize_Async'); + late final _FaceDetectorYN_GetInputSize_Async = + _FaceDetectorYN_GetInputSize_AsyncPtr.asFunction< + ffi.Pointer Function(FaceDetectorYN, CvCallback_1)>(); + ffi.Pointer FaceDetectorYN_GetNMSThreshold( FaceDetectorYN self, ffi.Pointer nms_threshold, @@ -3860,6 +4158,24 @@ class CvNative { ffi.Pointer Function( FaceDetectorYN, ffi.Pointer)>(); + ffi.Pointer FaceDetectorYN_GetNMSThreshold_Async( + FaceDetectorYN self, + CvCallback_1 callback, + ) { + return _FaceDetectorYN_GetNMSThreshold_Async( + self, + callback, + ); + } + + late final _FaceDetectorYN_GetNMSThreshold_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, + CvCallback_1)>>('FaceDetectorYN_GetNMSThreshold_Async'); + late final _FaceDetectorYN_GetNMSThreshold_Async = + _FaceDetectorYN_GetNMSThreshold_AsyncPtr.asFunction< + ffi.Pointer Function(FaceDetectorYN, CvCallback_1)>(); + ffi.Pointer FaceDetectorYN_GetScoreThreshold( FaceDetectorYN self, ffi.Pointer score_threshold, @@ -3879,6 +4195,24 @@ class CvNative { ffi.Pointer Function( FaceDetectorYN, ffi.Pointer)>(); + ffi.Pointer FaceDetectorYN_GetScoreThreshold_Async( + FaceDetectorYN self, + CvCallback_1 callback, + ) { + return _FaceDetectorYN_GetScoreThreshold_Async( + self, + callback, + ); + } + + late final _FaceDetectorYN_GetScoreThreshold_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, + CvCallback_1)>>('FaceDetectorYN_GetScoreThreshold_Async'); + late final _FaceDetectorYN_GetScoreThreshold_Async = + _FaceDetectorYN_GetScoreThreshold_AsyncPtr.asFunction< + ffi.Pointer Function(FaceDetectorYN, CvCallback_1)>(); + ffi.Pointer FaceDetectorYN_GetTopK( FaceDetectorYN self, ffi.Pointer top_k, @@ -3896,6 +4230,24 @@ class CvNative { late final _FaceDetectorYN_GetTopK = _FaceDetectorYN_GetTopKPtr.asFunction< ffi.Pointer Function(FaceDetectorYN, ffi.Pointer)>(); + ffi.Pointer FaceDetectorYN_GetTopK_Async( + FaceDetectorYN self, + CvCallback_1 callback, + ) { + return _FaceDetectorYN_GetTopK_Async( + self, + callback, + ); + } + + late final _FaceDetectorYN_GetTopK_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + FaceDetectorYN, CvCallback_1)>>('FaceDetectorYN_GetTopK_Async'); + late final _FaceDetectorYN_GetTopK_Async = + _FaceDetectorYN_GetTopK_AsyncPtr.asFunction< + ffi.Pointer Function(FaceDetectorYN, CvCallback_1)>(); + ffi.Pointer FaceDetectorYN_New( ffi.Pointer model, ffi.Pointer config, @@ -3997,23 +4349,136 @@ class CvNative { int, ffi.Pointer)>(); - ffi.Pointer FaceDetectorYN_SetInputSize( - FaceDetectorYN self, + ffi.Pointer FaceDetectorYN_NewFromBuffer_Async( + ffi.Pointer framework, + VecUChar buffer, + VecUChar buffer_config, Size input_size, + double score_threshold, + double nms_threshold, + int top_k, + int backend_id, + int target_id, + CvCallback_1 callback, ) { - return _FaceDetectorYN_SetInputSize( - self, + return _FaceDetectorYN_NewFromBuffer_Async( + framework, + buffer, + buffer_config, input_size, + score_threshold, + nms_threshold, + top_k, + backend_id, + target_id, + callback, ); } - late final _FaceDetectorYN_SetInputSizePtr = _lookup< + late final _FaceDetectorYN_NewFromBuffer_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + VecUChar, + VecUChar, + Size, + ffi.Float, + ffi.Float, + ffi.Int, + ffi.Int, + ffi.Int, + CvCallback_1)>>('FaceDetectorYN_NewFromBuffer_Async'); + late final _FaceDetectorYN_NewFromBuffer_Async = + _FaceDetectorYN_NewFromBuffer_AsyncPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, VecUChar, + VecUChar, Size, double, double, int, int, int, CvCallback_1)>(); + + ffi.Pointer FaceDetectorYN_New_Async( + ffi.Pointer model, + ffi.Pointer config, + Size input_size, + double score_threshold, + double nms_threshold, + int top_k, + int backend_id, + int target_id, + CvCallback_1 callback, + ) { + return _FaceDetectorYN_New_Async( + model, + config, + input_size, + score_threshold, + nms_threshold, + top_k, + backend_id, + target_id, + callback, + ); + } + + late final _FaceDetectorYN_New_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + Size, + ffi.Float, + ffi.Float, + ffi.Int, + ffi.Int, + ffi.Int, + CvCallback_1)>>('FaceDetectorYN_New_Async'); + late final _FaceDetectorYN_New_Async = + _FaceDetectorYN_New_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + Size, + double, + double, + int, + int, + int, + CvCallback_1)>(); + + ffi.Pointer FaceDetectorYN_SetInputSize( + FaceDetectorYN self, + Size input_size, + ) { + return _FaceDetectorYN_SetInputSize( + self, + input_size, + ); + } + + late final _FaceDetectorYN_SetInputSizePtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( FaceDetectorYN, Size)>>('FaceDetectorYN_SetInputSize'); late final _FaceDetectorYN_SetInputSize = _FaceDetectorYN_SetInputSizePtr .asFunction Function(FaceDetectorYN, Size)>(); + ffi.Pointer FaceDetectorYN_SetInputSize_Async( + FaceDetectorYN self, + Size input_size, + CvCallback_0 callback, + ) { + return _FaceDetectorYN_SetInputSize_Async( + self, + input_size, + callback, + ); + } + + late final _FaceDetectorYN_SetInputSize_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, Size, + CvCallback_0)>>('FaceDetectorYN_SetInputSize_Async'); + late final _FaceDetectorYN_SetInputSize_Async = + _FaceDetectorYN_SetInputSize_AsyncPtr.asFunction< + ffi.Pointer Function(FaceDetectorYN, Size, CvCallback_0)>(); + ffi.Pointer FaceDetectorYN_SetNMSThreshold( FaceDetectorYN self, double nms_threshold, @@ -4032,6 +4497,27 @@ class CvNative { _FaceDetectorYN_SetNMSThresholdPtr.asFunction< ffi.Pointer Function(FaceDetectorYN, double)>(); + ffi.Pointer FaceDetectorYN_SetNMSThreshold_Async( + FaceDetectorYN self, + double nms_threshold, + CvCallback_0 callback, + ) { + return _FaceDetectorYN_SetNMSThreshold_Async( + self, + nms_threshold, + callback, + ); + } + + late final _FaceDetectorYN_SetNMSThreshold_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, ffi.Float, + CvCallback_0)>>('FaceDetectorYN_SetNMSThreshold_Async'); + late final _FaceDetectorYN_SetNMSThreshold_Async = + _FaceDetectorYN_SetNMSThreshold_AsyncPtr.asFunction< + ffi.Pointer Function( + FaceDetectorYN, double, CvCallback_0)>(); + ffi.Pointer FaceDetectorYN_SetScoreThreshold( FaceDetectorYN self, double score_threshold, @@ -4050,6 +4536,27 @@ class CvNative { _FaceDetectorYN_SetScoreThresholdPtr.asFunction< ffi.Pointer Function(FaceDetectorYN, double)>(); + ffi.Pointer FaceDetectorYN_SetScoreThreshold_Async( + FaceDetectorYN self, + double score_threshold, + CvCallback_0 callback, + ) { + return _FaceDetectorYN_SetScoreThreshold_Async( + self, + score_threshold, + callback, + ); + } + + late final _FaceDetectorYN_SetScoreThreshold_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, ffi.Float, + CvCallback_0)>>('FaceDetectorYN_SetScoreThreshold_Async'); + late final _FaceDetectorYN_SetScoreThreshold_Async = + _FaceDetectorYN_SetScoreThreshold_AsyncPtr.asFunction< + ffi.Pointer Function( + FaceDetectorYN, double, CvCallback_0)>(); + ffi.Pointer FaceDetectorYN_SetTopK( FaceDetectorYN self, int top_k, @@ -4067,6 +4574,26 @@ class CvNative { late final _FaceDetectorYN_SetTopK = _FaceDetectorYN_SetTopKPtr.asFunction< ffi.Pointer Function(FaceDetectorYN, int)>(); + ffi.Pointer FaceDetectorYN_SetTopK_Async( + FaceDetectorYN self, + int top_k, + CvCallback_0 callback, + ) { + return _FaceDetectorYN_SetTopK_Async( + self, + top_k, + callback, + ); + } + + late final _FaceDetectorYN_SetTopK_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceDetectorYN, ffi.Int, + CvCallback_0)>>('FaceDetectorYN_SetTopK_Async'); + late final _FaceDetectorYN_SetTopK_Async = + _FaceDetectorYN_SetTopK_AsyncPtr.asFunction< + ffi.Pointer Function(FaceDetectorYN, int, CvCallback_0)>(); + ffi.Pointer FaceRecognizerSF_AlignCrop( FaceRecognizerSF self, Mat src_img, @@ -4090,6 +4617,29 @@ class CvNative { ffi.Pointer Function( FaceRecognizerSF, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer FaceRecognizerSF_AlignCrop_Async( + FaceRecognizerSF self, + Mat src_img, + Mat face_box, + CvCallback_1 callback, + ) { + return _FaceRecognizerSF_AlignCrop_Async( + self, + src_img, + face_box, + callback, + ); + } + + late final _FaceRecognizerSF_AlignCrop_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceRecognizerSF, Mat, Mat, + CvCallback_1)>>('FaceRecognizerSF_AlignCrop_Async'); + late final _FaceRecognizerSF_AlignCrop_Async = + _FaceRecognizerSF_AlignCrop_AsyncPtr.asFunction< + ffi.Pointer Function( + FaceRecognizerSF, Mat, Mat, CvCallback_1)>(); + void FaceRecognizerSF_Close( FaceRecognizerSFPtr self, ) { @@ -4127,6 +4677,29 @@ class CvNative { ffi.Pointer Function( FaceRecognizerSF, Mat, bool, ffi.Pointer)>(); + ffi.Pointer FaceRecognizerSF_Feature_Async( + FaceRecognizerSF self, + Mat aligned_img, + bool clone, + CvCallback_1 callback, + ) { + return _FaceRecognizerSF_Feature_Async( + self, + aligned_img, + clone, + callback, + ); + } + + late final _FaceRecognizerSF_Feature_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceRecognizerSF, Mat, ffi.Bool, + CvCallback_1)>>('FaceRecognizerSF_Feature_Async'); + late final _FaceRecognizerSF_Feature_Async = + _FaceRecognizerSF_Feature_AsyncPtr.asFunction< + ffi.Pointer Function( + FaceRecognizerSF, Mat, bool, CvCallback_1)>(); + ffi.Pointer FaceRecognizerSF_Match( FaceRecognizerSF self, Mat face_feature1, @@ -4151,6 +4724,31 @@ class CvNative { ffi.Pointer Function( FaceRecognizerSF, Mat, Mat, int, ffi.Pointer)>(); + ffi.Pointer FaceRecognizerSF_Match_Async( + FaceRecognizerSF self, + Mat face_feature1, + Mat face_feature2, + int dis_type, + CvCallback_1 callback, + ) { + return _FaceRecognizerSF_Match_Async( + self, + face_feature1, + face_feature2, + dis_type, + callback, + ); + } + + late final _FaceRecognizerSF_Match_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FaceRecognizerSF, Mat, Mat, ffi.Int, + CvCallback_1)>>('FaceRecognizerSF_Match_Async'); + late final _FaceRecognizerSF_Match_Async = + _FaceRecognizerSF_Match_AsyncPtr.asFunction< + ffi.Pointer Function( + FaceRecognizerSF, Mat, Mat, int, CvCallback_1)>(); + ffi.Pointer FaceRecognizerSF_New( ffi.Pointer model, ffi.Pointer config, @@ -4179,6 +4777,35 @@ class CvNative { ffi.Pointer Function(ffi.Pointer, ffi.Pointer, int, int, ffi.Pointer)>(); + ffi.Pointer FaceRecognizerSF_New_Async( + ffi.Pointer model, + ffi.Pointer config, + int backend_id, + int target_id, + CvCallback_1 callback, + ) { + return _FaceRecognizerSF_New_Async( + model, + config, + backend_id, + target_id, + callback, + ); + } + + late final _FaceRecognizerSF_New_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Int, + CvCallback_1)>>('FaceRecognizerSF_New_Async'); + late final _FaceRecognizerSF_New_Async = + _FaceRecognizerSF_New_AsyncPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, int, CvCallback_1)>(); + void FastFeatureDetector_Close( FastFeatureDetectorPtr f, ) { @@ -5512,6 +6139,27 @@ class CvNative { late final _GroupRectangles = _GroupRectanglesPtr.asFunction< ffi.Pointer Function(VecRect, int, double)>(); + ffi.Pointer GroupRectangles_Async( + VecRect rects, + int groupThreshold, + double eps, + CvCallback_0 callback, + ) { + return _GroupRectangles_Async( + rects, + groupThreshold, + eps, + callback, + ); + } + + late final _GroupRectangles_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(VecRect, ffi.Int, ffi.Double, + CvCallback_0)>>('GroupRectangles_Async'); + late final _GroupRectangles_Async = _GroupRectangles_AsyncPtr.asFunction< + ffi.Pointer Function(VecRect, int, double, CvCallback_0)>(); + void HOGDescriptor_Close( HOGDescriptorPtr self, ) { @@ -5557,6 +6205,31 @@ class CvNative { ffi.Pointer Function(HOGDescriptor, Mat, ffi.Pointer, Size, Size, ffi.Pointer)>(); + ffi.Pointer HOGDescriptor_Compute_Async( + HOGDescriptor self, + Mat img, + Size winStride, + Size padding, + CvCallback_2 callback, + ) { + return _HOGDescriptor_Compute_Async( + self, + img, + winStride, + padding, + callback, + ); + } + + late final _HOGDescriptor_Compute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, Mat, Size, Size, + CvCallback_2)>>('HOGDescriptor_Compute_Async'); + late final _HOGDescriptor_Compute_Async = + _HOGDescriptor_Compute_AsyncPtr.asFunction< + ffi.Pointer Function( + HOGDescriptor, Mat, Size, Size, CvCallback_2)>(); + ffi.Pointer HOGDescriptor_Detect( HOGDescriptor self, Mat img, @@ -5628,6 +6301,33 @@ class CvNative { ffi.Pointer Function(HOGDescriptor, Mat, ffi.Pointer, double, Size, Size, ffi.Pointer)>(); + ffi.Pointer HOGDescriptor_Detect2_Async( + HOGDescriptor self, + Mat img, + double hitThresh, + Size winStride, + Size padding, + CvCallback_2 callback, + ) { + return _HOGDescriptor_Detect2_Async( + self, + img, + hitThresh, + winStride, + padding, + callback, + ); + } + + late final _HOGDescriptor_Detect2_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, Mat, ffi.Double, Size, + Size, CvCallback_2)>>('HOGDescriptor_Detect2_Async'); + late final _HOGDescriptor_Detect2_Async = + _HOGDescriptor_Detect2_AsyncPtr.asFunction< + ffi.Pointer Function( + HOGDescriptor, Mat, double, Size, Size, CvCallback_2)>(); + ffi.Pointer HOGDescriptor_DetectMultiScale( HOGDescriptor self, Mat img, @@ -5691,19 +6391,107 @@ class CvNative { ffi.Pointer Function(HOGDescriptor, Mat, double, Size, Size, double, double, bool, ffi.Pointer)>(); - ffi.Pointer HOGDescriptor_Load( + ffi.Pointer HOGDescriptor_DetectMultiScaleWithParams_Async( HOGDescriptor self, - ffi.Pointer name, - ffi.Pointer rval, + Mat img, + double hitThresh, + Size winStride, + Size padding, + double scale, + double finalThreshold, + bool useMeanshiftGrouping, + CvCallback_1 callback, ) { - return _HOGDescriptor_Load( + return _HOGDescriptor_DetectMultiScaleWithParams_Async( self, - name, - rval, - ); - } - - late final _HOGDescriptor_LoadPtr = _lookup< + img, + hitThresh, + winStride, + padding, + scale, + finalThreshold, + useMeanshiftGrouping, + callback, + ); + } + + late final _HOGDescriptor_DetectMultiScaleWithParams_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + HOGDescriptor, + Mat, + ffi.Double, + Size, + Size, + ffi.Double, + ffi.Double, + ffi.Bool, + CvCallback_1)>>('HOGDescriptor_DetectMultiScaleWithParams_Async'); + late final _HOGDescriptor_DetectMultiScaleWithParams_Async = + _HOGDescriptor_DetectMultiScaleWithParams_AsyncPtr.asFunction< + ffi.Pointer Function(HOGDescriptor, Mat, double, Size, Size, + double, double, bool, CvCallback_1)>(); + + ffi.Pointer HOGDescriptor_DetectMultiScale_Async( + HOGDescriptor self, + Mat img, + CvCallback_1 callback, + ) { + return _HOGDescriptor_DetectMultiScale_Async( + self, + img, + callback, + ); + } + + late final _HOGDescriptor_DetectMultiScale_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, Mat, + CvCallback_1)>>('HOGDescriptor_DetectMultiScale_Async'); + late final _HOGDescriptor_DetectMultiScale_Async = + _HOGDescriptor_DetectMultiScale_AsyncPtr.asFunction< + ffi.Pointer Function(HOGDescriptor, Mat, CvCallback_1)>(); + + ffi.Pointer HOGDescriptor_Detect_Async( + HOGDescriptor self, + Mat img, + double hitThresh, + Size winStride, + Size padding, + CvCallback_3 callback, + ) { + return _HOGDescriptor_Detect_Async( + self, + img, + hitThresh, + winStride, + padding, + callback, + ); + } + + late final _HOGDescriptor_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, Mat, ffi.Double, Size, + Size, CvCallback_3)>>('HOGDescriptor_Detect_Async'); + late final _HOGDescriptor_Detect_Async = + _HOGDescriptor_Detect_AsyncPtr.asFunction< + ffi.Pointer Function( + HOGDescriptor, Mat, double, Size, Size, CvCallback_3)>(); + + ffi.Pointer HOGDescriptor_Load( + HOGDescriptor self, + ffi.Pointer name, + ffi.Pointer rval, + ) { + return _HOGDescriptor_Load( + self, + name, + rval, + ); + } + + late final _HOGDescriptor_LoadPtr = _lookup< ffi.NativeFunction< ffi.Pointer Function(HOGDescriptor, ffi.Pointer, ffi.Pointer)>>('HOGDescriptor_Load'); @@ -5711,6 +6499,27 @@ class CvNative { ffi.Pointer Function( HOGDescriptor, ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer HOGDescriptor_Load_Async( + HOGDescriptor self, + ffi.Pointer name, + CvCallback_1 callback, + ) { + return _HOGDescriptor_Load_Async( + self, + name, + callback, + ); + } + + late final _HOGDescriptor_Load_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, ffi.Pointer, + CvCallback_1)>>('HOGDescriptor_Load_Async'); + late final _HOGDescriptor_Load_Async = + _HOGDescriptor_Load_AsyncPtr.asFunction< + ffi.Pointer Function( + HOGDescriptor, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer HOGDescriptor_New( ffi.Pointer rval, ) { @@ -5745,6 +6554,39 @@ class CvNative { ffi.Pointer Function( ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer HOGDescriptor_NewFromFile_Async( + ffi.Pointer filename, + CvCallback_1 callback, + ) { + return _HOGDescriptor_NewFromFile_Async( + filename, + callback, + ); + } + + late final _HOGDescriptor_NewFromFile_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + CvCallback_1)>>('HOGDescriptor_NewFromFile_Async'); + late final _HOGDescriptor_NewFromFile_Async = + _HOGDescriptor_NewFromFile_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, CvCallback_1)>(); + + ffi.Pointer HOGDescriptor_New_Async( + CvCallback_1 callback, + ) { + return _HOGDescriptor_New_Async( + callback, + ); + } + + late final _HOGDescriptor_New_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'HOGDescriptor_New_Async'); + late final _HOGDescriptor_New_Async = _HOGDescriptor_New_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer HOGDescriptor_SetSVMDetector( HOGDescriptor self, VecFloat det, @@ -5762,6 +6604,27 @@ class CvNative { late final _HOGDescriptor_SetSVMDetector = _HOGDescriptor_SetSVMDetectorPtr .asFunction Function(HOGDescriptor, VecFloat)>(); + ffi.Pointer HOGDescriptor_SetSVMDetector_Async( + HOGDescriptor self, + VecFloat det, + CvCallback_0 callback, + ) { + return _HOGDescriptor_SetSVMDetector_Async( + self, + det, + callback, + ); + } + + late final _HOGDescriptor_SetSVMDetector_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, VecFloat, + CvCallback_0)>>('HOGDescriptor_SetSVMDetector_Async'); + late final _HOGDescriptor_SetSVMDetector_Async = + _HOGDescriptor_SetSVMDetector_AsyncPtr.asFunction< + ffi.Pointer Function( + HOGDescriptor, VecFloat, CvCallback_0)>(); + ffi.Pointer HOGDescriptor_computeGradient( HOGDescriptor self, Mat img, @@ -5789,6 +6652,35 @@ class CvNative { ffi.Pointer Function( HOGDescriptor, Mat, Mat, Mat, Size, Size)>(); + ffi.Pointer HOGDescriptor_computeGradient_Async( + HOGDescriptor self, + Mat img, + Mat grad, + Mat angleOfs, + Size paddingTL, + Size paddingBR, + CvCallback_0 callback, + ) { + return _HOGDescriptor_computeGradient_Async( + self, + img, + grad, + angleOfs, + paddingTL, + paddingBR, + callback, + ); + } + + late final _HOGDescriptor_computeGradient_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, Mat, Mat, Mat, Size, + Size, CvCallback_0)>>('HOGDescriptor_computeGradient_Async'); + late final _HOGDescriptor_computeGradient_Async = + _HOGDescriptor_computeGradient_AsyncPtr.asFunction< + ffi.Pointer Function( + HOGDescriptor, Mat, Mat, Mat, Size, Size, CvCallback_0)>(); + ffi.Pointer HOGDescriptor_getDaimlerPeopleDetector( ffi.Pointer rval, ) { @@ -5805,6 +6697,21 @@ class CvNative { _HOGDescriptor_getDaimlerPeopleDetectorPtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer HOGDescriptor_getDaimlerPeopleDetector_Async( + CvCallback_1 callback, + ) { + return _HOGDescriptor_getDaimlerPeopleDetector_Async( + callback, + ); + } + + late final _HOGDescriptor_getDaimlerPeopleDetector_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'HOGDescriptor_getDaimlerPeopleDetector_Async'); + late final _HOGDescriptor_getDaimlerPeopleDetector_Async = + _HOGDescriptor_getDaimlerPeopleDetector_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer HOGDescriptor_getDescriptorSize( HOGDescriptor self, ffi.Pointer rval, @@ -5824,6 +6731,24 @@ class CvNative { ffi.Pointer Function( HOGDescriptor, ffi.Pointer)>(); + ffi.Pointer HOGDescriptor_getDescriptorSize_Async( + HOGDescriptor self, + CvCallback_1 callback, + ) { + return _HOGDescriptor_getDescriptorSize_Async( + self, + callback, + ); + } + + late final _HOGDescriptor_getDescriptorSize_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(HOGDescriptor, + CvCallback_1)>>('HOGDescriptor_getDescriptorSize_Async'); + late final _HOGDescriptor_getDescriptorSize_Async = + _HOGDescriptor_getDescriptorSize_AsyncPtr.asFunction< + ffi.Pointer Function(HOGDescriptor, CvCallback_1)>(); + ffi.Pointer HOGDescriptor_getWinSigma( HOGDescriptor self, ffi.Pointer rval, @@ -5843,6 +6768,24 @@ class CvNative { ffi.Pointer Function( HOGDescriptor, ffi.Pointer)>(); + ffi.Pointer HOGDescriptor_getWinSigma_Async( + HOGDescriptor self, + CvCallback_1 callback, + ) { + return _HOGDescriptor_getWinSigma_Async( + self, + callback, + ); + } + + late final _HOGDescriptor_getWinSigma_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + HOGDescriptor, CvCallback_1)>>('HOGDescriptor_getWinSigma_Async'); + late final _HOGDescriptor_getWinSigma_Async = + _HOGDescriptor_getWinSigma_AsyncPtr.asFunction< + ffi.Pointer Function(HOGDescriptor, CvCallback_1)>(); + ffi.Pointer HOGDescriptor_groupRectangles( HOGDescriptor self, VecRect rectList, @@ -5868,6 +6811,38 @@ class CvNative { ffi.Pointer Function( HOGDescriptor, VecRect, VecDouble, int, double)>(); + ffi.Pointer HOGDescriptor_groupRectangles_Async( + HOGDescriptor self, + VecRect rectList, + VecDouble weights, + int groupThreshold, + double eps, + CvCallback_0 callback, + ) { + return _HOGDescriptor_groupRectangles_Async( + self, + rectList, + weights, + groupThreshold, + eps, + callback, + ); + } + + late final _HOGDescriptor_groupRectangles_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + HOGDescriptor, + VecRect, + VecDouble, + ffi.Int, + ffi.Double, + CvCallback_0)>>('HOGDescriptor_groupRectangles_Async'); + late final _HOGDescriptor_groupRectangles_Async = + _HOGDescriptor_groupRectangles_AsyncPtr.asFunction< + ffi.Pointer Function( + HOGDescriptor, VecRect, VecDouble, int, double, CvCallback_0)>(); + ffi.Pointer HOG_GetDefaultPeopleDetector( ffi.Pointer rval, ) { @@ -5883,6 +6858,21 @@ class CvNative { late final _HOG_GetDefaultPeopleDetector = _HOG_GetDefaultPeopleDetectorPtr .asFunction Function(ffi.Pointer)>(); + ffi.Pointer HOG_GetDefaultPeopleDetector_Async( + CvCallback_1 callback, + ) { + return _HOG_GetDefaultPeopleDetector_Async( + callback, + ); + } + + late final _HOG_GetDefaultPeopleDetector_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'HOG_GetDefaultPeopleDetector_Async'); + late final _HOG_GetDefaultPeopleDetector_Async = + _HOG_GetDefaultPeopleDetector_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer HoughCircles( Mat src, Mat circles, @@ -7195,6 +8185,22 @@ class CvNative { late final _Layer_Close = _Layer_ClosePtr.asFunction(); + void Layer_Close_Async( + LayerPtr layer, + CvCallback_0 callback, + ) { + return _Layer_Close_Async( + layer, + callback, + ); + } + + late final _Layer_Close_AsyncPtr = + _lookup>( + 'Layer_Close_Async'); + late final _Layer_Close_Async = + _Layer_Close_AsyncPtr.asFunction(); + ffi.Pointer Layer_GetName( Layer layer, ffi.Pointer> rval, @@ -7213,6 +8219,23 @@ class CvNative { ffi.Pointer Function( Layer, ffi.Pointer>)>(); + ffi.Pointer Layer_GetName_Async( + Layer layer, + CvCallback_1 callback, + ) { + return _Layer_GetName_Async( + layer, + callback, + ); + } + + late final _Layer_GetName_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Layer, CvCallback_1)>>( + 'Layer_GetName_Async'); + late final _Layer_GetName_Async = _Layer_GetName_AsyncPtr.asFunction< + ffi.Pointer Function(Layer, CvCallback_1)>(); + ffi.Pointer Layer_GetType( Layer layer, ffi.Pointer> rval, @@ -7231,6 +8254,23 @@ class CvNative { ffi.Pointer Function( Layer, ffi.Pointer>)>(); + ffi.Pointer Layer_GetType_Async( + Layer layer, + CvCallback_1 callback, + ) { + return _Layer_GetType_Async( + layer, + callback, + ); + } + + late final _Layer_GetType_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Layer, CvCallback_1)>>( + 'Layer_GetType_Async'); + late final _Layer_GetType_Async = _Layer_GetType_AsyncPtr.asFunction< + ffi.Pointer Function(Layer, CvCallback_1)>(); + ffi.Pointer Layer_InputNameToIndex( Layer layer, ffi.Pointer name, @@ -7251,6 +8291,27 @@ class CvNative { ffi.Pointer Function( Layer, ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Layer_InputNameToIndex_Async( + Layer layer, + ffi.Pointer name, + CvCallback_1 callback, + ) { + return _Layer_InputNameToIndex_Async( + layer, + name, + callback, + ); + } + + late final _Layer_InputNameToIndex_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Layer, ffi.Pointer, + CvCallback_1)>>('Layer_InputNameToIndex_Async'); + late final _Layer_InputNameToIndex_Async = + _Layer_InputNameToIndex_AsyncPtr.asFunction< + ffi.Pointer Function( + Layer, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer Layer_OutputNameToIndex( Layer layer, ffi.Pointer name, @@ -7271,6 +8332,27 @@ class CvNative { ffi.Pointer Function( Layer, ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Layer_OutputNameToIndex_Async( + Layer layer, + ffi.Pointer name, + CvCallback_1 callback, + ) { + return _Layer_OutputNameToIndex_Async( + layer, + name, + callback, + ); + } + + late final _Layer_OutputNameToIndex_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Layer, ffi.Pointer, + CvCallback_1)>>('Layer_OutputNameToIndex_Async'); + late final _Layer_OutputNameToIndex_Async = + _Layer_OutputNameToIndex_AsyncPtr.asFunction< + ffi.Pointer Function( + Layer, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer Line( Mat img, Point pt1, @@ -12604,9 +13686,68 @@ class CvNative { ffi.Pointer Function(VecRect, VecFloat, double, double, ffi.Pointer, double, int)>(); - ffi.Pointer Net_BlobFromImage( - Mat image, - Mat blob, + ffi.Pointer NMSBoxesWithParams_Async( + VecRect bboxes, + VecFloat scores, + double score_threshold, + double nms_threshold, + double eta, + int top_k, + CvCallback_1 callback, + ) { + return _NMSBoxesWithParams_Async( + bboxes, + scores, + score_threshold, + nms_threshold, + eta, + top_k, + callback, + ); + } + + late final _NMSBoxesWithParams_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + VecRect, + VecFloat, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Int, + CvCallback_1)>>('NMSBoxesWithParams_Async'); + late final _NMSBoxesWithParams_Async = + _NMSBoxesWithParams_AsyncPtr.asFunction< + ffi.Pointer Function( + VecRect, VecFloat, double, double, double, int, CvCallback_1)>(); + + ffi.Pointer NMSBoxes_Async( + VecRect bboxes, + VecFloat scores, + double score_threshold, + double nms_threshold, + CvCallback_1 callback, + ) { + return _NMSBoxes_Async( + bboxes, + scores, + score_threshold, + nms_threshold, + callback, + ); + } + + late final _NMSBoxes_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(VecRect, VecFloat, ffi.Float, + ffi.Float, CvCallback_1)>>('NMSBoxes_Async'); + late final _NMSBoxes_Async = _NMSBoxes_AsyncPtr.asFunction< + ffi.Pointer Function( + VecRect, VecFloat, double, double, CvCallback_1)>(); + + ffi.Pointer Net_BlobFromImage( + Mat image, + Mat blob, double scalefactor, Size size, Scalar mean, @@ -12634,6 +13775,43 @@ class CvNative { ffi.Pointer Function( Mat, Mat, double, Size, Scalar, bool, bool, int)>(); + ffi.Pointer Net_BlobFromImage_Async( + Mat image, + double scalefactor, + Size size, + Scalar mean, + bool swapRB, + bool crop, + int ddepth, + CvCallback_1 callback, + ) { + return _Net_BlobFromImage_Async( + image, + scalefactor, + size, + mean, + swapRB, + crop, + ddepth, + callback, + ); + } + + late final _Net_BlobFromImage_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Mat, + ffi.Double, + Size, + Scalar, + ffi.Bool, + ffi.Bool, + ffi.Int, + CvCallback_1)>>('Net_BlobFromImage_Async'); + late final _Net_BlobFromImage_Async = _Net_BlobFromImage_AsyncPtr.asFunction< + ffi.Pointer Function( + Mat, double, Size, Scalar, bool, bool, int, CvCallback_1)>(); + ffi.Pointer Net_BlobFromImages( VecMat images, Mat blob, @@ -12664,6 +13842,44 @@ class CvNative { ffi.Pointer Function( VecMat, Mat, double, Size, Scalar, bool, bool, int)>(); + ffi.Pointer Net_BlobFromImages_Async( + VecMat images, + double scalefactor, + Size size, + Scalar mean, + bool swapRB, + bool crop, + int ddepth, + CvCallback_1 callback, + ) { + return _Net_BlobFromImages_Async( + images, + scalefactor, + size, + mean, + swapRB, + crop, + ddepth, + callback, + ); + } + + late final _Net_BlobFromImages_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + VecMat, + ffi.Double, + Size, + Scalar, + ffi.Bool, + ffi.Bool, + ffi.Int, + CvCallback_1)>>('Net_BlobFromImages_Async'); + late final _Net_BlobFromImages_Async = + _Net_BlobFromImages_AsyncPtr.asFunction< + ffi.Pointer Function( + VecMat, double, Size, Scalar, bool, bool, int, CvCallback_1)>(); + void Net_Close( NetPtr net, ) { @@ -12676,6 +13892,22 @@ class CvNative { _lookup>('Net_Close'); late final _Net_Close = _Net_ClosePtr.asFunction(); + void Net_Close_Async( + NetPtr net, + CvCallback_0 callback, + ) { + return _Net_Close_Async( + net, + callback, + ); + } + + late final _Net_Close_AsyncPtr = + _lookup>( + 'Net_Close_Async'); + late final _Net_Close_Async = + _Net_Close_AsyncPtr.asFunction(); + ffi.Pointer Net_Create( ffi.Pointer rval, ) { @@ -12690,6 +13922,20 @@ class CvNative { late final _Net_Create = _Net_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer Net_Create_Async( + CvCallback_1 callback, + ) { + return _Net_Create_Async( + callback, + ); + } + + late final _Net_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'Net_Create_Async'); + late final _Net_Create_Async = _Net_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer Net_Dump( Net net, ffi.Pointer> rval, @@ -12708,6 +13954,22 @@ class CvNative { ffi.Pointer Function( Net, ffi.Pointer>)>(); + ffi.Pointer Net_Dump_Async( + Net net, + CvCallback_1 callback, + ) { + return _Net_Dump_Async( + net, + callback, + ); + } + + late final _Net_Dump_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Net, CvCallback_1)>>('Net_Dump_Async'); + late final _Net_Dump_Async = _Net_Dump_AsyncPtr.asFunction< + ffi.Pointer Function(Net, CvCallback_1)>(); + ffi.Pointer Net_Empty( Net net, ffi.Pointer rval, @@ -12725,6 +13987,23 @@ class CvNative { late final _Net_Empty = _Net_EmptyPtr.asFunction< ffi.Pointer Function(Net, ffi.Pointer)>(); + ffi.Pointer Net_Empty_Async( + Net net, + CvCallback_1 callback, + ) { + return _Net_Empty_Async( + net, + callback, + ); + } + + late final _Net_Empty_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Net, CvCallback_1)>>( + 'Net_Empty_Async'); + late final _Net_Empty_Async = _Net_Empty_AsyncPtr.asFunction< + ffi.Pointer Function(Net, CvCallback_1)>(); + ffi.Pointer Net_Forward( Net net, ffi.Pointer outputName, @@ -12764,6 +14043,45 @@ class CvNative { late final _Net_ForwardLayers = _Net_ForwardLayersPtr.asFunction< ffi.Pointer Function(Net, ffi.Pointer, VecVecChar)>(); + ffi.Pointer Net_ForwardLayers_Async( + Net net, + VecVecChar outBlobNames, + CvCallback_1 callback, + ) { + return _Net_ForwardLayers_Async( + net, + outBlobNames, + callback, + ); + } + + late final _Net_ForwardLayers_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Net, VecVecChar, CvCallback_1)>>('Net_ForwardLayers_Async'); + late final _Net_ForwardLayers_Async = _Net_ForwardLayers_AsyncPtr.asFunction< + ffi.Pointer Function(Net, VecVecChar, CvCallback_1)>(); + + ffi.Pointer Net_Forward_Async( + Net net, + ffi.Pointer outputName, + CvCallback_1 callback, + ) { + return _Net_Forward_Async( + net, + outputName, + callback, + ); + } + + late final _Net_Forward_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Net, ffi.Pointer, CvCallback_1)>>('Net_Forward_Async'); + late final _Net_Forward_Async = _Net_Forward_AsyncPtr.asFunction< + ffi.Pointer Function( + Net, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer Net_FromNet( Net net, ffi.Pointer rval, @@ -12781,6 +14099,23 @@ class CvNative { late final _Net_FromNet = _Net_FromNetPtr.asFunction< ffi.Pointer Function(Net, ffi.Pointer)>(); + ffi.Pointer Net_FromNet_Async( + Net net, + CvCallback_1 callback, + ) { + return _Net_FromNet_Async( + net, + callback, + ); + } + + late final _Net_FromNet_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Net, CvCallback_1)>>( + 'Net_FromNet_Async'); + late final _Net_FromNet_Async = _Net_FromNet_AsyncPtr.asFunction< + ffi.Pointer Function(Net, CvCallback_1)>(); + ffi.Pointer Net_GetBlobChannel( Mat blob, int imgidx, @@ -12802,6 +14137,28 @@ class CvNative { late final _Net_GetBlobChannel = _Net_GetBlobChannelPtr.asFunction< ffi.Pointer Function(Mat, int, int, ffi.Pointer)>(); + ffi.Pointer Net_GetBlobChannel_Async( + Mat blob, + int imgidx, + int chnidx, + CvCallback_1 callback, + ) { + return _Net_GetBlobChannel_Async( + blob, + imgidx, + chnidx, + callback, + ); + } + + late final _Net_GetBlobChannel_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Mat, ffi.Int, ffi.Int, + CvCallback_1)>>('Net_GetBlobChannel_Async'); + late final _Net_GetBlobChannel_Async = + _Net_GetBlobChannel_AsyncPtr.asFunction< + ffi.Pointer Function(Mat, int, int, CvCallback_1)>(); + ffi.Pointer Net_GetBlobSize( Mat blob, ffi.Pointer rval, @@ -12819,6 +14176,23 @@ class CvNative { late final _Net_GetBlobSize = _Net_GetBlobSizePtr.asFunction< ffi.Pointer Function(Mat, ffi.Pointer)>(); + ffi.Pointer Net_GetBlobSize_Async( + Mat blob, + CvCallback_1 callback, + ) { + return _Net_GetBlobSize_Async( + blob, + callback, + ); + } + + late final _Net_GetBlobSize_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Mat, CvCallback_1)>>( + 'Net_GetBlobSize_Async'); + late final _Net_GetBlobSize_Async = _Net_GetBlobSize_AsyncPtr.asFunction< + ffi.Pointer Function(Mat, CvCallback_1)>(); + ffi.Pointer Net_GetInputDetails( Net net, ffi.Pointer scales, @@ -12839,6 +14213,23 @@ class CvNative { ffi.Pointer Function( Net, ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer Net_GetInputDetails_Async( + Net net, + CvCallback_2 callback, + ) { + return _Net_GetInputDetails_Async( + net, + callback, + ); + } + + late final _Net_GetInputDetails_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Net, CvCallback_2)>>( + 'Net_GetInputDetails_Async'); + late final _Net_GetInputDetails_Async = _Net_GetInputDetails_AsyncPtr + .asFunction Function(Net, CvCallback_2)>(); + ffi.Pointer Net_GetLayer( Net net, int layerid, @@ -12875,6 +14266,42 @@ class CvNative { late final _Net_GetLayerNames = _Net_GetLayerNamesPtr.asFunction< ffi.Pointer Function(Net, ffi.Pointer)>(); + ffi.Pointer Net_GetLayerNames_Async( + Net net, + CvCallback_1 callback, + ) { + return _Net_GetLayerNames_Async( + net, + callback, + ); + } + + late final _Net_GetLayerNames_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Net, CvCallback_1)>>( + 'Net_GetLayerNames_Async'); + late final _Net_GetLayerNames_Async = _Net_GetLayerNames_AsyncPtr.asFunction< + ffi.Pointer Function(Net, CvCallback_1)>(); + + ffi.Pointer Net_GetLayer_Async( + Net net, + int layerid, + CvCallback_1 callback, + ) { + return _Net_GetLayer_Async( + net, + layerid, + callback, + ); + } + + late final _Net_GetLayer_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Net, ffi.Int, CvCallback_1)>>('Net_GetLayer_Async'); + late final _Net_GetLayer_Async = _Net_GetLayer_AsyncPtr.asFunction< + ffi.Pointer Function(Net, int, CvCallback_1)>(); + ffi.Pointer Net_GetPerfProfile( Net net, ffi.Pointer rval, @@ -12892,6 +14319,23 @@ class CvNative { late final _Net_GetPerfProfile = _Net_GetPerfProfilePtr.asFunction< ffi.Pointer Function(Net, ffi.Pointer)>(); + ffi.Pointer Net_GetPerfProfile_Async( + Net net, + CvCallback_1 callback, + ) { + return _Net_GetPerfProfile_Async( + net, + callback, + ); + } + + late final _Net_GetPerfProfile_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Net, CvCallback_1)>>( + 'Net_GetPerfProfile_Async'); + late final _Net_GetPerfProfile_Async = _Net_GetPerfProfile_AsyncPtr + .asFunction Function(Net, CvCallback_1)>(); + ffi.Pointer Net_GetUnconnectedOutLayers( Net net, ffi.Pointer rval, @@ -12909,6 +14353,24 @@ class CvNative { late final _Net_GetUnconnectedOutLayers = _Net_GetUnconnectedOutLayersPtr .asFunction Function(Net, ffi.Pointer)>(); + ffi.Pointer Net_GetUnconnectedOutLayers_Async( + Net net, + CvCallback_1 callback, + ) { + return _Net_GetUnconnectedOutLayers_Async( + net, + callback, + ); + } + + late final _Net_GetUnconnectedOutLayers_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Net, CvCallback_1)>>( + 'Net_GetUnconnectedOutLayers_Async'); + late final _Net_GetUnconnectedOutLayers_Async = + _Net_GetUnconnectedOutLayers_AsyncPtr.asFunction< + ffi.Pointer Function(Net, CvCallback_1)>(); + ffi.Pointer Net_ImagesFromBlob( Mat blob, ffi.Pointer rval, @@ -12926,6 +14388,23 @@ class CvNative { late final _Net_ImagesFromBlob = _Net_ImagesFromBlobPtr.asFunction< ffi.Pointer Function(Mat, ffi.Pointer)>(); + ffi.Pointer Net_ImagesFromBlob_Async( + Mat blob, + CvCallback_1 callback, + ) { + return _Net_ImagesFromBlob_Async( + blob, + callback, + ); + } + + late final _Net_ImagesFromBlob_AsyncPtr = _lookup< + ffi + .NativeFunction Function(Mat, CvCallback_1)>>( + 'Net_ImagesFromBlob_Async'); + late final _Net_ImagesFromBlob_Async = _Net_ImagesFromBlob_AsyncPtr + .asFunction Function(Mat, CvCallback_1)>(); + ffi.Pointer Net_ReadNet( ffi.Pointer model, ffi.Pointer config, @@ -12973,6 +14452,28 @@ class CvNative { ffi.Pointer Function( ffi.Pointer, VecUChar, VecUChar, ffi.Pointer)>(); + ffi.Pointer Net_ReadNetBytes_Async( + ffi.Pointer framework, + VecUChar model, + VecUChar config, + CvCallback_1 callback, + ) { + return _Net_ReadNetBytes_Async( + framework, + model, + config, + callback, + ); + } + + late final _Net_ReadNetBytes_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, VecUChar, + VecUChar, CvCallback_1)>>('Net_ReadNetBytes_Async'); + late final _Net_ReadNetBytes_Async = _Net_ReadNetBytes_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, VecUChar, VecUChar, CvCallback_1)>(); + ffi.Pointer Net_ReadNetFromCaffe( ffi.Pointer prototxt, ffi.Pointer caffeModel, @@ -13016,6 +14517,49 @@ class CvNative { ffi.Pointer Function( VecUChar, VecUChar, ffi.Pointer)>(); + ffi.Pointer Net_ReadNetFromCaffeBytes_Async( + VecUChar prototxt, + VecUChar caffeModel, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromCaffeBytes_Async( + prototxt, + caffeModel, + callback, + ); + } + + late final _Net_ReadNetFromCaffeBytes_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(VecUChar, VecUChar, + CvCallback_1)>>('Net_ReadNetFromCaffeBytes_Async'); + late final _Net_ReadNetFromCaffeBytes_Async = + _Net_ReadNetFromCaffeBytes_AsyncPtr.asFunction< + ffi.Pointer Function(VecUChar, VecUChar, CvCallback_1)>(); + + ffi.Pointer Net_ReadNetFromCaffe_Async( + ffi.Pointer prototxt, + ffi.Pointer caffeModel, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromCaffe_Async( + prototxt, + caffeModel, + callback, + ); + } + + late final _Net_ReadNetFromCaffe_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + CvCallback_1)>>('Net_ReadNetFromCaffe_Async'); + late final _Net_ReadNetFromCaffe_Async = + _Net_ReadNetFromCaffe_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer Net_ReadNetFromONNX( ffi.Pointer model, ffi.Pointer rval, @@ -13051,6 +14595,43 @@ class CvNative { late final _Net_ReadNetFromONNXBytes = _Net_ReadNetFromONNXBytesPtr .asFunction Function(VecUChar, ffi.Pointer)>(); + ffi.Pointer Net_ReadNetFromONNXBytes_Async( + VecUChar model, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromONNXBytes_Async( + model, + callback, + ); + } + + late final _Net_ReadNetFromONNXBytes_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + VecUChar, CvCallback_1)>>('Net_ReadNetFromONNXBytes_Async'); + late final _Net_ReadNetFromONNXBytes_Async = + _Net_ReadNetFromONNXBytes_AsyncPtr.asFunction< + ffi.Pointer Function(VecUChar, CvCallback_1)>(); + + ffi.Pointer Net_ReadNetFromONNX_Async( + ffi.Pointer model, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromONNX_Async( + model, + callback, + ); + } + + late final _Net_ReadNetFromONNX_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + CvCallback_1)>>('Net_ReadNetFromONNX_Async'); + late final _Net_ReadNetFromONNX_Async = + _Net_ReadNetFromONNX_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, CvCallback_1)>(); + ffi.Pointer Net_ReadNetFromTFLite( ffi.Pointer model, ffi.Pointer rval, @@ -13073,18 +14654,55 @@ class CvNative { VecUChar bufferModel, ffi.Pointer rval, ) { - return _Net_ReadNetFromTFLiteBytes( - bufferModel, - rval, + return _Net_ReadNetFromTFLiteBytes( + bufferModel, + rval, + ); + } + + late final _Net_ReadNetFromTFLiteBytesPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + VecUChar, ffi.Pointer)>>('Net_ReadNetFromTFLiteBytes'); + late final _Net_ReadNetFromTFLiteBytes = _Net_ReadNetFromTFLiteBytesPtr + .asFunction Function(VecUChar, ffi.Pointer)>(); + + ffi.Pointer Net_ReadNetFromTFLiteBytes_Async( + VecUChar bufferModel, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromTFLiteBytes_Async( + bufferModel, + callback, + ); + } + + late final _Net_ReadNetFromTFLiteBytes_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + VecUChar, CvCallback_1)>>('Net_ReadNetFromTFLiteBytes_Async'); + late final _Net_ReadNetFromTFLiteBytes_Async = + _Net_ReadNetFromTFLiteBytes_AsyncPtr.asFunction< + ffi.Pointer Function(VecUChar, CvCallback_1)>(); + + ffi.Pointer Net_ReadNetFromTFLite_Async( + ffi.Pointer model, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromTFLite_Async( + model, + callback, ); } - late final _Net_ReadNetFromTFLiteBytesPtr = _lookup< + late final _Net_ReadNetFromTFLite_AsyncPtr = _lookup< ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + CvCallback_1)>>('Net_ReadNetFromTFLite_Async'); + late final _Net_ReadNetFromTFLite_Async = + _Net_ReadNetFromTFLite_AsyncPtr.asFunction< ffi.Pointer Function( - VecUChar, ffi.Pointer)>>('Net_ReadNetFromTFLiteBytes'); - late final _Net_ReadNetFromTFLiteBytes = _Net_ReadNetFromTFLiteBytesPtr - .asFunction Function(VecUChar, ffi.Pointer)>(); + ffi.Pointer, CvCallback_1)>(); ffi.Pointer Net_ReadNetFromTensorflow( ffi.Pointer model, @@ -13130,6 +14748,49 @@ class CvNative { ffi.Pointer Function( VecUChar, VecUChar, ffi.Pointer)>(); + ffi.Pointer Net_ReadNetFromTensorflowBytes_Async( + VecUChar model, + VecUChar config, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromTensorflowBytes_Async( + model, + config, + callback, + ); + } + + late final _Net_ReadNetFromTensorflowBytes_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(VecUChar, VecUChar, + CvCallback_1)>>('Net_ReadNetFromTensorflowBytes_Async'); + late final _Net_ReadNetFromTensorflowBytes_Async = + _Net_ReadNetFromTensorflowBytes_AsyncPtr.asFunction< + ffi.Pointer Function(VecUChar, VecUChar, CvCallback_1)>(); + + ffi.Pointer Net_ReadNetFromTensorflow_Async( + ffi.Pointer model, + ffi.Pointer config, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromTensorflow_Async( + model, + config, + callback, + ); + } + + late final _Net_ReadNetFromTensorflow_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + CvCallback_1)>>('Net_ReadNetFromTensorflow_Async'); + late final _Net_ReadNetFromTensorflow_Async = + _Net_ReadNetFromTensorflow_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer Net_ReadNetFromTorch( ffi.Pointer model, bool isBinary, @@ -13152,6 +14813,54 @@ class CvNative { ffi.Pointer Function( ffi.Pointer, bool, bool, ffi.Pointer)>(); + ffi.Pointer Net_ReadNetFromTorch_Async( + ffi.Pointer model, + bool isBinary, + bool evaluate, + CvCallback_1 callback, + ) { + return _Net_ReadNetFromTorch_Async( + model, + isBinary, + evaluate, + callback, + ); + } + + late final _Net_ReadNetFromTorch_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Bool, + ffi.Bool, CvCallback_1)>>('Net_ReadNetFromTorch_Async'); + late final _Net_ReadNetFromTorch_Async = + _Net_ReadNetFromTorch_AsyncPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, bool, bool, CvCallback_1)>(); + + ffi.Pointer Net_ReadNet_Async( + ffi.Pointer model, + ffi.Pointer config, + ffi.Pointer framework, + CvCallback_1 callback, + ) { + return _Net_ReadNet_Async( + model, + config, + framework, + callback, + ); + } + + late final _Net_ReadNet_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + CvCallback_1)>>('Net_ReadNet_Async'); + late final _Net_ReadNet_Async = _Net_ReadNet_AsyncPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, CvCallback_1)>(); + ffi.Pointer Net_SetInput( Net net, Mat blob, @@ -13171,6 +14880,28 @@ class CvNative { late final _Net_SetInput = _Net_SetInputPtr.asFunction< ffi.Pointer Function(Net, Mat, ffi.Pointer)>(); + ffi.Pointer Net_SetInput_Async( + Net net, + Mat blob, + ffi.Pointer name, + CvCallback_0 callback, + ) { + return _Net_SetInput_Async( + net, + blob, + name, + callback, + ); + } + + late final _Net_SetInput_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Net, Mat, ffi.Pointer, + CvCallback_0)>>('Net_SetInput_Async'); + late final _Net_SetInput_Async = _Net_SetInput_AsyncPtr.asFunction< + ffi.Pointer Function( + Net, Mat, ffi.Pointer, CvCallback_0)>(); + ffi.Pointer Net_SetPreferableBackend( Net net, int backend, @@ -13187,6 +14918,26 @@ class CvNative { late final _Net_SetPreferableBackend = _Net_SetPreferableBackendPtr .asFunction Function(Net, int)>(); + ffi.Pointer Net_SetPreferableBackend_Async( + Net net, + int backend, + CvCallback_0 callback, + ) { + return _Net_SetPreferableBackend_Async( + net, + backend, + callback, + ); + } + + late final _Net_SetPreferableBackend_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Net, ffi.Int, CvCallback_0)>>('Net_SetPreferableBackend_Async'); + late final _Net_SetPreferableBackend_Async = + _Net_SetPreferableBackend_AsyncPtr.asFunction< + ffi.Pointer Function(Net, int, CvCallback_0)>(); + ffi.Pointer Net_SetPreferableTarget( Net net, int target, @@ -13203,6 +14954,25 @@ class CvNative { late final _Net_SetPreferableTarget = _Net_SetPreferableTargetPtr.asFunction< ffi.Pointer Function(Net, int)>(); + ffi.Pointer Net_SetPreferableTarget_Async( + Net net, + int target, + CvCallback_0 callback, + ) { + return _Net_SetPreferableTarget_Async( + net, + target, + callback, + ); + } + + late final _Net_SetPreferableTarget_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Net, ffi.Int, CvCallback_0)>>('Net_SetPreferableTarget_Async'); + late final _Net_SetPreferableTarget_Async = _Net_SetPreferableTarget_AsyncPtr + .asFunction Function(Net, int, CvCallback_0)>(); + ffi.Pointer Net_forwardAsync( Net net, ffi.Pointer outputName, @@ -13882,6 +15652,26 @@ class CvNative { ffi.Pointer Function(QRCodeDetector, Mat, ffi.Pointer, Mat, ffi.Pointer>)>(); + ffi.Pointer QRCodeDetector_Decode_Async( + QRCodeDetector self, + Mat input, + CvCallback_3 callback, + ) { + return _QRCodeDetector_Decode_Async( + self, + input, + callback, + ); + } + + late final _QRCodeDetector_Decode_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, Mat, + CvCallback_3)>>('QRCodeDetector_Decode_Async'); + late final _QRCodeDetector_Decode_Async = + _QRCodeDetector_Decode_AsyncPtr.asFunction< + ffi.Pointer Function(QRCodeDetector, Mat, CvCallback_3)>(); + ffi.Pointer QRCodeDetector_Detect( QRCodeDetector self, Mat input, @@ -13978,6 +15768,46 @@ class CvNative { ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer QRCodeDetector_DetectAndDecodeMulti_Async( + QRCodeDetector self, + Mat input, + CvCallback_4 callback, + ) { + return _QRCodeDetector_DetectAndDecodeMulti_Async( + self, + input, + callback, + ); + } + + late final _QRCodeDetector_DetectAndDecodeMulti_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, Mat, + CvCallback_4)>>('QRCodeDetector_DetectAndDecodeMulti_Async'); + late final _QRCodeDetector_DetectAndDecodeMulti_Async = + _QRCodeDetector_DetectAndDecodeMulti_AsyncPtr.asFunction< + ffi.Pointer Function(QRCodeDetector, Mat, CvCallback_4)>(); + + ffi.Pointer QRCodeDetector_DetectAndDecode_Async( + QRCodeDetector self, + Mat input, + CvCallback_3 callback, + ) { + return _QRCodeDetector_DetectAndDecode_Async( + self, + input, + callback, + ); + } + + late final _QRCodeDetector_DetectAndDecode_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, Mat, + CvCallback_3)>>('QRCodeDetector_DetectAndDecode_Async'); + late final _QRCodeDetector_DetectAndDecode_Async = + _QRCodeDetector_DetectAndDecode_AsyncPtr.asFunction< + ffi.Pointer Function(QRCodeDetector, Mat, CvCallback_3)>(); + ffi.Pointer QRCodeDetector_DetectMulti( QRCodeDetector self, Mat input, @@ -14004,6 +15834,46 @@ class CvNative { ffi.Pointer Function(QRCodeDetector, Mat, ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer QRCodeDetector_DetectMulti_Async( + QRCodeDetector self, + Mat input, + CvCallback_2 callback, + ) { + return _QRCodeDetector_DetectMulti_Async( + self, + input, + callback, + ); + } + + late final _QRCodeDetector_DetectMulti_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, Mat, + CvCallback_2)>>('QRCodeDetector_DetectMulti_Async'); + late final _QRCodeDetector_DetectMulti_Async = + _QRCodeDetector_DetectMulti_AsyncPtr.asFunction< + ffi.Pointer Function(QRCodeDetector, Mat, CvCallback_2)>(); + + ffi.Pointer QRCodeDetector_Detect_Async( + QRCodeDetector self, + Mat input, + CvCallback_2 callback, + ) { + return _QRCodeDetector_Detect_Async( + self, + input, + callback, + ); + } + + late final _QRCodeDetector_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, Mat, + CvCallback_2)>>('QRCodeDetector_Detect_Async'); + late final _QRCodeDetector_Detect_Async = + _QRCodeDetector_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(QRCodeDetector, Mat, CvCallback_2)>(); + ffi.Pointer QRCodeDetector_New( ffi.Pointer rval, ) { @@ -14019,6 +15889,20 @@ class CvNative { late final _QRCodeDetector_New = _QRCodeDetector_NewPtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer QRCodeDetector_New_Async( + CvCallback_1 callback, + ) { + return _QRCodeDetector_New_Async( + callback, + ); + } + + late final _QRCodeDetector_New_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'QRCodeDetector_New_Async'); + late final _QRCodeDetector_New_Async = _QRCodeDetector_New_AsyncPtr + .asFunction Function(CvCallback_1)>(); + ffi.Pointer QRCodeDetector_decodeCurved( QRCodeDetector self, Mat img, @@ -14045,6 +15929,29 @@ class CvNative { ffi.Pointer Function(QRCodeDetector, Mat, VecPoint, ffi.Pointer, ffi.Pointer>)>(); + ffi.Pointer QRCodeDetector_decodeCurved_Async( + QRCodeDetector self, + Mat img, + VecPoint points, + CvCallback_2 callback, + ) { + return _QRCodeDetector_decodeCurved_Async( + self, + img, + points, + callback, + ); + } + + late final _QRCodeDetector_decodeCurved_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, Mat, VecPoint, + CvCallback_2)>>('QRCodeDetector_decodeCurved_Async'); + late final _QRCodeDetector_decodeCurved_Async = + _QRCodeDetector_decodeCurved_AsyncPtr.asFunction< + ffi.Pointer Function( + QRCodeDetector, Mat, VecPoint, CvCallback_2)>(); + ffi.Pointer QRCodeDetector_detectAndDecodeCurved( QRCodeDetector self, Mat img, @@ -14079,6 +15986,26 @@ class CvNative { ffi.Pointer, ffi.Pointer>)>(); + ffi.Pointer QRCodeDetector_detectAndDecodeCurved_Async( + QRCodeDetector self, + Mat img, + CvCallback_3 callback, + ) { + return _QRCodeDetector_detectAndDecodeCurved_Async( + self, + img, + callback, + ); + } + + late final _QRCodeDetector_detectAndDecodeCurved_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, Mat, + CvCallback_3)>>('QRCodeDetector_detectAndDecodeCurved_Async'); + late final _QRCodeDetector_detectAndDecodeCurved_Async = + _QRCodeDetector_detectAndDecodeCurved_AsyncPtr.asFunction< + ffi.Pointer Function(QRCodeDetector, Mat, CvCallback_3)>(); + ffi.Pointer QRCodeDetector_setEpsX( QRCodeDetector self, double epsX, @@ -14096,6 +16023,27 @@ class CvNative { late final _QRCodeDetector_setEpsX = _QRCodeDetector_setEpsXPtr.asFunction< ffi.Pointer Function(QRCodeDetector, double)>(); + ffi.Pointer QRCodeDetector_setEpsX_Async( + QRCodeDetector self, + double epsX, + CvCallback_0 callback, + ) { + return _QRCodeDetector_setEpsX_Async( + self, + epsX, + callback, + ); + } + + late final _QRCodeDetector_setEpsX_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, ffi.Double, + CvCallback_0)>>('QRCodeDetector_setEpsX_Async'); + late final _QRCodeDetector_setEpsX_Async = + _QRCodeDetector_setEpsX_AsyncPtr.asFunction< + ffi.Pointer Function( + QRCodeDetector, double, CvCallback_0)>(); + ffi.Pointer QRCodeDetector_setEpsY( QRCodeDetector self, double epsY, @@ -14113,6 +16061,27 @@ class CvNative { late final _QRCodeDetector_setEpsY = _QRCodeDetector_setEpsYPtr.asFunction< ffi.Pointer Function(QRCodeDetector, double)>(); + ffi.Pointer QRCodeDetector_setEpsY_Async( + QRCodeDetector self, + double epsY, + CvCallback_0 callback, + ) { + return _QRCodeDetector_setEpsY_Async( + self, + epsY, + callback, + ); + } + + late final _QRCodeDetector_setEpsY_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, ffi.Double, + CvCallback_0)>>('QRCodeDetector_setEpsY_Async'); + late final _QRCodeDetector_setEpsY_Async = + _QRCodeDetector_setEpsY_AsyncPtr.asFunction< + ffi.Pointer Function( + QRCodeDetector, double, CvCallback_0)>(); + ffi.Pointer QRCodeDetector_setUseAlignmentMarkers( QRCodeDetector self, bool useAlignmentMarkers, @@ -14131,6 +16100,26 @@ class CvNative { _QRCodeDetector_setUseAlignmentMarkersPtr.asFunction< ffi.Pointer Function(QRCodeDetector, bool)>(); + ffi.Pointer QRCodeDetector_setUseAlignmentMarkers_Async( + QRCodeDetector self, + bool useAlignmentMarkers, + CvCallback_0 callback, + ) { + return _QRCodeDetector_setUseAlignmentMarkers_Async( + self, + useAlignmentMarkers, + callback, + ); + } + + late final _QRCodeDetector_setUseAlignmentMarkers_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(QRCodeDetector, ffi.Bool, + CvCallback_0)>>('QRCodeDetector_setUseAlignmentMarkers_Async'); + late final _QRCodeDetector_setUseAlignmentMarkers_Async = + _QRCodeDetector_setUseAlignmentMarkers_AsyncPtr.asFunction< + ffi.Pointer Function(QRCodeDetector, bool, CvCallback_0)>(); + ffi.Pointer RNG_Fill( RNG rng, Mat mat, @@ -22663,6 +24652,8 @@ class _SymbolAddresses { get KalmanFilter_Close => _library._KalmanFilter_ClosePtr; ffi.Pointer> get Layer_Close => _library._Layer_ClosePtr; + ffi.Pointer> + get Layer_Close_Async => _library._Layer_Close_AsyncPtr; ffi.Pointer> get MSER_Close => _library._MSER_ClosePtr; ffi.Pointer> get Mat_Close => @@ -22673,6 +24664,8 @@ class _SymbolAddresses { get MergeMertens_Close => _library._MergeMertens_ClosePtr; ffi.Pointer> get Net_Close => _library._Net_ClosePtr; + ffi.Pointer> + get Net_Close_Async => _library._Net_Close_AsyncPtr; ffi.Pointer> get ORB_Close => _library._ORB_ClosePtr; ffi.Pointer> @@ -22845,6 +24838,11 @@ typedef CvCallback_3Function = ffi.Void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer); typedef DartCvCallback_3Function = void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef CvCallback_4 = ffi.Pointer>; +typedef CvCallback_4Function = ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef DartCvCallback_4Function = void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer); typedef CvCallback_5 = ffi.Pointer>; typedef CvCallback_5Function = ffi.Void Function( ffi.Pointer, diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100644 index 00000000..f1a7b5ac --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,2 @@ +#!/bin/sh +exec dart format --fix --set-exit-if-changed -l 110 . diff --git a/src/calib3d/calib3d_async.h b/src/calib3d/calib3d_async.h index a9bdcd58..5bafc3c3 100644 --- a/src/calib3d/calib3d_async.h +++ b/src/calib3d/calib3d_async.h @@ -7,6 +7,8 @@ #define CVD_ASYNC_CALIB3D_H #include "core/types.h" +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/dnn/dnn_async.cpp b/src/dnn/dnn_async.cpp new file mode 100644 index 00000000..e61b654d --- /dev/null +++ b/src/dnn/dnn_async.cpp @@ -0,0 +1,314 @@ +#include "dnn_async.h" +#include "core/types.h" + +// Asynchronous functions for Net +CvStatus *Net_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net()}); + END_WRAP +} + +CvStatus *Net_FromNet_Async(Net net, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(*net.ptr)}); + END_WRAP +} + +CvStatus *Net_ReadNet_Async(const char *model, const char *config, const char *framework, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNet(model, config, framework))}); + END_WRAP +} + +CvStatus *Net_ReadNetBytes_Async(const char *framework, VecUChar model, VecUChar config, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNet(framework, *model.ptr, *config.ptr))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromCaffe_Async(const char *prototxt, const char *caffeModel, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromCaffe(prototxt, caffeModel))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromCaffeBytes_Async(VecUChar prototxt, VecUChar caffeModel, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromCaffe(*prototxt.ptr, *caffeModel.ptr))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromTensorflow_Async(const char *model, const char *config, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromTensorflow(model, config))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromTensorflowBytes_Async(VecUChar model, VecUChar config, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromTensorflow(*model.ptr, *config.ptr))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromTFLite_Async(const char *model, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromTFLite(model))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromTFLiteBytes_Async(VecUChar bufferModel, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromTFLite(*bufferModel.ptr))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromTorch_Async(const char *model, bool isBinary, bool evaluate, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromTorch(model, isBinary, evaluate))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromONNX_Async(const char *model, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromONNX(model))}); + END_WRAP +} + +CvStatus *Net_ReadNetFromONNXBytes_Async(VecUChar model, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Net{new cv::dnn::Net(cv::dnn::readNetFromONNX(*model.ptr))}); + END_WRAP +} + +void Net_Close_Async(NetPtr net, CvCallback_0 callback) +{ + CVD_FREE(net); + callback(); +} + +CvStatus *Net_BlobFromImage_Async(Mat image, double scalefactor, Size size, Scalar mean, bool swapRB, bool crop, int ddepth, CvCallback_1 callback) +{ + BEGIN_WRAP + cv::Size sz(size.width, size.height); + cv::Scalar cm(mean.val1, mean.val2, mean.val3, mean.val4); + Mat *blob = new Mat{new cv::Mat()}; + cv::dnn::blobFromImage(*image.ptr, *blob->ptr, scalefactor, sz, cm, swapRB, crop, ddepth); + callback(blob); + END_WRAP +} + +CvStatus *Net_BlobFromImages_Async(VecMat images, double scalefactor, Size size, Scalar mean, bool swapRB, bool crop, int ddepth, CvCallback_1 callback) +{ + BEGIN_WRAP + cv::Size sz(size.width, size.height); + cv::Scalar cm = cv::Scalar(mean.val1, mean.val2, mean.val3, mean.val4); + Mat *blob = new Mat{new cv::Mat()}; + cv::dnn::blobFromImages(*images.ptr, *blob->ptr, scalefactor, sz, cm, swapRB, crop, ddepth); + callback(blob); + END_WRAP +} + +CvStatus *Net_ImagesFromBlob_Async(Mat blob, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector imgs; + cv::dnn::imagesFromBlob(*blob.ptr, imgs); + callback(new VecMat{new std::vector(imgs)}); + END_WRAP +} + +CvStatus *Net_Empty_Async(Net net, CvCallback_1 callback) +{ + BEGIN_WRAP + bool rval = net.ptr->empty(); + callback(new bool(rval)); + END_WRAP +} + +CvStatus *Net_Dump_Async(Net net, CvCallback_1 callback) +{ + BEGIN_WRAP + auto ss = net.ptr->dump(); + callback(new char *(strdup(ss.c_str()))); + END_WRAP +} + +CvStatus *Net_SetInput_Async(Net net, Mat blob, const char *name, CvCallback_0 callback) +{ + BEGIN_WRAP + net.ptr->setInput(*blob.ptr, name); + callback(); + END_WRAP +} + +CvStatus *Net_Forward_Async(Net net, const char *outputName, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Mat{new cv::Mat(net.ptr->forward(outputName))}); + END_WRAP +} + +CvStatus *Net_ForwardLayers_Async(Net net, VecVecChar outBlobNames, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector blobs; + std::vector names; + for (int i = 0; i < outBlobNames.ptr->size(); ++i) + { + auto n = outBlobNames.ptr->at(i); + names.push_back(cv::String(n.begin(), n.end())); + } + net.ptr->forward(blobs, names); + callback(new VecMat{new std::vector(blobs)}); + END_WRAP +} + +CvStatus *Net_SetPreferableBackend_Async(Net net, int backend, CvCallback_0 callback) +{ + BEGIN_WRAP + net.ptr->setPreferableBackend(backend); + callback(); + END_WRAP +} + +CvStatus *Net_SetPreferableTarget_Async(Net net, int target, CvCallback_0 callback) +{ + BEGIN_WRAP + net.ptr->setPreferableTarget(target); + callback(); + END_WRAP +} + +CvStatus *Net_GetPerfProfile_Async(Net net, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector layersTimes; + int64_t rval = net.ptr->getPerfProfile(layersTimes); + callback(new int64_t(rval)); + END_WRAP +} + +CvStatus *Net_GetUnconnectedOutLayers_Async(Net net, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector layers = net.ptr->getUnconnectedOutLayers(); + callback(new VecInt{new std::vector(layers)}); + END_WRAP +} + +CvStatus *Net_GetLayerNames_Async(Net net, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector> vec; + std::vector cstrs = net.ptr->getLayerNames(); + for (size_t i = 0; i < cstrs.size(); i++) + { + std::vector cstr(cstrs[i].begin(), cstrs[i].end()); + vec.push_back(cstr); + } + callback(new VecVecChar{new std::vector>(vec)}); + END_WRAP +} + +CvStatus *Net_GetInputDetails_Async(Net net, CvCallback_2 callback) +{ + BEGIN_WRAP + std::vector sc; + std::vector zp; + net.ptr->getInputDetails(sc, zp); + callback(new VecFloat{new std::vector(sc)}, new VecInt{new std::vector(zp)}); + END_WRAP +} + +CvStatus *Net_GetBlobChannel_Async(Mat blob, int imgidx, int chnidx, CvCallback_1 callback) +{ + BEGIN_WRAP + size_t w = blob.ptr->size[3]; + size_t h = blob.ptr->size[2]; + callback(new Mat{new cv::Mat(h, w, CV_32F, blob.ptr->ptr(imgidx, chnidx))}); + END_WRAP +} + +CvStatus *Net_GetBlobSize_Async(Mat blob, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Scalar{(double)(blob.ptr->size[0]), (double)(blob.ptr->size[1]), (double)(blob.ptr->size[2]), (double)(blob.ptr->size[3])}); + END_WRAP +} + +CvStatus *Net_GetLayer_Async(Net net, int layerid, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new Layer{new cv::Ptr(net.ptr->getLayer(layerid))}); + END_WRAP +} + +CvStatus *Layer_InputNameToIndex_Async(Layer layer, const char *name, CvCallback_1 callback) +{ + BEGIN_WRAP + int rval = (*layer.ptr)->inputNameToIndex(name); + callback(new int(rval)); + END_WRAP +} + +CvStatus *Layer_OutputNameToIndex_Async(Layer layer, const char *name, CvCallback_1 callback) +{ + BEGIN_WRAP + int rval = (*layer.ptr)->outputNameToIndex(name); + callback(new int(rval)); + END_WRAP +} + +CvStatus *Layer_GetName_Async(Layer layer, CvCallback_1 callback) +{ + BEGIN_WRAP + auto ss = (*layer.ptr)->name; + callback(new char *(strdup(ss.c_str()))); + END_WRAP +} + +CvStatus *Layer_GetType_Async(Layer layer, CvCallback_1 callback) +{ + BEGIN_WRAP + auto ss = (*layer.ptr)->type; + callback(new char *(strdup(ss.c_str()))); + END_WRAP +} + +void Layer_Close_Async(LayerPtr layer, CvCallback_0 callback) +{ + layer->ptr->reset(); + CVD_FREE(layer); + callback(); +} + +CvStatus *NMSBoxes_Async(VecRect bboxes, VecFloat scores, float score_threshold, float nms_threshold, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector v; + cv::dnn::NMSBoxes(*bboxes.ptr, *scores.ptr, score_threshold, nms_threshold, v, 1.f, 0); + callback(new VecInt{new std::vector(v)}); + END_WRAP +} + +CvStatus *NMSBoxesWithParams_Async(VecRect bboxes, VecFloat scores, const float score_threshold, const float nms_threshold, const float eta, const int top_k, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector v; + cv::dnn::NMSBoxes(*bboxes.ptr, *scores.ptr, score_threshold, nms_threshold, v, eta, top_k); + callback(new VecInt{new std::vector(v)}); + END_WRAP +} diff --git a/src/dnn/dnn_async.h b/src/dnn/dnn_async.h new file mode 100644 index 00000000..5de32dc6 --- /dev/null +++ b/src/dnn/dnn_async.h @@ -0,0 +1,58 @@ +#ifndef CVD_DNN_ASYNC_H_ +#define CVD_DNN_ASYNC_H_ + +#include "dnn.h" +#include "core/types.h" +#include + +#ifdef __cplusplus +#include +#include +extern "C" { +#endif + +// Asynchronous functions for Net +CvStatus *Net_Create_Async(CvCallback_1 callback); +CvStatus *Net_FromNet_Async(Net net, CvCallback_1 callback); +CvStatus *Net_ReadNet_Async(const char *model, const char *config, const char *framework, CvCallback_1 callback); +CvStatus *Net_ReadNetBytes_Async(const char *framework, VecUChar model, VecUChar config, CvCallback_1 callback); +CvStatus *Net_ReadNetFromCaffe_Async(const char *prototxt, const char *caffeModel, CvCallback_1 callback); +CvStatus *Net_ReadNetFromCaffeBytes_Async(VecUChar prototxt, VecUChar caffeModel, CvCallback_1 callback); +CvStatus *Net_ReadNetFromTensorflow_Async(const char *model, const char *config, CvCallback_1 callback); +CvStatus *Net_ReadNetFromTensorflowBytes_Async(VecUChar model, VecUChar config, CvCallback_1 callback); +CvStatus *Net_ReadNetFromTFLite_Async(const char *model, CvCallback_1 callback); +CvStatus *Net_ReadNetFromTFLiteBytes_Async(VecUChar bufferModel, CvCallback_1 callback); +CvStatus *Net_ReadNetFromTorch_Async(const char *model, bool isBinary, bool evaluate, CvCallback_1 callback); +CvStatus *Net_ReadNetFromONNX_Async(const char *model, CvCallback_1 callback); +CvStatus *Net_ReadNetFromONNXBytes_Async(VecUChar model, CvCallback_1 callback); +void Net_Close_Async(NetPtr net, CvCallback_0 callback); +CvStatus *Net_BlobFromImage_Async(Mat image, double scalefactor, Size size, Scalar mean, bool swapRB, bool crop, int ddepth, CvCallback_1 callback); +CvStatus *Net_BlobFromImages_Async(VecMat images, double scalefactor, Size size, Scalar mean, bool swapRB, bool crop, int ddepth, CvCallback_1 callback); +CvStatus *Net_ImagesFromBlob_Async(Mat blob, CvCallback_1 callback); +CvStatus *Net_Empty_Async(Net net, CvCallback_1 callback); +CvStatus *Net_Dump_Async(Net net, CvCallback_1 callback); +CvStatus *Net_SetInput_Async(Net net, Mat blob, const char *name, CvCallback_0 callback); +CvStatus *Net_Forward_Async(Net net, const char *outputName, CvCallback_1 callback); +CvStatus *Net_ForwardLayers_Async(Net net, VecVecChar outBlobNames, CvCallback_1 callback); +CvStatus *Net_SetPreferableBackend_Async(Net net, int backend, CvCallback_0 callback); +CvStatus *Net_SetPreferableTarget_Async(Net net, int target, CvCallback_0 callback); +CvStatus *Net_GetPerfProfile_Async(Net net, CvCallback_1 callback); +CvStatus *Net_GetUnconnectedOutLayers_Async(Net net, CvCallback_1 callback); +CvStatus *Net_GetLayerNames_Async(Net net, CvCallback_1 callback); +CvStatus *Net_GetInputDetails_Async(Net net, CvCallback_2 callback); +CvStatus *Net_GetBlobChannel_Async(Mat blob, int imgidx, int chnidx, CvCallback_1 callback); +CvStatus *Net_GetBlobSize_Async(Mat blob, CvCallback_1 callback); +CvStatus *Net_GetLayer_Async(Net net, int layerid, CvCallback_1 callback); +CvStatus *Layer_InputNameToIndex_Async(Layer layer, const char *name, CvCallback_1 callback); +CvStatus *Layer_OutputNameToIndex_Async(Layer layer, const char *name, CvCallback_1 callback); +CvStatus *Layer_GetName_Async(Layer layer, CvCallback_1 callback); +CvStatus *Layer_GetType_Async(Layer layer, CvCallback_1 callback); +void Layer_Close_Async(LayerPtr layer, CvCallback_0 callback); +CvStatus *NMSBoxes_Async(VecRect bboxes, VecFloat scores, float score_threshold, float nms_threshold, CvCallback_1 callback); +CvStatus *NMSBoxesWithParams_Async(VecRect bboxes, VecFloat scores, const float score_threshold, const float nms_threshold, const float eta, const int top_k, CvCallback_1 callback); + +#ifdef __cplusplus +} +#endif + +#endif // CVD_DNN_ASYNC_H_ diff --git a/src/objdetect/objdetect_async.cpp b/src/objdetect/objdetect_async.cpp new file mode 100644 index 00000000..3bc8a89f --- /dev/null +++ b/src/objdetect/objdetect_async.cpp @@ -0,0 +1,419 @@ +#include "objdetect_async.h" +#include "core/types.h" + +// Asynchronous functions for CascadeClassifier +CvStatus *CascadeClassifier_New_Async(CvCallback_1 callback) { + BEGIN_WRAP + callback(new CascadeClassifier{new cv::CascadeClassifier()}); + END_WRAP +} + +CvStatus *CascadeClassifier_NewFromFile_Async(const char *filename, CvCallback_1 callback) { + BEGIN_WRAP + callback(new CascadeClassifier{new cv::CascadeClassifier(filename)}); + END_WRAP +} + +CvStatus *CascadeClassifier_Load_Async(CascadeClassifier self, const char *name, CvCallback_1 callback) { + BEGIN_WRAP + int rval = self.ptr->load(name); + callback(new int(rval)); + END_WRAP +} + +CvStatus *CascadeClassifier_DetectMultiScale_Async(CascadeClassifier self, Mat img, CvCallback_1 callback) { + BEGIN_WRAP + std::vector rects; + self.ptr->detectMultiScale(*img.ptr, rects); + callback(new VecRect{new std::vector(rects)}); + END_WRAP +} + +CvStatus *CascadeClassifier_DetectMultiScaleWithParams_Async(CascadeClassifier self, Mat img, double scale, int minNeighbors, int flags, Size minSize, Size maxSize, CvCallback_1 callback) { + BEGIN_WRAP + std::vector rects; + auto minsize = cv::Size(minSize.width, minSize.height); + auto maxsize = cv::Size(maxSize.width, maxSize.height); + self.ptr->detectMultiScale(*img.ptr, rects, scale, minNeighbors, flags, minsize, maxsize); + callback(new VecRect{new std::vector(rects)}); + END_WRAP +} + +CvStatus *CascadeClassifier_DetectMultiScale2_Async(CascadeClassifier self, Mat img, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize, CvCallback_2 callback) { + BEGIN_WRAP + std::vector rects; + std::vector nums; + auto minsize = cv::Size(minSize.width, minSize.height); + auto maxsize = cv::Size(maxSize.width, maxSize.height); + self.ptr->detectMultiScale(*img.ptr, rects, nums, scaleFactor, minNeighbors, flags, minsize, maxsize); + callback(new VecRect{new std::vector(rects)}, new VecInt{new std::vector(nums)}); + END_WRAP +} + +CvStatus *CascadeClassifier_DetectMultiScale3_Async(CascadeClassifier self, Mat img, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize, bool outputRejectLevels, CvCallback_3 callback) { + BEGIN_WRAP + std::vector rects; + std::vector rejects; + std::vector weights; + auto minsize = cv::Size(minSize.width, minSize.height); + auto maxsize = cv::Size(maxSize.width, maxSize.height); + self.ptr->detectMultiScale(*img.ptr, rects, rejects, weights, scaleFactor, minNeighbors, flags, minsize, maxsize, outputRejectLevels); + callback(new VecRect{new std::vector(rects)}, new VecInt{new std::vector(rejects)}, new VecDouble{new std::vector(weights)}); + END_WRAP +} + +CvStatus *CascadeClassifier_Empty_Async(CascadeClassifier self, CvCallback_1 callback) { + BEGIN_WRAP + bool rval = self.ptr->empty(); + callback(new bool(rval)); + END_WRAP +} + +CvStatus *CascadeClassifier_getFeatureType_Async(CascadeClassifier self, CvCallback_1 callback) { + BEGIN_WRAP + int rval = self.ptr->getFeatureType(); + callback(new int(rval)); + END_WRAP +} + +CvStatus *CascadeClassifier_getOriginalWindowSize_Async(CascadeClassifier self, CvCallback_1 callback) { + BEGIN_WRAP + auto sz = self.ptr->getOriginalWindowSize(); + callback(new Size{sz.width, sz.height}); + END_WRAP +} + +CvStatus *CascadeClassifier_isOldFormatCascade_Async(CascadeClassifier self, CvCallback_1 callback) { + BEGIN_WRAP + bool rval = self.ptr->isOldFormatCascade(); + callback(new bool(rval)); + END_WRAP +} + +// Asynchronous functions for HOGDescriptor +CvStatus *HOGDescriptor_New_Async(CvCallback_1 callback) { + BEGIN_WRAP + callback(new HOGDescriptor{new cv::HOGDescriptor()}); + END_WRAP +} + +CvStatus *HOGDescriptor_NewFromFile_Async(const char *filename, CvCallback_1 callback) { + BEGIN_WRAP + callback(new HOGDescriptor{new cv::HOGDescriptor(filename)}); + END_WRAP +} + +CvStatus *HOGDescriptor_Load_Async(HOGDescriptor self, const char *name, CvCallback_1 callback) { + BEGIN_WRAP + bool rval = self.ptr->load(name); + callback(new bool(rval)); + END_WRAP +} + +CvStatus *HOGDescriptor_Detect_Async(HOGDescriptor self, Mat img, double hitThresh, Size winStride, Size padding, CvCallback_3 callback) { + BEGIN_WRAP + std::vector _foundLocations; + std::vector _searchLocations; + std::vector _weights; + self.ptr->detect(*img.ptr, _foundLocations, _weights, hitThresh, cv::Point(winStride.width, winStride.height), cv::Point(padding.width, padding.height), _searchLocations); + callback(new VecPoint{new std::vector(_foundLocations)}, new VecDouble{new std::vector(_weights)}, new VecPoint{new std::vector(_searchLocations)}); + END_WRAP +} + +CvStatus *HOGDescriptor_Detect2_Async(HOGDescriptor self, Mat img, double hitThresh, Size winStride, Size padding, CvCallback_2 callback) { + BEGIN_WRAP + std::vector _foundLocations; + std::vector _searchLocations; + self.ptr->detect(*img.ptr, _foundLocations, hitThresh, cv::Point(winStride.width, winStride.height), cv::Point(padding.width, padding.height), _searchLocations); + callback(new VecPoint{new std::vector(_foundLocations)}, new VecPoint{new std::vector(_searchLocations)}); + END_WRAP +} + +CvStatus *HOGDescriptor_DetectMultiScale_Async(HOGDescriptor self, Mat img, CvCallback_1 callback) { + BEGIN_WRAP + std::vector rects; + self.ptr->detectMultiScale(*img.ptr, rects); + callback(new VecRect{new std::vector(rects)}); + END_WRAP +} + +CvStatus *HOGDescriptor_DetectMultiScaleWithParams_Async(HOGDescriptor self, Mat img, double hitThresh, Size winStride, Size padding, double scale, double finalThreshold, bool useMeanshiftGrouping, CvCallback_1 callback) { + BEGIN_WRAP + std::vector rects; + auto winstride = cv::Size(winStride.width, winStride.height); + auto pad = cv::Size(padding.width, padding.height); + self.ptr->detectMultiScale(*img.ptr, rects, hitThresh, winstride, pad, scale, finalThreshold, useMeanshiftGrouping); + callback(new VecRect{new std::vector(rects)}); + END_WRAP +} + +CvStatus *HOGDescriptor_Compute_Async(HOGDescriptor self, Mat img, Size winStride, Size padding, CvCallback_2 callback) { + BEGIN_WRAP + std::vector _descriptors; + std::vector _locations; + self.ptr->compute(*img.ptr, _descriptors, cv::Size(winStride.width, winStride.height), cv::Size(padding.width, padding.height), _locations); + callback(new VecFloat{new std::vector(_descriptors)}, new VecPoint{new std::vector(_locations)}); + END_WRAP +} + +CvStatus *HOGDescriptor_computeGradient_Async(HOGDescriptor self, Mat img, Mat grad, Mat angleOfs, Size paddingTL, Size paddingBR, CvCallback_0 callback) { + BEGIN_WRAP + self.ptr->computeGradient(*img.ptr, *grad.ptr, *angleOfs.ptr, cv::Size(paddingTL.width, paddingTL.height), cv::Size(paddingBR.width, paddingBR.height)); + callback(); + END_WRAP +} + +CvStatus *HOG_GetDefaultPeopleDetector_Async(CvCallback_1 callback) { + BEGIN_WRAP + callback(new VecFloat{new std::vector(cv::HOGDescriptor::getDefaultPeopleDetector())}); + END_WRAP +} + +CvStatus *HOGDescriptor_SetSVMDetector_Async(HOGDescriptor self, VecFloat det, CvCallback_0 callback) { + BEGIN_WRAP + self.ptr->setSVMDetector(*det.ptr); + callback(); + END_WRAP +} + +CvStatus *HOGDescriptor_getDaimlerPeopleDetector_Async(CvCallback_1 callback) { + BEGIN_WRAP + callback(new VecFloat{new std::vector(cv::HOGDescriptor::getDaimlerPeopleDetector())}); + END_WRAP +} + +CvStatus *HOGDescriptor_getDescriptorSize_Async(HOGDescriptor self, CvCallback_1 callback) { + BEGIN_WRAP + size_t rval = self.ptr->getDescriptorSize(); + callback(new size_t(rval)); + END_WRAP +} + +CvStatus *HOGDescriptor_getWinSigma_Async(HOGDescriptor self, CvCallback_1 callback) { + BEGIN_WRAP + double rval = self.ptr->getWinSigma(); + callback(new double(rval)); + END_WRAP +} + +CvStatus *HOGDescriptor_groupRectangles_Async(HOGDescriptor self, VecRect rectList, VecDouble weights, int groupThreshold, double eps, CvCallback_0 callback) { + BEGIN_WRAP + self.ptr->groupRectangles(*rectList.ptr, *weights.ptr, groupThreshold, eps); + callback(); + END_WRAP +} + +CvStatus *GroupRectangles_Async(VecRect rects, int groupThreshold, double eps, CvCallback_0 callback) { + BEGIN_WRAP + cv::groupRectangles(*rects.ptr, groupThreshold, eps); + callback(); + END_WRAP +} + +// Asynchronous functions for QRCodeDetector +CvStatus *QRCodeDetector_New_Async(CvCallback_1 callback) { + BEGIN_WRAP + callback(new QRCodeDetector{new cv::QRCodeDetector()}); + END_WRAP +} + +CvStatus *QRCodeDetector_DetectAndDecode_Async(QRCodeDetector self, Mat input, CvCallback_3 callback) { + BEGIN_WRAP + std::vector points_; + cv::Mat straight_qrcode; + auto info = self.ptr->detectAndDecode(*input.ptr, points_, straight_qrcode); + callback(new char*(strdup(info.c_str())), new VecPoint{new std::vector(points_)}, new Mat{new cv::Mat(straight_qrcode)}); + END_WRAP +} + +CvStatus *QRCodeDetector_Detect_Async(QRCodeDetector self, Mat input, CvCallback_2 callback) { + BEGIN_WRAP + std::vector _points; + bool rval = self.ptr->detect(*input.ptr, _points); + callback(new bool(rval), new VecPoint{new std::vector(_points)}); + END_WRAP +} + +CvStatus *QRCodeDetector_Decode_Async(QRCodeDetector self, Mat input, CvCallback_3 callback) { + BEGIN_WRAP + std::vector _points; + cv::Mat straight_qrcode; + auto info = self.ptr->detectAndDecode(*input.ptr, _points, straight_qrcode); + callback(new char*(strdup(info.c_str())), new VecPoint{new std::vector(_points)}, new Mat{new cv::Mat(straight_qrcode)}); + END_WRAP +} + +CvStatus *QRCodeDetector_decodeCurved_Async(QRCodeDetector self, Mat img, VecPoint points, CvCallback_2 callback) { + BEGIN_WRAP + cv::Mat _straight_qrcode; + auto ret = self.ptr->decodeCurved(*img.ptr, *points.ptr, _straight_qrcode); + callback(new char*(strdup(ret.c_str())), new Mat{new cv::Mat(_straight_qrcode)}); + END_WRAP +} + +CvStatus *QRCodeDetector_detectAndDecodeCurved_Async(QRCodeDetector self, Mat img, CvCallback_3 callback) { + BEGIN_WRAP + cv::Mat _straight_qrcode; + std::vector _points; + auto ret = self.ptr->detectAndDecodeCurved(*img.ptr, _points, _straight_qrcode); + callback(new char*(strdup(ret.c_str())), new VecPoint{new std::vector(_points)}, new Mat{new cv::Mat(_straight_qrcode)}); + END_WRAP +} + +CvStatus *QRCodeDetector_DetectMulti_Async(QRCodeDetector self, Mat input, CvCallback_2 callback) { + BEGIN_WRAP + std::vector _points; + bool rval = self.ptr->detectMulti(*input.ptr, _points); + callback(new bool(rval), new VecPoint{new std::vector(_points)}); + END_WRAP +} + +CvStatus *QRCodeDetector_DetectAndDecodeMulti_Async(QRCodeDetector self, Mat input, CvCallback_4 callback) { + BEGIN_WRAP + std::vector decodedCodes; + std::vector straightQrCodes; + std::vector points_; + bool rval = self.ptr->detectAndDecodeMulti(*input.ptr, decodedCodes, points_, straightQrCodes); + if (!rval) { + callback(new bool(rval), new VecVecChar{new std::vector>()}, new VecPoint{new std::vector()}, new VecMat{new std::vector()}); + } else { + std::vector> vecvec; + for (int i = 0; i < decodedCodes.size(); i++) { + vecvec.push_back(std::vector(decodedCodes[i].begin(), decodedCodes[i].end())); + } + callback(new bool(rval), new VecVecChar{new std::vector>(vecvec)}, new VecPoint{new std::vector(points_)}, new VecMat{new std::vector(straightQrCodes)}); + } + END_WRAP +} + +CvStatus *QRCodeDetector_setEpsX_Async(QRCodeDetector self, double epsX, CvCallback_0 callback) { + BEGIN_WRAP + self.ptr->setEpsX(epsX); + callback(); + END_WRAP +} + +CvStatus *QRCodeDetector_setEpsY_Async(QRCodeDetector self, double epsY, CvCallback_0 callback) { + BEGIN_WRAP + self.ptr->setEpsY(epsY); + callback(); + END_WRAP +} + +CvStatus *QRCodeDetector_setUseAlignmentMarkers_Async(QRCodeDetector self, bool useAlignmentMarkers, CvCallback_0 callback) { + BEGIN_WRAP + self.ptr->setUseAlignmentMarkers(useAlignmentMarkers); + callback(); + END_WRAP +} + +// Asynchronous functions for FaceDetectorYN +CvStatus *FaceDetectorYN_New_Async(const char *model, const char *config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id, CvCallback_1 callback) { + BEGIN_WRAP + callback(new FaceDetectorYN{new cv::Ptr(cv::FaceDetectorYN::create(model, config, cv::Size(input_size.width, input_size.height), score_threshold, nms_threshold, top_k, backend_id, target_id))}); + END_WRAP +} + +CvStatus *FaceDetectorYN_NewFromBuffer_Async(const char *framework, VecUChar buffer, VecUChar buffer_config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id, CvCallback_1 callback) { + BEGIN_WRAP + callback(new FaceDetectorYN{new cv::Ptr(cv::FaceDetectorYN::create(framework, *buffer.ptr, *buffer_config.ptr, cv::Size(input_size.width, input_size.height), score_threshold, nms_threshold, top_k, backend_id, target_id))}); + END_WRAP +} + +CvStatus *FaceDetectorYN_Detect_Async(FaceDetectorYN self, Mat img, CvCallback_1 callback) { + BEGIN_WRAP + cv::Mat faces; + (*self.ptr)->detect(*img.ptr, faces); + callback(new Mat{new cv::Mat(faces)}); + END_WRAP +} + +CvStatus *FaceDetectorYN_SetInputSize_Async(FaceDetectorYN self, Size input_size, CvCallback_0 callback) { + BEGIN_WRAP + (*self.ptr)->setInputSize(cv::Size(input_size.width, input_size.height)); + callback(); + END_WRAP +} + +CvStatus *FaceDetectorYN_GetInputSize_Async(FaceDetectorYN self, CvCallback_1 callback) { + BEGIN_WRAP + cv::Size sz = (*self.ptr)->getInputSize(); + callback(new Size{sz.width, sz.height}); + END_WRAP +} + +CvStatus *FaceDetectorYN_SetScoreThreshold_Async(FaceDetectorYN self, float score_threshold, CvCallback_0 callback) { + BEGIN_WRAP + (*self.ptr)->setScoreThreshold(score_threshold); + callback(); + END_WRAP +} + +CvStatus *FaceDetectorYN_GetScoreThreshold_Async(FaceDetectorYN self, CvCallback_1 callback) { + BEGIN_WRAP + float score_threshold = (*self.ptr)->getScoreThreshold(); + callback(new float(score_threshold)); + END_WRAP +} + +CvStatus *FaceDetectorYN_SetNMSThreshold_Async(FaceDetectorYN self, float nms_threshold, CvCallback_0 callback) { + BEGIN_WRAP + (*self.ptr)->setNMSThreshold(nms_threshold); + callback(); + END_WRAP +} + +CvStatus *FaceDetectorYN_GetNMSThreshold_Async(FaceDetectorYN self, CvCallback_1 callback) { + BEGIN_WRAP + float nms_threshold = (*self.ptr)->getNMSThreshold(); + callback(new float(nms_threshold)); + END_WRAP +} + +CvStatus *FaceDetectorYN_SetTopK_Async(FaceDetectorYN self, int top_k, CvCallback_0 callback) { + BEGIN_WRAP + (*self.ptr)->setTopK(top_k); + callback(); + END_WRAP +} + +CvStatus *FaceDetectorYN_GetTopK_Async(FaceDetectorYN self, CvCallback_1 callback) { + BEGIN_WRAP + int top_k = (*self.ptr)->getTopK(); + callback(new int(top_k)); + END_WRAP +} + +// Asynchronous functions for FaceRecognizerSF +CvStatus *FaceRecognizerSF_New_Async(const char *model, const char *config, int backend_id, int target_id, CvCallback_1 callback) { + BEGIN_WRAP + callback(new FaceRecognizerSF{new cv::Ptr(cv::FaceRecognizerSF::create(model, config, backend_id, target_id))}); + END_WRAP +} + +CvStatus *FaceRecognizerSF_AlignCrop_Async(FaceRecognizerSF self, Mat src_img, Mat face_box, CvCallback_1 callback) { + BEGIN_WRAP + cv::Mat aligned_img; + (*self.ptr)->alignCrop(*src_img.ptr, *face_box.ptr, aligned_img); + callback(new Mat{new cv::Mat(aligned_img)}); + END_WRAP +} + +CvStatus *FaceRecognizerSF_Feature_Async(FaceRecognizerSF self, Mat aligned_img, bool clone, CvCallback_1 callback) { + BEGIN_WRAP + cv::Mat face_feature; + (*self.ptr)->feature(*aligned_img.ptr, face_feature); + if (clone) { + callback(new Mat{new cv::Mat(face_feature.clone())}); + } else { + callback(new Mat{new cv::Mat(face_feature)}); + } + END_WRAP +} + +CvStatus *FaceRecognizerSF_Match_Async(FaceRecognizerSF self, Mat face_feature1, Mat face_feature2, int dis_type, CvCallback_1 callback) { + BEGIN_WRAP + double distance = (*self.ptr)->match(*face_feature1.ptr, *face_feature2.ptr, dis_type); + callback(new double(distance)); + END_WRAP +} diff --git a/src/objdetect/objdetect_async.h b/src/objdetect/objdetect_async.h new file mode 100644 index 00000000..f0eef021 --- /dev/null +++ b/src/objdetect/objdetect_async.h @@ -0,0 +1,81 @@ +/* Created by Rainyl. Licensed: Apache 2.0 license. Copyright (c) 2024 Rainyl. */ +#ifndef CVD_OBJDETECT_ASYNC_H_ +#define CVD_OBJDETECT_ASYNC_H_ + +#include "core/types.h" +#include "objdetect.h" +#include + +#ifdef __cplusplus +#include +extern "C" { +#endif + +// CascadeClassifier +CvStatus *CascadeClassifier_New_Async(CvCallback_1 callback); +CvStatus *CascadeClassifier_NewFromFile_Async(const char *filename, CvCallback_1 callback); +CvStatus *CascadeClassifier_Load_Async(CascadeClassifier self, const char *name, CvCallback_1 callback); +CvStatus *CascadeClassifier_DetectMultiScale_Async(CascadeClassifier self, Mat img, CvCallback_1 callback); +CvStatus *CascadeClassifier_DetectMultiScaleWithParams_Async(CascadeClassifier self, Mat img, double scale, int minNeighbors, int flags, Size minSize, Size maxSize, CvCallback_1 callback); +CvStatus *CascadeClassifier_DetectMultiScale2_Async(CascadeClassifier self, Mat img, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize, CvCallback_2 callback); +CvStatus *CascadeClassifier_DetectMultiScale3_Async(CascadeClassifier self, Mat img, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize, bool outputRejectLevels, CvCallback_3 callback); +CvStatus *CascadeClassifier_Empty_Async(CascadeClassifier self, CvCallback_1 callback); +CvStatus *CascadeClassifier_getFeatureType_Async(CascadeClassifier self, CvCallback_1 callback); +CvStatus *CascadeClassifier_getOriginalWindowSize_Async(CascadeClassifier self, CvCallback_1 callback); +CvStatus *CascadeClassifier_isOldFormatCascade_Async(CascadeClassifier self, CvCallback_1 callback); + +// HOGDescriptor +CvStatus *HOGDescriptor_New_Async(CvCallback_1 callback); +CvStatus *HOGDescriptor_NewFromFile_Async(const char *filename, CvCallback_1 callback); +CvStatus *HOGDescriptor_Load_Async(HOGDescriptor self, const char *name, CvCallback_1 callback); +CvStatus *HOGDescriptor_Detect_Async(HOGDescriptor self, Mat img, double hitThresh, Size winStride, Size padding, CvCallback_3 callback); +CvStatus *HOGDescriptor_Detect2_Async(HOGDescriptor self, Mat img, double hitThresh, Size winStride, Size padding, CvCallback_2 callback); +CvStatus *HOGDescriptor_DetectMultiScale_Async(HOGDescriptor self, Mat img, CvCallback_1 callback); +CvStatus *HOGDescriptor_DetectMultiScaleWithParams_Async(HOGDescriptor self, Mat img, double hitThresh, Size winStride, Size padding, double scale, double finalThreshold, bool useMeanshiftGrouping, CvCallback_1 callback); +CvStatus *HOGDescriptor_Compute_Async(HOGDescriptor self, Mat img, Size winStride, Size padding, CvCallback_2 callback); +CvStatus *HOGDescriptor_computeGradient_Async(HOGDescriptor self, Mat img, Mat grad, Mat angleOfs, Size paddingTL, Size paddingBR, CvCallback_0 callback); +CvStatus *HOG_GetDefaultPeopleDetector_Async(CvCallback_1 callback); +CvStatus *HOGDescriptor_SetSVMDetector_Async(HOGDescriptor self, VecFloat det, CvCallback_0 callback); +CvStatus *HOGDescriptor_getDaimlerPeopleDetector_Async(CvCallback_1 callback); +CvStatus *HOGDescriptor_getDescriptorSize_Async(HOGDescriptor self, CvCallback_1 callback); +CvStatus *HOGDescriptor_getWinSigma_Async(HOGDescriptor self, CvCallback_1 callback); +CvStatus *HOGDescriptor_groupRectangles_Async(HOGDescriptor self, VecRect rectList, VecDouble weights, int groupThreshold, double eps, CvCallback_0 callback); +CvStatus *GroupRectangles_Async(VecRect rects, int groupThreshold, double eps, CvCallback_0 callback); + +// QRCodeDetector +CvStatus *QRCodeDetector_New_Async(CvCallback_1 callback); +CvStatus *QRCodeDetector_DetectAndDecode_Async(QRCodeDetector self, Mat input, CvCallback_3 callback); +CvStatus *QRCodeDetector_Detect_Async(QRCodeDetector self, Mat input, CvCallback_2 callback); +CvStatus *QRCodeDetector_Decode_Async(QRCodeDetector self, Mat input, CvCallback_3 callback); +CvStatus *QRCodeDetector_decodeCurved_Async(QRCodeDetector self, Mat img, VecPoint points, CvCallback_2 callback); +CvStatus *QRCodeDetector_detectAndDecodeCurved_Async(QRCodeDetector self, Mat img, CvCallback_3 callback); +CvStatus *QRCodeDetector_DetectMulti_Async(QRCodeDetector self, Mat input, CvCallback_2 callback); +CvStatus *QRCodeDetector_DetectAndDecodeMulti_Async(QRCodeDetector self, Mat input, CvCallback_4 callback); +CvStatus *QRCodeDetector_setEpsX_Async(QRCodeDetector self, double epsX, CvCallback_0 callback); +CvStatus *QRCodeDetector_setEpsY_Async(QRCodeDetector self, double epsY, CvCallback_0 callback); +CvStatus *QRCodeDetector_setUseAlignmentMarkers_Async(QRCodeDetector self, bool useAlignmentMarkers, CvCallback_0 callback); + +// FaceDetectorYN +CvStatus *FaceDetectorYN_New_Async(const char *model, const char *config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id, CvCallback_1 callback); +CvStatus *FaceDetectorYN_NewFromBuffer_Async(const char *framework, VecUChar buffer, VecUChar buffer_config, Size input_size, float score_threshold, float nms_threshold, int top_k, int backend_id, int target_id, CvCallback_1 callback); +CvStatus *FaceDetectorYN_Detect_Async(FaceDetectorYN self, Mat img, CvCallback_1 callback); +CvStatus *FaceDetectorYN_SetInputSize_Async(FaceDetectorYN self, Size input_size, CvCallback_0 callback); +CvStatus *FaceDetectorYN_GetInputSize_Async(FaceDetectorYN self, CvCallback_1 callback); +CvStatus *FaceDetectorYN_SetScoreThreshold_Async(FaceDetectorYN self, float score_threshold, CvCallback_0 callback); +CvStatus *FaceDetectorYN_GetScoreThreshold_Async(FaceDetectorYN self, CvCallback_1 callback); +CvStatus *FaceDetectorYN_SetNMSThreshold_Async(FaceDetectorYN self, float nms_threshold, CvCallback_0 callback); +CvStatus *FaceDetectorYN_GetNMSThreshold_Async(FaceDetectorYN self, CvCallback_1 callback); +CvStatus *FaceDetectorYN_SetTopK_Async(FaceDetectorYN self, int top_k, CvCallback_0 callback); +CvStatus *FaceDetectorYN_GetTopK_Async(FaceDetectorYN self, CvCallback_1 callback); + +// FaceRecognizerSF +CvStatus *FaceRecognizerSF_New_Async(const char *model, const char *config, int backend_id, int target_id, CvCallback_1 callback); +CvStatus *FaceRecognizerSF_AlignCrop_Async(FaceRecognizerSF self, Mat src_img, Mat face_box, CvCallback_1 callback); +CvStatus *FaceRecognizerSF_Feature_Async(FaceRecognizerSF self, Mat aligned_img, bool clone, CvCallback_1 callback); +CvStatus *FaceRecognizerSF_Match_Async(FaceRecognizerSF self, Mat face_feature1, Mat face_feature2, int dis_type, CvCallback_1 callback); + +#ifdef __cplusplus +} +#endif + +#endif // CVD_OBJDETECT_ASYNC_H_ diff --git a/test/dnn/dnn_async_test.dart b/test/dnn/dnn_async_test.dart new file mode 100644 index 00000000..5f5cfbe3 --- /dev/null +++ b/test/dnn/dnn_async_test.dart @@ -0,0 +1,272 @@ +import 'dart:io'; +import 'package:opencv_dart/opencv_dart.dart' as cv; +import 'package:test/test.dart'; + +Future checkCaffeNetAsync(cv.Net net) async { + expect(net.isEmpty, false); + await net.setPreferableBackendAsync(cv.DNN_BACKEND_DEFAULT); + await net.setPreferableTargetAsync(cv.DNN_TARGET_CPU); + + final img = await cv.imreadAsync("test/images/space_shuttle.jpg", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final blob = await cv.blobFromImageAsync( + img, + scalefactor: 1.0, + size: (224, 224), + mean: cv.Scalar.all(0), + swapRB: false, + crop: false, + ); + expect(blob.isEmpty, false); + + await net.setInputAsync(blob, name: "data"); + final layer = await net.getLayerAsync(0); + expect(await layer.inputNameToIndexAsync("notthere"), -1); + expect(await layer.outputNameToIndexAsync("notthere"), -1); + expect(await layer.nameAsync, "_input"); + expect(await layer.typeAsync, ""); + + final ids = await net.getUnconnectedOutLayersAsync(); + expect((ids.length, ids.first), (1, 142)); + + final lnames = await net.getLayerNamesAsync(); + expect((lnames.length, lnames[1]), (142, "conv1/relu_7x7")); + + final prob = await net.forwardLayersAsync(["prob"]); + expect(prob.length, greaterThan(0)); + expect(prob.first.isEmpty, false); + + final probMat = prob.first.reshape(1, 1); + //TODO: Migrate to async + final (_, maxVal, minLoc, maxLoc) = cv.minMaxLoc(probMat); + expect(maxVal, closeTo(0.9998, 5e-5)); + expect((minLoc.x, minLoc.y), (955, 0)); + expect((maxLoc.x, maxLoc.y), (812, 0)); + + final perf = await net.getPerfProfileAsync(); + expect(perf, greaterThan(0)); + + return true; +} + +Future checkTensorflowAsync(cv.Net net) async { + expect(net.isEmpty, false); + final img = await cv.imreadAsync("test/images/space_shuttle.jpg", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final blob = await cv.blobFromImageAsync( + img, + scalefactor: 1.0, + size: (224, 224), + mean: cv.Scalar.all(0), + swapRB: true, + crop: false, + ); + expect(blob.isEmpty, false); + + await net.setInputAsync(blob, name: "input"); + final prob = await net.forwardLayersAsync(["softmax2"]); + expect(prob.isEmpty, false); + + final probMat = prob.first.reshape(1, 1); + //TODO: Migrate to async + final (_, maxVal, minLoc, maxLoc) = cv.minMaxLoc(probMat); + expect(maxVal, closeTo(1.0, 5e-5)); + expect((minLoc.x, minLoc.y), (481, 0)); + expect((maxLoc.x, maxLoc.y), (234, 0)); + + final perf = await net.getPerfProfileAsync(); + expect(perf, greaterThan(0)); + + return true; +} + +Future checkOnnxAsync(cv.Net net) async { + expect(net.isEmpty, false); + final img = await cv.imreadAsync("test/images/space_shuttle.jpg", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final blob = await cv.blobFromImageAsync( + img, + scalefactor: 1.0, + size: (224, 224), + mean: cv.Scalar.all(0), + swapRB: true, + crop: false, + ); + expect(blob.isEmpty, false); + + await net.setInputAsync(blob, name: "data_0"); + final prob = await net.forwardLayersAsync(["prob_1"]); + expect(prob.isEmpty, false); + + final probMat = prob.first.reshape(1, 1); + //TODO: Migrate to async + final (_, maxVal, minLoc, maxLoc) = cv.minMaxLoc(probMat); + expect(maxVal, closeTo(0.9965, 5e-3)); + expect((minLoc.x, minLoc.y), (955, 0)); + expect((maxLoc.x, maxLoc.y), (812, 0)); + + final perf = await net.getPerfProfileAsync(); + expect(perf, greaterThan(0)); + + return true; +} + +Future checkTfliteAsync(cv.Net net) async { + expect(net.isEmpty, false); + final img = await cv.imreadAsync("test/images/space_shuttle.jpg", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final blob = await cv.blobFromImageAsync( + img, + scalefactor: 1.0, + size: (224, 224), + mean: cv.Scalar.all(0), + swapRB: true, + crop: false, + ); + expect(blob.isEmpty, false); + + // TODO: TFLite support of opencv is not complete + // print(net.getLayerNames()); + // net.setInput(blob, name: "inputs_0"); + + return true; +} + +void main() async { + test('cv.NetAsync.fromFileAsync', () async { + final net = await cv.NetAsync.emptyAsync(); + expect(net.isEmpty, true); + + final model = await cv.NetAsync.fromFileAsync( + "test/models/bvlc_googlenet.caffemodel", + config: "test/models/bvlc_googlenet.prototxt", + ); + await checkCaffeNetAsync(model); + expect(await model.dumpAsync(), isNotEmpty); + + model.dispose(); + }); + + test('cv.NetAsync.fromBytesAsync', () async { + final bytes = await File("test/models/bvlc_googlenet.caffemodel").readAsBytes(); + final config = await File("test/models/bvlc_googlenet.prototxt").readAsBytes(); + final model = await cv.NetAsync.fromBytesAsync("caffe", bytes, bufferConfig: config); + await checkCaffeNetAsync(model); + + model.dispose(); + }); + + test('cv.NetAsync.fromCaffeAsync', () async { + final model = await cv.NetAsync.fromCaffeAsync( + "test/models/bvlc_googlenet.prototxt", + "test/models/bvlc_googlenet.caffemodel", + ); + await checkCaffeNetAsync(model); + }); + + test('cv.NetAsync.fromCaffeBytesAsync', () async { + final bytes = await File("test/models/bvlc_googlenet.caffemodel").readAsBytes(); + final config = await File("test/models/bvlc_googlenet.prototxt").readAsBytes(); + final model = await cv.NetAsync.fromCaffeBytesAsync(config, bytes); + await checkCaffeNetAsync(model); + }); + + test('cv.NetAsync.fromOnnxAsync', () async { + final model = await cv.NetAsync.fromOnnxAsync("test/models/googlenet-9.onnx"); + await checkOnnxAsync(model); + }); + + test('cv.NetAsync.fromOnnxBytesAsync', () async { + final bytes = await File("test/models/googlenet-9.onnx").readAsBytes(); + final model = await cv.NetAsync.fromOnnxBytesAsync(bytes); + await checkOnnxAsync(model); + }); + + test('cv.NetAsync.fromTensorflowAsync', () async { + final model = await cv.NetAsync.fromTensorflowAsync("test/models/tensorflow_inception_graph.pb"); + expect(model.isEmpty, false); + await checkTensorflowAsync(model); + }); + + test('cv.NetAsync.fromTensorflowBytesAsync', () async { + final bytes = await File("test/models/tensorflow_inception_graph.pb").readAsBytes(); + final model = await cv.NetAsync.fromTensorflowBytesAsync(bytes); + expect(model.isEmpty, false); + await checkTensorflowAsync(model); + }); + + test('cv.NetAsync.fromTFLiteAsync', skip: true, () async { + final model = await cv.NetAsync.fromTFLiteAsync("test/models/googlenet_float32.tflite"); + await checkTfliteAsync(model); + }); + + test('cv.NetAsync.fromTorchAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + final model = await cv.NetAsync.fromTorchAsync("test/models/openface.nn4.small2.v1.t7"); + expect(model.isEmpty, false); + + final blob = await cv.blobFromImageAsync( + img, + scalefactor: 1.0, + size: (224, 224), + mean: cv.Scalar.all(0), + swapRB: false, + crop: false, + ); + expect(blob.isEmpty, false); + }); + + test('cv.blobFromImagesAsync, cv.imagesFromBlobAsync, cv.getBlobChannelAsync', () async { + final imgs = [ + await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR), + await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR), + ].cvd; + + final blob = await cv.blobFromImagesAsync(imgs); + expect(blob.isEmpty, false); + expect(await cv.getBlobSizeAsync(blob), cv.Scalar(2, 3, 480, 512)); + + final images = await cv.imagesFromBlobAsync(blob); + expect(images.length, 2); + expect((images.first.rows, images.first.cols), (imgs.first.rows, imgs.first.cols)); + expect((images.last.rows, images.last.cols), (imgs.last.rows, imgs.last.cols)); + + final ch2 = await cv.getBlobChannelAsync(blob, 0, 1); + expect(ch2.isEmpty, false); + expect((ch2.rows, ch2.cols), (imgs.first.rows, imgs.first.cols)); + }); + + test('cv.blobFromImagesAsync GrayScale', () async { + final imgs = [ + await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_GRAYSCALE), + await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_GRAYSCALE), + ].cvd; + + final blob = await cv.blobFromImagesAsync(imgs); + expect(blob.isEmpty, false); + expect(await cv.getBlobSizeAsync(blob), cv.Scalar(2, 1, 480, 512)); + }); + + test('cv.NMSBoxesAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + //TODO: Migrate to async + img.convertTo(cv.MatType.CV_32FC1); + + final bboxes = [ + cv.Rect(53, 47, 589, 451), + cv.Rect(118, 54, 618, 450), + cv.Rect(53, 66, 605, 480), + cv.Rect(111, 65, 630, 480), + cv.Rect(156, 51, 640, 480), + ].cvd; + final scores = [0.82094115, 0.7998236, 0.9809663, 0.99717456, 0.89628726].f32; + final indices = await cv.NMSBoxesAsync(bboxes, scores, 0.5, 0.4); + expect(indices.first, 3); + }); +} diff --git a/test/dnn_test.dart b/test/dnn/dnn_test.dart similarity index 100% rename from test/dnn_test.dart rename to test/dnn/dnn_test.dart diff --git a/test/objdetect/objdetect_async_test.dart b/test/objdetect/objdetect_async_test.dart new file mode 100644 index 00000000..560f3730 --- /dev/null +++ b/test/objdetect/objdetect_async_test.dart @@ -0,0 +1,318 @@ +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:opencv_dart/opencv_dart.dart' as cv; +import 'package:opencv_dart/src/core/mat_type.dart'; +import 'package:test/test.dart'; + +cv.Mat visualizeFaceDetect(cv.Mat img, cv.Mat faces) { + expect(faces.rows, greaterThanOrEqualTo(1)); + for (int row = 0; row < faces.rows; row++) { + final rect = cv.Rect( + faces.at(row, 0).toInt(), + faces.at(row, 1).toInt(), + faces.at(row, 2).toInt(), + faces.at(row, 3).toInt(), + ); + final points = [ + cv.Point(faces.at(row, 4).toInt(), faces.at(row, 5).toInt()), + cv.Point(faces.at(row, 6).toInt(), faces.at(row, 7).toInt()), + cv.Point(faces.at(row, 8).toInt(), faces.at(row, 9).toInt()), + cv.Point(faces.at(row, 10).toInt(), faces.at(row, 11).toInt()), + cv.Point(faces.at(row, 12).toInt(), faces.at(row, 13).toInt()), + ]; + cv.rectangle(img, rect, cv.Scalar.green, thickness: 2); + for (final p in points) { + cv.circle(img, p, 2, cv.Scalar.blue, thickness: 2); + } + } + return img; +} + +void main() async { + test('cv.CascadeClassifierAsync', () async { + final img = await cv.imreadAsync("test/images/face.jpg", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final classifier = await cv.CascadeClassifierAsync.emptyNewAsync(); + await classifier.loadAsync("test/data/haarcascade_frontalface_default.xml"); + final rects = await classifier.detectMultiScaleAsync(img); + expect(rects.length, 1); + + classifier.dispose(); + + final cls = + await cv.CascadeClassifierAsync.fromFileAsync("test/data/haarcascade_frontalface_default.xml"); + expect(cls.empty(), false); + + { + final (objects, nums) = await cls.detectMultiScale2Async(img); + expect(objects.length, 1); + expect(nums.length, 1); + } + + { + final (objects, nums, weights) = await cls.detectMultiScale3Async(img, outputRejectLevels: true); + expect(objects.length, 1); + expect(nums.length, 1); + expect(weights.length, 1); + } + + expect(await cls.getFeatureTypeAsync(), 0); + expect(await cls.getOriginalWindowSizeAsync(), (24, 24)); + expect(await cls.isOldFormatCascadeAsync(), false); + }); + + test('cv.HOGDescriptorAsync', () async { + final img = await cv.imreadAsync("test/images/face.jpg", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + { + final hog = await cv.HOGDescriptorAsync.emptyNewAsync(); + await hog.setSVMDetectorAsync(await cv.HOGDescriptorAsync.getDefaultPeopleDetectorAsync()); + final rects = await hog.detectMultiScaleAsync(img); + expect(rects.length, 1); + hog.dispose(); + } + { + final hog = await cv.HOGDescriptorAsync.emptyNewAsync(); + expect(await hog.getDescriptorSizeAsync(), 3780); + expect(await hog.getWinSigmaAsync(), closeTo(4.0, 1e-6)); + final d = await cv.HOGDescriptorAsync.getDaimlerPeopleDetectorAsync(); + expect(d.length, 1981); + final success = await hog.loadAsync("test/data/hog.xml"); + expect(success, true); + // hog.setSVMDetector(d); + final rects = await hog.detectMultiScaleAsync(img); + expect(rects.length, greaterThanOrEqualTo(0)); + } + + final hog1 = await cv.HOGDescriptorAsync.fromFileAsync("test/data/hog.xml"); + final (descriptors, locations) = await hog1.computeAsync(img); + expect(descriptors.length, greaterThanOrEqualTo(0)); + expect(locations.length, greaterThanOrEqualTo(0)); + + final grad = cv.Mat.empty(); + final angle = cv.Mat.empty(); + await hog1.computeGradientAsync(img, grad, angle); + expect(grad.isEmpty, false); + expect(angle.isEmpty, false); + + { + final (locs, slocs) = await hog1.detectAsync(img); + expect(locs.length, greaterThanOrEqualTo(0)); + expect(slocs.length, greaterThanOrEqualTo(0)); + } + + { + final (locs, weights, slocs) = await hog1.detect2Async(img); + expect(locs.length, greaterThanOrEqualTo(0)); + expect(weights.length, greaterThanOrEqualTo(0)); + expect(slocs.length, greaterThanOrEqualTo(0)); + } + + { + final rects = await hog1.detectMultiScaleAsync(img); + expect(rects.length, greaterThanOrEqualTo(0)); + } + }); + + test('cv.groupRectanglesAsync', () async { + final rects = [ + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 30, 30), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + cv.Rect(10, 10, 35, 35), + ]; + + final res = await cv.groupRectanglesAsync(rects.cvd, 1, 0.2); + expect(res.length, 1); + expect(res.first, cv.Rect(10, 10, 32, 32)); + + { + final hog = await cv.HOGDescriptorAsync.emptyNewAsync(); + final w = List.generate(rects.length, (index) => 0.1); + final (res, weights) = await hog.groupRectanglesAsync(rects.cvd, w.f64, 1, 0.1); + expect(res.length, greaterThan(0)); + expect(weights.length, greaterThan(0)); + } + }); + + test('cv.QRCodeDetectorAsync', () async { + final img = await cv.imreadAsync("test/images/qrcode.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final detector = await cv.QRCodeDetectorAsync.emptyNewAsync(); + final (res, bbox) = await detector.detectAsync(img); + expect(res, true); + expect(bbox, isNotNull); + + { + final (success, pts) = await detector.detectAsync(img); + expect(success, true); + expect(pts.length, greaterThan(0)); + + final (rval, code) = await detector.decodeCurvedAsync(img, pts); + expect(rval, "Hello World!"); + expect(code.isEmpty, false); + } + + { + final (rval, pts, code) = await detector.detectAndDecodeCurvedAsync(img); + expect(rval, "Hello World!"); + expect(pts.length, greaterThan(0)); + expect(code.isEmpty, false); + } + + final (res2, bbox2, codes2) = await detector.decodeAsync(img); + final (res2_1, bbox2_1, codes2_1) = await detector.decodeAsync(img); + expect(res2_1, equals(res2)); + expect(bbox2_1, bbox2); + expect(codes2?.shape, codes2_1?.shape); + final (res3, bbox3, codes3) = await detector.detectAndDecodeAsync(img); + final (res3_1, bbox3_1, codes3_1) = await detector.detectAndDecodeAsync(img); + expect(bbox3_1, bbox3); + expect(codes3.shape, codes3_1.shape); + expect(res2, equals(res3)); + expect(res3_1, equals(res3)); + + final img2 = await cv.imreadAsync("test/images/multi_qrcodes.png", flags: cv.IMREAD_COLOR); + expect(img2.isEmpty, false); + + final (res4, multiBox) = await detector.detectMultiAsync(img2); + expect(res4, true); + expect(multiBox, isNotNull); + expect(multiBox.length, greaterThan(0)); + + final (success, strs, pts, mats) = await detector.detectAndDecodeMultiAsync(img); + expect(success, true); + expect(strs, ["Hello World!"]); + expect(pts.length, greaterThan(0)); + expect(mats.length, greaterThan(0)); + + await detector.setEpsXAsync(0.1); + await detector.setEpsYAsync(0.1); + await detector.setUseAlignmentMarkersAsync(false); + + detector.dispose(); + }); + + // https://docs.opencv.org/4.x/d0/dd4/tutorial_dnn_face.html + test('cv.FaceDetectorYNAsync', tags: ["no-local-files"], () async { + { + // Test loading from file + const modelPath = "test/models/face_detection_yunet_2023mar.onnx"; + final detector = await cv.FaceDetectorYNAsync.fromFileAsync(modelPath, "", (320, 320)); + + // Test loading image and setting input size + final img = await cv.imreadAsync("test/images/lenna.png"); + expect(img.isEmpty, false); + await detector.setInputSizeAsync((img.width, img.height)); + + // Test detection + final face = await detector.detectAsync(img); + expect(face.rows, greaterThanOrEqualTo(1)); + visualizeFaceDetect(img, face); + + // Test setting parameters + await detector.setScoreThresholdAsync(0.8); + await detector.setNMSThresholdAsync(0.4); + await detector.setTopKAsync(3000); + + // Test getters and compare values + expect(await detector.getScoreThresholdAsync(), closeTo(0.8, 1e-6)); + expect(await detector.getNmsThresholdAsync(), closeTo(0.4, 1e-6)); + expect(await detector.getTopKAsync(), equals(3000)); + expect(await detector.getInputSizeAsync(), equals((img.width, img.height))); + + // Dispose the detector + detector.dispose(); + } + + { + // Test loading from buffer + const modelPath = "test/models/face_detection_yunet_2023mar.onnx"; + final buf = await File(modelPath).readAsBytes(); + final detector = await cv.FaceDetectorYNAsync.fromBufferAsync("onnx", buf, Uint8List(0), (320, 320)); + + // Test loading image and setting input size + final img = await cv.imreadAsync("test/images/lenna.png"); + expect(img.isEmpty, false); + await detector.setInputSizeAsync((img.width, img.height)); + + // Test detection + final face = await detector.detectAsync(img); + expect(face.rows, greaterThanOrEqualTo(1)); + visualizeFaceDetect(img, face); + // cv.imwrite("AAA.png", img); + + // Dispose the detector + detector.dispose(); + } + }); + + // Test for cv.FaceRecognizerSF + test('cv.FaceRecognizerSFAsync', tags: ["no-local-files"], () async { + const modelPath = "test/models/face_recognition_sface_2021dec.onnx"; + final recognizer = await cv.FaceRecognizerSFAsync.fromFileAsync(modelPath, ""); + + // Test loading image + final img = await cv.imreadAsync("test/images/face.jpg"); + expect(img.isEmpty, false); + + // Assume face detection already done and we have faceBox (a Mat object) + final faceBox = cv.Mat.zeros(1, 4, MatType.CV_32SC1); + faceBox.set(0, 0, 50); // x + faceBox.set(0, 1, 50); // y + faceBox.set(0, 2, 100); // width + faceBox.set(0, 3, 100); // height + + // Test alignCrop + final alignedFace = await recognizer.alignCropAsync(img, faceBox); + expect(alignedFace.isEmpty, false); + + // Test feature extraction + final faceFeature = await recognizer.featureAsync(alignedFace); + expect(faceFeature.isEmpty, false); + + // Test loading another image for matching + final img2 = await cv.imreadAsync("test/images/lenna.png"); + expect(img2.isEmpty, false); + + // Test alignCrop and feature extraction for the second image + final alignedFace2 = await recognizer.alignCropAsync(img2, faceBox); + final faceFeature2 = await recognizer.featureAsync(alignedFace2); + + // Test matching features using L2 distance + final matchScoreL2 = + await recognizer.matchAsync(faceFeature, faceFeature2, disType: cv.FaceRecognizerSF.FR_NORM_L2); + expect(matchScoreL2, greaterThanOrEqualTo(0)); + + // Test matching features using Cosine distance + final matchScoreCosine = + await recognizer.matchAsync(faceFeature, faceFeature2, disType: cv.FaceRecognizerSF.FR_COSINE); + expect(matchScoreCosine, greaterThanOrEqualTo(0)); + + // Clean up + recognizer.dispose(); + alignedFace.dispose(); + faceFeature.dispose(); + alignedFace2.dispose(); + faceFeature2.dispose(); + }); +} diff --git a/test/objdetect_test.dart b/test/objdetect/objdetect_test.dart similarity index 100% rename from test/objdetect_test.dart rename to test/objdetect/objdetect_test.dart