diff --git a/ffigen.yaml b/ffigen.yaml index 7a73d77e..68aa1355 100644 --- a/ffigen.yaml +++ b/ffigen.yaml @@ -30,6 +30,7 @@ headers: - src/extra/img_hash.h - src/extra/wechat_qrcode.h - src/features2d/features2d.h + - src/features2d/features2d_async.h - src/gapi/gapi.h - src/highgui/highgui.h - src/imgcodecs/imgcodecs.h @@ -60,6 +61,7 @@ headers: - src/extra/img_hash.h - src/extra/wechat_qrcode.h - src/features2d/features2d.h + - src/features2d/features2d_async.h - src/gapi/gapi.h - src/highgui/highgui.h - src/imgcodecs/imgcodecs.h diff --git a/lib/opencv_dart.dart b/lib/opencv_dart.dart index 0d5ce8bd..db33fc6f 100644 --- a/lib/opencv_dart.dart +++ b/lib/opencv_dart.dart @@ -30,6 +30,7 @@ export 'src/core/vec.dart'; export 'src/dnn/dnn.dart'; export 'src/dnn/dnn_async.dart'; export 'src/features2d/features2d.dart'; +export 'src/features2d/features2d_async.dart'; export 'src/highgui/highgui.dart'; export 'src/imgcodecs/imgcodecs.dart'; export 'src/imgcodecs/imgcodecs_async.dart'; diff --git a/lib/src/features2d/features2d.dart b/lib/src/features2d/features2d.dart index e0262c16..bb16c71e 100644 --- a/lib/src/features2d/features2d.dart +++ b/lib/src/features2d/features2d.dart @@ -22,6 +22,7 @@ class AKAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory AKAZE.fromPointer(cvg.AKAZEPtr ptr, [bool attach = true]) => AKAZE._(ptr, attach); /// returns a new AKAZE algorithm /// @@ -50,7 +51,9 @@ class AKAZE extends CvStruct { (VecKeyPoint ret, Mat desc) detectAndCompute(Mat src, Mat mask) { final desc = Mat.empty(); final ret = calloc(); - cvRun(() => CFFI.AKAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + cvRun( + () => CFFI.AKAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret), + ); return (VecKeyPoint.fromPointer(ret), desc); } @@ -75,6 +78,8 @@ class AgastFeatureDetector extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory AgastFeatureDetector.fromPointer(cvg.AgastFeatureDetectorPtr ptr, [bool attach = true]) => + AgastFeatureDetector._(ptr, attach); /// returns a new AgastFeatureDetector algorithm /// @@ -96,8 +101,9 @@ class AgastFeatureDetector extends CvStruct { return VecKeyPoint.fromPointer(ret); } - static final finalizer = - OcvFinalizer(CFFI.addresses.AgastFeatureDetector_Close); + static final finalizer = OcvFinalizer( + CFFI.addresses.AgastFeatureDetector_Close, + ); void dispose() { finalizer.detach(this); @@ -118,6 +124,7 @@ class BRISK extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory BRISK.fromPointer(cvg.BRISKPtr ptr, [bool attach = true]) => BRISK._(ptr, attach); /// returns a new BRISK algorithm /// @@ -146,7 +153,9 @@ class BRISK extends CvStruct { (VecKeyPoint, Mat) detectAndCompute(Mat src, Mat mask) { final desc = Mat.empty(); final ret = calloc(); - cvRun(() => CFFI.BRISK_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + cvRun( + () => CFFI.BRISK_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret), + ); return (VecKeyPoint.fromPointer(ret), desc); } @@ -185,6 +194,8 @@ class FastFeatureDetector extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory FastFeatureDetector.fromPointer(cvg.FastFeatureDetectorPtr ptr, [bool attach = true]) => + FastFeatureDetector._(ptr, attach); /// returns a new FastFeatureDetector algorithm /// @@ -227,7 +238,9 @@ class FastFeatureDetector extends CvStruct { return VecKeyPoint.fromPointer(ret); } - static final finalizer = OcvFinalizer(CFFI.addresses.FastFeatureDetector_Close); + static final finalizer = OcvFinalizer( + CFFI.addresses.FastFeatureDetector_Close, + ); void dispose() { finalizer.detach(this); @@ -248,6 +261,8 @@ class GFTTDetector extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory GFTTDetector.fromPointer(cvg.GFTTDetectorPtr ptr, [bool attach = true]) => + GFTTDetector._(ptr, attach); /// returns a new GFTTDetector algorithm /// @@ -290,6 +305,7 @@ class KAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory KAZE.fromPointer(cvg.KAZEPtr ptr, [bool attach = true]) => KAZE._(ptr, attach); /// returns a new KAZE algorithm /// @@ -318,7 +334,9 @@ class KAZE extends CvStruct { (VecKeyPoint, Mat) detectAndCompute(Mat src, Mat mask) { final desc = Mat.empty(); final ret = calloc(); - cvRun(() => CFFI.KAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + cvRun( + () => CFFI.KAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret), + ); return (VecKeyPoint.fromPointer(ret), desc); } @@ -343,6 +361,7 @@ class MSER extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory MSER.fromPointer(cvg.MSERPtr ptr, [bool attach = true]) => MSER._(ptr, attach); /// returns a new MSER algorithm /// @@ -393,6 +412,7 @@ class ORB extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory ORB.fromPointer(cvg.ORBPtr ptr, [bool attach = true]) => ORB._(ptr, attach); /// returns a new ORB algorithm /// @@ -454,7 +474,9 @@ class ORB extends CvStruct { (VecKeyPoint, Mat) detectAndCompute(Mat src, Mat mask) { final desc = Mat.empty(); final ret = calloc(); - cvRun(() => CFFI.ORB_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + cvRun( + () => CFFI.ORB_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret), + ); return (VecKeyPoint.fromPointer(ret), desc); } @@ -473,8 +495,10 @@ class ORB extends CvStruct { } class SimpleBlobDetectorParams extends CvStruct { - SimpleBlobDetectorParams._(ffi.Pointer ptr, [bool attach = true]) - : super.fromPointer(ptr) { + SimpleBlobDetectorParams._( + ffi.Pointer ptr, [ + bool attach = true, + ]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } @@ -510,7 +534,9 @@ class SimpleBlobDetectorParams extends CvStruct { final p = calloc(); if (blobColor != null) p.ref.blobColor = blobColor; if (filterByArea != null) p.ref.filterByArea = filterByArea; - if (filterByCircularity != null) p.ref.filterByCircularity = filterByCircularity; + if (filterByCircularity != null) { + p.ref.filterByCircularity = filterByCircularity; + } if (filterByColor != null) p.ref.filterByColor = filterByColor; if (filterByConvexity != null) p.ref.filterByConvexity = filterByConvexity; if (filterByInertia != null) p.ref.filterByInertia = filterByInertia; @@ -522,7 +548,9 @@ class SimpleBlobDetectorParams extends CvStruct { if (minArea != null) p.ref.minArea = minArea; if (minCircularity != null) p.ref.minCircularity = minCircularity; if (minConvexity != null) p.ref.minConvexity = minConvexity; - if (minDistBetweenBlobs != null) p.ref.minDistBetweenBlobs = minDistBetweenBlobs; + if (minDistBetweenBlobs != null) { + p.ref.minDistBetweenBlobs = minDistBetweenBlobs; + } if (minInertiaRatio != null) p.ref.minInertiaRatio = minInertiaRatio; if (minRepeatability != null) p.ref.minRepeatability = minRepeatability; if (minThreshold != null) p.ref.minThreshold = minThreshold; @@ -691,6 +719,9 @@ class SimpleBlobDetector extends CvStruct { } } + factory SimpleBlobDetector.fromPointer(cvg.SimpleBlobDetectorPtr ptr, [bool attach = true]) => + SimpleBlobDetector._(ptr, attach); + /// returns a new SimpleBlobDetector algorithm /// /// For further details, please see: @@ -717,7 +748,9 @@ class SimpleBlobDetector extends CvStruct { return VecKeyPoint.fromPointer(ret); } - static final finalizer = OcvFinalizer(CFFI.addresses.SimpleBlobDetector_Close); + static final finalizer = OcvFinalizer( + CFFI.addresses.SimpleBlobDetector_Close, + ); void dispose() { finalizer.detach(this); @@ -738,6 +771,7 @@ class BFMatcher extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory BFMatcher.fromPointer(cvg.BFMatcherPtr ptr, [bool attach = true]) => BFMatcher._(ptr, attach); /// returns a new BFMatcher algorithm /// @@ -796,6 +830,8 @@ class FlannBasedMatcher extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory FlannBasedMatcher.fromPointer(cvg.FlannBasedMatcherPtr ptr, [bool attach = true]) => + FlannBasedMatcher._(ptr, attach); /// returns a new FlannBasedMatcher algorithm /// @@ -813,11 +849,15 @@ class FlannBasedMatcher extends CvStruct { /// https://docs.opencv.org/master/db/d39/classcv_1_1DescriptorMatcher.html#aa880f9353cdf185ccf3013e08210483a VecVecDMatch knnMatch(Mat query, Mat train, int k) { final ret = calloc(); - cvRun(() => CFFI.FlannBasedMatcher_KnnMatch(ptr.ref, query.ref, train.ref, k, ret)); + cvRun( + () => CFFI.FlannBasedMatcher_KnnMatch(ptr.ref, query.ref, train.ref, k, ret), + ); return VecVecDMatch.fromPointer(ret); } - static final finalizer = OcvFinalizer(CFFI.addresses.FlannBasedMatcher_Close); + static final finalizer = OcvFinalizer( + CFFI.addresses.FlannBasedMatcher_Close, + ); void dispose() { finalizer.detach(this); @@ -848,8 +888,22 @@ enum DrawMatchesFlag { final int value; } -void drawKeyPoints(Mat src, VecKeyPoint keypoints, Mat dst, Scalar color, DrawMatchesFlag flag) { - cvRun(() => CFFI.DrawKeyPoints(src.ref, keypoints.ref, dst.ref, color.ref, flag.value)); +void drawKeyPoints( + Mat src, + VecKeyPoint keypoints, + Mat dst, + Scalar color, + DrawMatchesFlag flag, +) { + cvRun( + () => CFFI.DrawKeyPoints( + src.ref, + keypoints.ref, + dst.ref, + color.ref, + flag.value, + ), + ); } /// SIFT is a wrapper around the cv::SIFT. @@ -859,6 +913,7 @@ class SIFT extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory SIFT.fromPointer(cvg.SIFTPtr ptr, [bool attach = true]) => SIFT._(ptr, attach); /// returns a new SIFT algorithm /// @@ -887,7 +942,9 @@ class SIFT extends CvStruct { (VecKeyPoint, Mat) detectAndCompute(Mat src, Mat mask) { final desc = Mat.empty(); final ret = calloc(); - cvRun(() => CFFI.SIFT_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + cvRun( + () => CFFI.SIFT_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret), + ); return (VecKeyPoint.fromPointer(ret), desc); } @@ -905,10 +962,10 @@ class SIFT extends CvStruct { cvg.SIFT get ref => ptr.ref; } -// DrawMatches draws matches on combined train and querry images. -// -// For further details, please see: -// https://docs.opencv.org/master/d4/d5d/group__features2d__draw.html#gad8f463ccaf0dc6f61083abd8717c261a +/// DrawMatches draws matches on combined train and querry images. +/// +/// For further details, please see: +/// https://docs.opencv.org/master/d4/d5d/group__features2d__draw.html#gad8f463ccaf0dc6f61083abd8717c261a void drawMatches( InputArray img1, VecKeyPoint keypoints1, diff --git a/lib/src/features2d/features2d_async.dart b/lib/src/features2d/features2d_async.dart new file mode 100644 index 00000000..11c39690 --- /dev/null +++ b/lib/src/features2d/features2d_async.dart @@ -0,0 +1,538 @@ +// ignore_for_file: non_constant_identifier_names + +library cv; + +import '../constants.g.dart'; +import '../core/base.dart'; +import '../core/dmatch.dart'; +import '../core/keypoint.dart'; +import '../core/mat.dart'; +import '../core/scalar.dart'; +import '../core/vec.dart'; +import '../opencv.g.dart' as cvg; +import './features2d.dart'; + +extension AKAZEAsync on AKAZE { + /// returns a new AKAZE algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d8/d30/classcv_1_1AKAZE.html + static Future emptyAsync() async => cvRunAsync( + CFFI.AKAZE_Create_Async, + (c, p) => c.complete(AKAZE.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using AKAZE. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.AKAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } + + /// DetectAndCompute keypoints and compute in an image using AKAZE. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#a8be0d1c20b08eb867184b8d74c15a677 + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async => + cvRunAsync2<(VecKeyPoint, Mat)>( + (callback) => CFFI.AKAZE_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + callback, + ), + (c, keypoints, desc) => c.complete( + ( + VecKeyPoint.fromPointer(keypoints.cast()), + Mat.fromPointer(desc.cast()), + ), + ), + ); +} + +extension AgastFeatureDetectorAsync on AgastFeatureDetector { + /// returns a new AgastFeatureDetector algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d7/d19/classcv_1_1AgastFeatureDetector.html + static Future emptyAsync() async => cvRunAsync( + CFFI.AgastFeatureDetector_Create_Async, + (c, p) => c.complete(AgastFeatureDetector.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using AgastFeatureDetector. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.AgastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } +} + +extension BRISKAsync on BRISK { + /// returns a new BRISK algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d8/d30/classcv_1_1AKAZE.html + static Future emptyAsync() async => cvRunAsync( + CFFI.BRISK_Create_Async, + (c, p) => c.complete(BRISK.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using BRISK. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.BRISK_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } + + /// DetectAndCompute keypoints and compute in an image using BRISK. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#a8be0d1c20b08eb867184b8d74c15a677 + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async => + cvRunAsync2<(VecKeyPoint, Mat)>( + (callback) => CFFI.BRISK_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + callback, + ), + (c, keypoints, desc) => c.complete( + ( + VecKeyPoint.fromPointer(keypoints.cast()), + Mat.fromPointer(desc.cast()), + ), + ), + ); +} + +extension FastFeatureDetectorAsync on FastFeatureDetector { + /// returns a new FastFeatureDetector algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/df/d74/classcv_1_1FastFeatureDetector.html + static Future emptyAsync() async => cvRunAsync( + CFFI.FastFeatureDetector_Create_Async, + (c, p) => c.complete(FastFeatureDetector.fromPointer(p.cast())), + ); + + /// returns a new FastFeatureDetector algorithm with parameters + /// + /// For further details, please see: + /// https://docs.opencv.org/master/df/d74/classcv_1_1FastFeatureDetector.html#ab986f2ff8f8778aab1707e2642bc7f8e + static Future createAsync({ + int threshold = 10, + bool nonmaxSuppression = true, + FastFeatureDetectorType type = FastFeatureDetectorType.TYPE_9_16, + }) async => + cvRunAsync( + (callback) => CFFI.FastFeatureDetector_CreateWithParams_Async( + threshold, + nonmaxSuppression, + type.value, + callback, + ), + (c, p) => c.complete(FastFeatureDetector.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using FastFeatureDetector. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.FastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } +} + +extension GFTTDetectorAsync on GFTTDetector { + /// returns a new GFTTDetector algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/df/d21/classcv_1_1GFTTDetector.html + static Future emptyAsync() async => cvRunAsync( + CFFI.GFTTDetector_Create_Async, + (c, p) => c.complete(GFTTDetector.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using GFTTDetector. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.GFTTDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } +} + +extension KAZEAsync on KAZE { + /// returns a new KAZE algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d3/d61/classcv_1_1KAZE.html + static Future emptyAsync() async => cvRunAsync( + CFFI.KAZE_Create_Async, + (c, p) => c.complete(KAZE.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using KAZE. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.KAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } + + /// DetectAndCompute keypoints and compute in an image using KAZE. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#a8be0d1c20b08eb867184b8d74c15a677 + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async => + cvRunAsync2<(VecKeyPoint, Mat)>( + (callback) => CFFI.KAZE_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + callback, + ), + (c, keypoints, desc) => c.complete( + ( + VecKeyPoint.fromPointer(keypoints.cast()), + Mat.fromPointer(desc.cast()), + ), + ), + ); +} + +extension MSERAsync on MSER { + /// returns a new MSER algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d3/d61/classcv_1_1KAZE.html + static Future emptyAsync() async => cvRunAsync( + CFFI.MSER_Create_Async, + (c, p) => c.complete(MSER.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using MSER. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.MSER_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } +} + +extension ORBAsync on ORB { + /// returns a new ORB algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d3/d61/classcv_1_1KAZE.html + static Future emptyAsync() async => + cvRunAsync(CFFI.ORB_Create_Async, (c, p) => c.complete(ORB.fromPointer(p.cast()))); + + /// NewORBWithParams returns a new ORB algorithm with parameters + /// + /// For further details, please see: + /// https://docs.opencv.org/master/db/d95/classcv_1_1ORB.html#aeff0cbe668659b7ca14bb85ff1c4073b + static Future createAsync({ + int nFeatures = 500, + double scaleFactor = 1.2, + int nLevels = 8, + int edgeThreshold = 31, + int firstLevel = 0, + int WTA_K = 2, + ORBScoreType scoreType = ORBScoreType.HARRIS_SCORE, + int patchSize = 31, + int fastThreshold = 20, + }) async => + cvRunAsync( + (callback) => CFFI.ORB_CreateWithParams_Async( + nFeatures, + scaleFactor, + nLevels, + edgeThreshold, + firstLevel, + WTA_K, + scoreType.value, + patchSize, + fastThreshold, + callback, + ), + (c, p) => c.complete(ORB.fromPointer(p.cast())), + ); + + /// Detect keypoints in an image using ORB. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.ORB_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } + + /// DetectAndCompute keypoints and compute in an image using ORB. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#a8be0d1c20b08eb867184b8d74c15a677 + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async => + cvRunAsync2<(VecKeyPoint, Mat)>( + (callback) => CFFI.ORB_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + callback, + ), + (c, keypoints, desc) => c.complete( + ( + VecKeyPoint.fromPointer(keypoints.cast()), + Mat.fromPointer(desc.cast()), + ), + ), + ); +} + +extension SimpleBlobDetectorAsync on SimpleBlobDetector { + /// returns a new SimpleBlobDetector algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d3/d61/classcv_1_1KAZE.html + static Future emptyAsync() async => cvRunAsync( + CFFI.SimpleBlobDetector_Create_Async, + (c, p) => c.complete(SimpleBlobDetector.fromPointer(p.cast())), + ); + + static Future createAsync( + SimpleBlobDetectorParams params, + ) async => + cvRunAsync( + (callback) => CFFI.SimpleBlobDetector_Create_WithParams_Async( + params.ref, + callback, + ), + (c, p) => c.complete( + SimpleBlobDetector.fromPointer(p.cast()), + ), + ); + + /// Detect keypoints in an image using SimpleBlobDetector. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.SimpleBlobDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } +} + +extension BFMatcherAsync on BFMatcher { + /// returns a new BFMatcher algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d3/d61/classcv_1_1KAZE.html + static Future emptyAsync() async => cvRunAsync( + CFFI.BFMatcher_Create_Async, + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); + + static Future createAsync({ + int type = NORM_L2, + bool crossCheck = false, + }) async => + cvRunAsync( + (callback) => CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); + + /// Match Finds the best match for each descriptor from a query set. + /// + /// For further details, please see: + /// https://docs.opencv.org/4.x/db/d39/classcv_1_1DescriptorMatcher.html#a0f046f47b68ec7074391e1e85c750cba + Future matchAsync(Mat query, Mat train) async { + final rval = cvRunAsync( + (callback) => CFFI.BFMatcher_Match_Async(ref, query.ref, train.ref, callback), + (c, ret) => c.complete(VecDMatch.fromPointer(ret.cast())), + ); + return rval; + } + + /// KnnMatch Finds the k best matches for each descriptor from a query set. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/db/d39/classcv_1_1DescriptorMatcher.html#aa880f9353cdf185ccf3013e08210483a + Future knnMatchAsync(Mat query, Mat train, int k) async { + final rval = cvRunAsync( + (callback) => CFFI.BFMatcher_KnnMatch_Async( + ref, + query.ref, + train.ref, + k, + callback, + ), + (c, ret) => c.complete(VecVecDMatch.fromPointer(ret.cast())), + ); + return rval; + } +} + +extension FlannBasedMatcherAsync on FlannBasedMatcher { + /// returns a new FlannBasedMatcher algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d3/d61/classcv_1_1KAZE.html + static Future emptyAsync() async => cvRunAsync( + CFFI.FlannBasedMatcher_Create_Async, + (c, p) => c.complete(FlannBasedMatcher.fromPointer(p.cast())), + ); + + /// KnnMatch Finds the k best matches for each descriptor from a query set. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/db/d39/classcv_1_1DescriptorMatcher.html#aa880f9353cdf185ccf3013e08210483a + Future knnMatchAsync(Mat query, Mat train, int k) async { + final rval = cvRunAsync( + (callback) => CFFI.FlannBasedMatcher_KnnMatch_Async( + ref, + query.ref, + train.ref, + k, + callback, + ), + (c, ret) => c.complete(VecVecDMatch.fromPointer(ret.cast())), + ); + return rval; + } +} + +extension SIFTAsync on SIFT { + /// returns a new SIFT algorithm + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d5/d3c/classcv_1_1xfeatures2d_1_1SIFT.html + static Future emptyAsync() async => + cvRunAsync(CFFI.SIFT_Create_Async, (c, p) => c.complete(SIFT.fromPointer(p.cast()))); + + /// Detect keypoints in an image using SIFT. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#aa4e9a7082ec61ebc108806704fbd7887 + Future detectAsync(Mat src) async { + final rval = cvRunAsync( + (callback) => CFFI.SIFT_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); + return rval; + } + + /// DetectAndCompute keypoints and compute in an image using SIFT. + /// + /// For further details, please see: + /// https://docs.opencv.org/master/d0/d13/classcv_1_1Feature2D.html#a8be0d1c20b08eb867184b8d74c15a677 + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async => + cvRunAsync2<(VecKeyPoint, Mat)>( + (callback) => CFFI.SIFT_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + callback, + ), + (c, keypoints, desc) => c.complete( + ( + VecKeyPoint.fromPointer(keypoints.cast()), + Mat.fromPointer(desc.cast()), + ), + ), + ); +} + +Future drawKeyPointsAsync( + Mat src, + VecKeyPoint keypoints, + Mat dst, + Scalar color, + DrawMatchesFlag flag, +) async { + await cvRunAsync0( + (callback) => CFFI.DrawKeyPoints_Async( + src.ref, + keypoints.ref, + dst.ref, + color.ref, + flag.value, + callback, + ), + (c) => c.complete(), + ); +} + +/// DrawMatches draws matches on combined train and querry images. +/// +/// For further details, please see: +/// https://docs.opencv.org/master/d4/d5d/group__features2d__draw.html#gad8f463ccaf0dc6f61083abd8717c261a +Future drawMatchesAsync( + InputArray img1, + VecKeyPoint keypoints1, + InputArray img2, + VecKeyPoint keypoints2, + VecDMatch matches1to2, + InputOutputArray outImg, { + Scalar? matchColor, + Scalar? singlePointColor, + VecChar? matchesMask, + DrawMatchesFlag flags = DrawMatchesFlag.DEFAULT, +}) async { + matchColor ??= Scalar.all(-1); + singlePointColor ??= Scalar.all(-1); + matchesMask ??= VecChar(); + await cvRunAsync0( + (callback) => CFFI.DrawMatches_Async( + img1.ref, + keypoints1.ref, + img2.ref, + keypoints2.ref, + matches1to2.ref, + outImg.ref, + matchColor!.ref, + singlePointColor!.ref, + matchesMask!.ref, + flags.value, + callback, + ), + (c) => c.complete(), + ); +} diff --git a/lib/src/opencv.g.dart b/lib/src/opencv.g.dart index 3263a010..9b5f2d87 100644 --- a/lib/src/opencv.g.dart +++ b/lib/src/opencv.g.dart @@ -41,6 +41,23 @@ class CvNative { late final _AKAZE_Close = _AKAZE_ClosePtr.asFunction(); + ffi.Pointer AKAZE_Close_Async( + AKAZEPtr self, + CvCallback_0 callback, + ) { + return _AKAZE_Close_Async( + self, + callback, + ); + } + + late final _AKAZE_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + AKAZEPtr, CvCallback_0)>>('AKAZE_Close_Async'); + late final _AKAZE_Close_Async = _AKAZE_Close_AsyncPtr.asFunction< + ffi.Pointer Function(AKAZEPtr, CvCallback_0)>(); + ffi.Pointer AKAZE_Create( ffi.Pointer rval, ) { @@ -55,6 +72,20 @@ class CvNative { late final _AKAZE_Create = _AKAZE_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer AKAZE_Create_Async( + CvCallback_1 callback, + ) { + return _AKAZE_Create_Async( + callback, + ); + } + + late final _AKAZE_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'AKAZE_Create_Async'); + late final _AKAZE_Create_Async = _AKAZE_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer AKAZE_Detect( AKAZE a, Mat src, @@ -98,6 +129,47 @@ class CvNative { ffi.Pointer Function( AKAZE, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer AKAZE_DetectAndCompute_Async( + AKAZE self, + Mat src, + Mat mask, + CvCallback_2 callback, + ) { + return _AKAZE_DetectAndCompute_Async( + self, + src, + mask, + callback, + ); + } + + late final _AKAZE_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + AKAZE, Mat, Mat, CvCallback_2)>>('AKAZE_DetectAndCompute_Async'); + late final _AKAZE_DetectAndCompute_Async = + _AKAZE_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(AKAZE, Mat, Mat, CvCallback_2)>(); + + ffi.Pointer AKAZE_Detect_Async( + AKAZE self, + Mat src, + CvCallback_1 callback, + ) { + return _AKAZE_Detect_Async( + self, + src, + callback, + ); + } + + late final _AKAZE_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + AKAZE, Mat, CvCallback_1)>>('AKAZE_Detect_Async'); + late final _AKAZE_Detect_Async = _AKAZE_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(AKAZE, Mat, CvCallback_1)>(); + ffi.Pointer AdaptiveThreshold( Mat src, Mat dst, @@ -168,6 +240,25 @@ class CvNative { late final _AgastFeatureDetector_Close = _AgastFeatureDetector_ClosePtr .asFunction(); + ffi.Pointer AgastFeatureDetector_Close_Async( + AgastFeatureDetectorPtr self, + CvCallback_0 callback, + ) { + return _AgastFeatureDetector_Close_Async( + self, + callback, + ); + } + + late final _AgastFeatureDetector_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(AgastFeatureDetectorPtr, + CvCallback_0)>>('AgastFeatureDetector_Close_Async'); + late final _AgastFeatureDetector_Close_Async = + _AgastFeatureDetector_Close_AsyncPtr.asFunction< + ffi.Pointer Function( + AgastFeatureDetectorPtr, CvCallback_0)>(); + ffi.Pointer AgastFeatureDetector_Create( ffi.Pointer rval, ) { @@ -185,6 +276,21 @@ class CvNative { _AgastFeatureDetector_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer AgastFeatureDetector_Create_Async( + CvCallback_1 callback, + ) { + return _AgastFeatureDetector_Create_Async( + callback, + ); + } + + late final _AgastFeatureDetector_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'AgastFeatureDetector_Create_Async'); + late final _AgastFeatureDetector_Create_Async = + _AgastFeatureDetector_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer AgastFeatureDetector_Detect( AgastFeatureDetector a, Mat src, @@ -206,6 +312,27 @@ class CvNative { ffi.Pointer Function( AgastFeatureDetector, Mat, ffi.Pointer)>(); + ffi.Pointer AgastFeatureDetector_Detect_Async( + AgastFeatureDetector self, + Mat src, + CvCallback_1 callback, + ) { + return _AgastFeatureDetector_Detect_Async( + self, + src, + callback, + ); + } + + late final _AgastFeatureDetector_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(AgastFeatureDetector, Mat, + CvCallback_1)>>('AgastFeatureDetector_Detect_Async'); + late final _AgastFeatureDetector_Detect_Async = + _AgastFeatureDetector_Detect_AsyncPtr.asFunction< + ffi.Pointer Function( + AgastFeatureDetector, Mat, CvCallback_1)>(); + void AlignMTB_Close( AlignMTBPtr b, ) { @@ -1927,6 +2054,23 @@ class CvNative { late final _BFMatcher_Close = _BFMatcher_ClosePtr.asFunction(); + ffi.Pointer BFMatcher_Close_Async( + BFMatcherPtr self, + CvCallback_0 callback, + ) { + return _BFMatcher_Close_Async( + self, + callback, + ); + } + + late final _BFMatcher_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + BFMatcherPtr, CvCallback_0)>>('BFMatcher_Close_Async'); + late final _BFMatcher_Close_Async = _BFMatcher_Close_AsyncPtr.asFunction< + ffi.Pointer Function(BFMatcherPtr, CvCallback_0)>(); + ffi.Pointer BFMatcher_Create( ffi.Pointer rval, ) { @@ -1962,6 +2106,40 @@ class CvNative { _BFMatcher_CreateWithParamsPtr.asFunction< ffi.Pointer Function(int, bool, ffi.Pointer)>(); + ffi.Pointer BFMatcher_CreateWithParams_Async( + int normType, + bool crossCheck, + CvCallback_1 callback, + ) { + return _BFMatcher_CreateWithParams_Async( + normType, + crossCheck, + callback, + ); + } + + late final _BFMatcher_CreateWithParams_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Int, ffi.Bool, + CvCallback_1)>>('BFMatcher_CreateWithParams_Async'); + late final _BFMatcher_CreateWithParams_Async = + _BFMatcher_CreateWithParams_AsyncPtr.asFunction< + ffi.Pointer Function(int, bool, CvCallback_1)>(); + + ffi.Pointer BFMatcher_Create_Async( + CvCallback_1 callback, + ) { + return _BFMatcher_Create_Async( + callback, + ); + } + + late final _BFMatcher_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'BFMatcher_Create_Async'); + late final _BFMatcher_Create_Async = _BFMatcher_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer BFMatcher_KnnMatch( BFMatcher b, Mat query, @@ -1986,6 +2164,31 @@ class CvNative { ffi.Pointer Function( BFMatcher, Mat, Mat, int, ffi.Pointer)>(); + ffi.Pointer BFMatcher_KnnMatch_Async( + BFMatcher self, + Mat query, + Mat train, + int k, + CvCallback_1 callback, + ) { + return _BFMatcher_KnnMatch_Async( + self, + query, + train, + k, + callback, + ); + } + + late final _BFMatcher_KnnMatch_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(BFMatcher, Mat, Mat, ffi.Int, + CvCallback_1)>>('BFMatcher_KnnMatch_Async'); + late final _BFMatcher_KnnMatch_Async = + _BFMatcher_KnnMatch_AsyncPtr.asFunction< + ffi.Pointer Function( + BFMatcher, Mat, Mat, int, CvCallback_1)>(); + ffi.Pointer BFMatcher_Match( BFMatcher b, Mat query, @@ -2008,6 +2211,27 @@ class CvNative { ffi.Pointer Function( BFMatcher, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer BFMatcher_Match_Async( + BFMatcher self, + Mat query, + Mat train, + CvCallback_1 callback, + ) { + return _BFMatcher_Match_Async( + self, + query, + train, + callback, + ); + } + + late final _BFMatcher_Match_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + BFMatcher, Mat, Mat, CvCallback_1)>>('BFMatcher_Match_Async'); + late final _BFMatcher_Match_Async = _BFMatcher_Match_AsyncPtr.asFunction< + ffi.Pointer Function(BFMatcher, Mat, Mat, CvCallback_1)>(); + void BRISK_Close( BRISKPtr b, ) { @@ -2021,6 +2245,23 @@ class CvNative { late final _BRISK_Close = _BRISK_ClosePtr.asFunction(); + ffi.Pointer BRISK_Close_Async( + BRISKPtr self, + CvCallback_0 callback, + ) { + return _BRISK_Close_Async( + self, + callback, + ); + } + + late final _BRISK_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + BRISKPtr, CvCallback_0)>>('BRISK_Close_Async'); + late final _BRISK_Close_Async = _BRISK_Close_AsyncPtr.asFunction< + ffi.Pointer Function(BRISKPtr, CvCallback_0)>(); + ffi.Pointer BRISK_Create( ffi.Pointer rval, ) { @@ -2035,6 +2276,20 @@ class CvNative { late final _BRISK_Create = _BRISK_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer BRISK_Create_Async( + CvCallback_1 callback, + ) { + return _BRISK_Create_Async( + callback, + ); + } + + late final _BRISK_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'BRISK_Create_Async'); + late final _BRISK_Create_Async = _BRISK_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer BRISK_Detect( BRISK b, Mat src, @@ -2078,6 +2333,47 @@ class CvNative { ffi.Pointer Function( BRISK, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer BRISK_DetectAndCompute_Async( + BRISK self, + Mat src, + Mat mask, + CvCallback_2 callback, + ) { + return _BRISK_DetectAndCompute_Async( + self, + src, + mask, + callback, + ); + } + + late final _BRISK_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + BRISK, Mat, Mat, CvCallback_2)>>('BRISK_DetectAndCompute_Async'); + late final _BRISK_DetectAndCompute_Async = + _BRISK_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(BRISK, Mat, Mat, CvCallback_2)>(); + + ffi.Pointer BRISK_Detect_Async( + BRISK self, + Mat src, + CvCallback_1 callback, + ) { + return _BRISK_Detect_Async( + self, + src, + callback, + ); + } + + late final _BRISK_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + BRISK, Mat, CvCallback_1)>>('BRISK_Detect_Async'); + late final _BRISK_Detect_Async = _BRISK_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(BRISK, Mat, CvCallback_1)>(); + ffi.Pointer BackgroundSubtractorKNN_Apply( BackgroundSubtractorKNN self, Mat src, @@ -4659,6 +4955,32 @@ class CvNative { late final _DrawKeyPoints = _DrawKeyPointsPtr.asFunction< ffi.Pointer Function(Mat, VecKeyPoint, Mat, Scalar, int)>(); + ffi.Pointer DrawKeyPoints_Async( + Mat src, + VecKeyPoint kp, + Mat dst, + Scalar color, + int flags, + CvCallback_0 callback, + ) { + return _DrawKeyPoints_Async( + src, + kp, + dst, + color, + flags, + callback, + ); + } + + late final _DrawKeyPoints_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Mat, VecKeyPoint, Mat, Scalar, ffi.Int, + CvCallback_0)>>('DrawKeyPoints_Async'); + late final _DrawKeyPoints_Async = _DrawKeyPoints_AsyncPtr.asFunction< + ffi.Pointer Function( + Mat, VecKeyPoint, Mat, Scalar, int, CvCallback_0)>(); + ffi.Pointer DrawMatches( Mat img1, VecKeyPoint kp1, @@ -4702,6 +5024,52 @@ class CvNative { ffi.Pointer Function(Mat, VecKeyPoint, Mat, VecKeyPoint, VecDMatch, Mat, Scalar, Scalar, VecChar, int)>(); + ffi.Pointer DrawMatches_Async( + Mat img1, + VecKeyPoint kp1, + Mat img2, + VecKeyPoint kp2, + VecDMatch matches1to2, + Mat outImg, + Scalar matchesColor, + Scalar pointColor, + VecChar matchesMask, + int flags, + CvCallback_0 callback, + ) { + return _DrawMatches_Async( + img1, + kp1, + img2, + kp2, + matches1to2, + outImg, + matchesColor, + pointColor, + matchesMask, + flags, + callback, + ); + } + + late final _DrawMatches_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Mat, + VecKeyPoint, + Mat, + VecKeyPoint, + VecDMatch, + Mat, + Scalar, + Scalar, + VecChar, + ffi.Int, + CvCallback_0)>>('DrawMatches_Async'); + late final _DrawMatches_Async = _DrawMatches_AsyncPtr.asFunction< + ffi.Pointer Function(Mat, VecKeyPoint, Mat, VecKeyPoint, + VecDMatch, Mat, Scalar, Scalar, VecChar, int, CvCallback_0)>(); + ffi.Pointer EdgePreservingFilter( Mat src, Mat dst, @@ -5947,6 +6315,25 @@ class CvNative { late final _FastFeatureDetector_Close = _FastFeatureDetector_ClosePtr .asFunction(); + ffi.Pointer FastFeatureDetector_Close_Async( + FastFeatureDetectorPtr self, + CvCallback_0 callback, + ) { + return _FastFeatureDetector_Close_Async( + self, + callback, + ); + } + + late final _FastFeatureDetector_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FastFeatureDetectorPtr, + CvCallback_0)>>('FastFeatureDetector_Close_Async'); + late final _FastFeatureDetector_Close_Async = + _FastFeatureDetector_Close_AsyncPtr.asFunction< + ffi.Pointer Function( + FastFeatureDetectorPtr, CvCallback_0)>(); + ffi.Pointer FastFeatureDetector_Create( ffi.Pointer rval, ) { @@ -5987,6 +6374,43 @@ class CvNative { ffi.Pointer Function( int, bool, int, ffi.Pointer)>(); + ffi.Pointer FastFeatureDetector_CreateWithParams_Async( + int threshold, + bool nonmaxSuppression, + int type, + CvCallback_1 callback, + ) { + return _FastFeatureDetector_CreateWithParams_Async( + threshold, + nonmaxSuppression, + type, + callback, + ); + } + + late final _FastFeatureDetector_CreateWithParams_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Int, ffi.Bool, ffi.Int, + CvCallback_1)>>('FastFeatureDetector_CreateWithParams_Async'); + late final _FastFeatureDetector_CreateWithParams_Async = + _FastFeatureDetector_CreateWithParams_AsyncPtr.asFunction< + ffi.Pointer Function(int, bool, int, CvCallback_1)>(); + + ffi.Pointer FastFeatureDetector_Create_Async( + CvCallback_1 callback, + ) { + return _FastFeatureDetector_Create_Async( + callback, + ); + } + + late final _FastFeatureDetector_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'FastFeatureDetector_Create_Async'); + late final _FastFeatureDetector_Create_Async = + _FastFeatureDetector_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer FastFeatureDetector_Detect( FastFeatureDetector f, Mat src, @@ -6008,6 +6432,27 @@ class CvNative { ffi.Pointer Function( FastFeatureDetector, Mat, ffi.Pointer)>(); + ffi.Pointer FastFeatureDetector_Detect_Async( + FastFeatureDetector self, + Mat src, + CvCallback_1 callback, + ) { + return _FastFeatureDetector_Detect_Async( + self, + src, + callback, + ); + } + + late final _FastFeatureDetector_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FastFeatureDetector, Mat, + CvCallback_1)>>('FastFeatureDetector_Detect_Async'); + late final _FastFeatureDetector_Detect_Async = + _FastFeatureDetector_Detect_AsyncPtr.asFunction< + ffi.Pointer Function( + FastFeatureDetector, Mat, CvCallback_1)>(); + ffi.Pointer FastNlMeansDenoising( Mat src, Mat dst, @@ -6858,6 +7303,24 @@ class CvNative { late final _FlannBasedMatcher_Close = _FlannBasedMatcher_ClosePtr.asFunction< void Function(FlannBasedMatcherPtr)>(); + ffi.Pointer FlannBasedMatcher_Close_Async( + FlannBasedMatcherPtr self, + CvCallback_0 callback, + ) { + return _FlannBasedMatcher_Close_Async( + self, + callback, + ); + } + + late final _FlannBasedMatcher_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FlannBasedMatcherPtr, + CvCallback_0)>>('FlannBasedMatcher_Close_Async'); + late final _FlannBasedMatcher_Close_Async = + _FlannBasedMatcher_Close_AsyncPtr.asFunction< + ffi.Pointer Function(FlannBasedMatcherPtr, CvCallback_0)>(); + ffi.Pointer FlannBasedMatcher_Create( ffi.Pointer rval, ) { @@ -6874,6 +7337,21 @@ class CvNative { _FlannBasedMatcher_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer FlannBasedMatcher_Create_Async( + CvCallback_1 callback, + ) { + return _FlannBasedMatcher_Create_Async( + callback, + ); + } + + late final _FlannBasedMatcher_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'FlannBasedMatcher_Create_Async'); + late final _FlannBasedMatcher_Create_Async = + _FlannBasedMatcher_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer FlannBasedMatcher_KnnMatch( FlannBasedMatcher f, Mat query, @@ -6899,6 +7377,31 @@ class CvNative { ffi.Pointer Function( FlannBasedMatcher, Mat, Mat, int, ffi.Pointer)>(); + ffi.Pointer FlannBasedMatcher_KnnMatch_Async( + FlannBasedMatcher self, + Mat query, + Mat train, + int k, + CvCallback_1 callback, + ) { + return _FlannBasedMatcher_KnnMatch_Async( + self, + query, + train, + k, + callback, + ); + } + + late final _FlannBasedMatcher_KnnMatch_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(FlannBasedMatcher, Mat, Mat, ffi.Int, + CvCallback_1)>>('FlannBasedMatcher_KnnMatch_Async'); + late final _FlannBasedMatcher_KnnMatch_Async = + _FlannBasedMatcher_KnnMatch_AsyncPtr.asFunction< + ffi.Pointer Function( + FlannBasedMatcher, Mat, Mat, int, CvCallback_1)>(); + ffi.Pointer GArrayGArrayPoint_FromVec( VecVecPoint points, ffi.Pointer rval, @@ -7085,6 +7588,24 @@ class CvNative { late final _GFTTDetector_Close = _GFTTDetector_ClosePtr.asFunction(); + ffi.Pointer GFTTDetector_Close_Async( + GFTTDetectorPtr self, + CvCallback_0 callback, + ) { + return _GFTTDetector_Close_Async( + self, + callback, + ); + } + + late final _GFTTDetector_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + GFTTDetectorPtr, CvCallback_0)>>('GFTTDetector_Close_Async'); + late final _GFTTDetector_Close_Async = + _GFTTDetector_Close_AsyncPtr.asFunction< + ffi.Pointer Function(GFTTDetectorPtr, CvCallback_0)>(); + ffi.Pointer GFTTDetector_Create( ffi.Pointer rval, ) { @@ -7100,6 +7621,20 @@ class CvNative { late final _GFTTDetector_Create = _GFTTDetector_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer GFTTDetector_Create_Async( + CvCallback_1 callback, + ) { + return _GFTTDetector_Create_Async( + callback, + ); + } + + late final _GFTTDetector_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'GFTTDetector_Create_Async'); + late final _GFTTDetector_Create_Async = _GFTTDetector_Create_AsyncPtr + .asFunction Function(CvCallback_1)>(); + ffi.Pointer GFTTDetector_Detect( GFTTDetector a, Mat src, @@ -7120,6 +7655,26 @@ class CvNative { ffi.Pointer Function( GFTTDetector, Mat, ffi.Pointer)>(); + ffi.Pointer GFTTDetector_Detect_Async( + GFTTDetector self, + Mat src, + CvCallback_1 callback, + ) { + return _GFTTDetector_Detect_Async( + self, + src, + callback, + ); + } + + late final _GFTTDetector_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + GFTTDetector, Mat, CvCallback_1)>>('GFTTDetector_Detect_Async'); + late final _GFTTDetector_Detect_Async = + _GFTTDetector_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(GFTTDetector, Mat, CvCallback_1)>(); + ffi.Pointer GaussianBlur( Mat src, Mat dst, @@ -9464,6 +10019,23 @@ class CvNative { _lookup>('KAZE_Close'); late final _KAZE_Close = _KAZE_ClosePtr.asFunction(); + ffi.Pointer KAZE_Close_Async( + KAZEPtr self, + CvCallback_0 callback, + ) { + return _KAZE_Close_Async( + self, + callback, + ); + } + + late final _KAZE_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + KAZEPtr, CvCallback_0)>>('KAZE_Close_Async'); + late final _KAZE_Close_Async = _KAZE_Close_AsyncPtr.asFunction< + ffi.Pointer Function(KAZEPtr, CvCallback_0)>(); + ffi.Pointer KAZE_Create( ffi.Pointer rval, ) { @@ -9478,6 +10050,20 @@ class CvNative { late final _KAZE_Create = _KAZE_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer KAZE_Create_Async( + CvCallback_1 callback, + ) { + return _KAZE_Create_Async( + callback, + ); + } + + late final _KAZE_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'KAZE_Create_Async'); + late final _KAZE_Create_Async = _KAZE_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer KAZE_Detect( KAZE a, Mat src, @@ -9521,6 +10107,47 @@ class CvNative { ffi.Pointer Function( KAZE, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer KAZE_DetectAndCompute_Async( + KAZE self, + Mat src, + Mat mask, + CvCallback_2 callback, + ) { + return _KAZE_DetectAndCompute_Async( + self, + src, + mask, + callback, + ); + } + + late final _KAZE_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + KAZE, Mat, Mat, CvCallback_2)>>('KAZE_DetectAndCompute_Async'); + late final _KAZE_DetectAndCompute_Async = + _KAZE_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(KAZE, Mat, Mat, CvCallback_2)>(); + + ffi.Pointer KAZE_Detect_Async( + KAZE self, + Mat src, + CvCallback_1 callback, + ) { + return _KAZE_Detect_Async( + self, + src, + callback, + ); + } + + late final _KAZE_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + KAZE, Mat, CvCallback_1)>>('KAZE_Detect_Async'); + late final _KAZE_Detect_Async = _KAZE_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(KAZE, Mat, CvCallback_1)>(); + ffi.Pointer KMeans( Mat data, int k, @@ -10575,6 +11202,23 @@ class CvNative { _lookup>('MSER_Close'); late final _MSER_Close = _MSER_ClosePtr.asFunction(); + ffi.Pointer MSER_Close_Async( + MSERPtr self, + CvCallback_0 callback, + ) { + return _MSER_Close_Async( + self, + callback, + ); + } + + late final _MSER_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + MSERPtr, CvCallback_0)>>('MSER_Close_Async'); + late final _MSER_Close_Async = _MSER_Close_AsyncPtr.asFunction< + ffi.Pointer Function(MSERPtr, CvCallback_0)>(); + ffi.Pointer MSER_Create( ffi.Pointer rval, ) { @@ -10589,6 +11233,20 @@ class CvNative { late final _MSER_Create = _MSER_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer MSER_Create_Async( + CvCallback_1 callback, + ) { + return _MSER_Create_Async( + callback, + ); + } + + late final _MSER_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'MSER_Create_Async'); + late final _MSER_Create_Async = _MSER_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer MSER_Detect( MSER a, Mat src, @@ -10608,6 +11266,25 @@ class CvNative { late final _MSER_Detect = _MSER_DetectPtr.asFunction< ffi.Pointer Function(MSER, Mat, ffi.Pointer)>(); + ffi.Pointer MSER_Detect_Async( + MSER self, + Mat src, + CvCallback_1 callback, + ) { + return _MSER_Detect_Async( + self, + src, + callback, + ); + } + + late final _MSER_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + MSER, Mat, CvCallback_1)>>('MSER_Detect_Async'); + late final _MSER_Detect_Async = _MSER_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(MSER, Mat, CvCallback_1)>(); + ffi.Pointer Mat_AbsDiff( Mat src1, Mat src2, @@ -17599,6 +18276,23 @@ class CvNative { _lookup>('ORB_Close'); late final _ORB_Close = _ORB_ClosePtr.asFunction(); + ffi.Pointer ORB_Close_Async( + ORBPtr self, + CvCallback_0 callback, + ) { + return _ORB_Close_Async( + self, + callback, + ); + } + + late final _ORB_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ORBPtr, CvCallback_0)>>('ORB_Close_Async'); + late final _ORB_Close_Async = _ORB_Close_AsyncPtr.asFunction< + ffi.Pointer Function(ORBPtr, CvCallback_0)>(); + ffi.Pointer ORB_Create( ffi.Pointer rval, ) { @@ -17656,6 +18350,64 @@ class CvNative { ffi.Pointer Function( int, double, int, int, int, int, int, int, int, ffi.Pointer)>(); + ffi.Pointer ORB_CreateWithParams_Async( + int nfeatures, + double scaleFactor, + int nlevels, + int edgeThreshold, + int firstLevel, + int WTA_K, + int scoreType, + int patchSize, + int fastThreshold, + CvCallback_1 callback, + ) { + return _ORB_CreateWithParams_Async( + nfeatures, + scaleFactor, + nlevels, + edgeThreshold, + firstLevel, + WTA_K, + scoreType, + patchSize, + fastThreshold, + callback, + ); + } + + late final _ORB_CreateWithParams_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int, + ffi.Float, + ffi.Int, + ffi.Int, + ffi.Int, + ffi.Int, + ffi.Int, + ffi.Int, + ffi.Int, + CvCallback_1)>>('ORB_CreateWithParams_Async'); + late final _ORB_CreateWithParams_Async = + _ORB_CreateWithParams_AsyncPtr.asFunction< + ffi.Pointer Function( + int, double, int, int, int, int, int, int, int, CvCallback_1)>(); + + ffi.Pointer ORB_Create_Async( + CvCallback_1 callback, + ) { + return _ORB_Create_Async( + callback, + ); + } + + late final _ORB_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'ORB_Create_Async'); + late final _ORB_Create_Async = _ORB_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer ORB_Detect( ORB o, Mat src, @@ -17699,6 +18451,47 @@ class CvNative { ffi.Pointer Function( ORB, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer ORB_DetectAndCompute_Async( + ORB self, + Mat src, + Mat mask, + CvCallback_2 callback, + ) { + return _ORB_DetectAndCompute_Async( + self, + src, + mask, + callback, + ); + } + + late final _ORB_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ORB, Mat, Mat, CvCallback_2)>>('ORB_DetectAndCompute_Async'); + late final _ORB_DetectAndCompute_Async = + _ORB_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(ORB, Mat, Mat, CvCallback_2)>(); + + ffi.Pointer ORB_Detect_Async( + ORB self, + Mat src, + CvCallback_1 callback, + ) { + return _ORB_Detect_Async( + self, + src, + callback, + ); + } + + late final _ORB_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ORB, Mat, CvCallback_1)>>('ORB_Detect_Async'); + late final _ORB_Detect_Async = _ORB_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(ORB, Mat, CvCallback_1)>(); + ffi.Pointer Ones( int rows, int cols, @@ -19414,6 +20207,23 @@ class CvNative { _lookup>('SIFT_Close'); late final _SIFT_Close = _SIFT_ClosePtr.asFunction(); + ffi.Pointer SIFT_Close_Async( + SIFTPtr self, + CvCallback_0 callback, + ) { + return _SIFT_Close_Async( + self, + callback, + ); + } + + late final _SIFT_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + SIFTPtr, CvCallback_0)>>('SIFT_Close_Async'); + late final _SIFT_Close_Async = _SIFT_Close_AsyncPtr.asFunction< + ffi.Pointer Function(SIFTPtr, CvCallback_0)>(); + ffi.Pointer SIFT_Create( ffi.Pointer rval, ) { @@ -19428,6 +20238,20 @@ class CvNative { late final _SIFT_Create = _SIFT_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer SIFT_Create_Async( + CvCallback_1 callback, + ) { + return _SIFT_Create_Async( + callback, + ); + } + + late final _SIFT_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'SIFT_Create_Async'); + late final _SIFT_Create_Async = _SIFT_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer SIFT_Detect( SIFT f, Mat src, @@ -19471,6 +20295,47 @@ class CvNative { ffi.Pointer Function( SIFT, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer SIFT_DetectAndCompute_Async( + SIFT self, + Mat src, + Mat mask, + CvCallback_2 callback, + ) { + return _SIFT_DetectAndCompute_Async( + self, + src, + mask, + callback, + ); + } + + late final _SIFT_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + SIFT, Mat, Mat, CvCallback_2)>>('SIFT_DetectAndCompute_Async'); + late final _SIFT_DetectAndCompute_Async = + _SIFT_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(SIFT, Mat, Mat, CvCallback_2)>(); + + ffi.Pointer SIFT_Detect_Async( + SIFT self, + Mat src, + CvCallback_1 callback, + ) { + return _SIFT_Detect_Async( + self, + src, + callback, + ); + } + + late final _SIFT_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + SIFT, Mat, CvCallback_1)>>('SIFT_Detect_Async'); + late final _SIFT_Detect_Async = _SIFT_Detect_AsyncPtr.asFunction< + ffi.Pointer Function(SIFT, Mat, CvCallback_1)>(); + ffi.Pointer SVD_Compute( Mat src, ffi.Pointer w, @@ -19791,6 +20656,25 @@ class CvNative { late final _SimpleBlobDetector_Close = _SimpleBlobDetector_ClosePtr .asFunction(); + ffi.Pointer SimpleBlobDetector_Close_Async( + SimpleBlobDetectorPtr self, + CvCallback_0 callback, + ) { + return _SimpleBlobDetector_Close_Async( + self, + callback, + ); + } + + late final _SimpleBlobDetector_Close_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(SimpleBlobDetectorPtr, + CvCallback_0)>>('SimpleBlobDetector_Close_Async'); + late final _SimpleBlobDetector_Close_Async = + _SimpleBlobDetector_Close_AsyncPtr.asFunction< + ffi.Pointer Function( + SimpleBlobDetectorPtr, CvCallback_0)>(); + ffi.Pointer SimpleBlobDetector_Create( ffi.Pointer rval, ) { @@ -19807,6 +20691,21 @@ class CvNative { _SimpleBlobDetector_CreatePtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer SimpleBlobDetector_Create_Async( + CvCallback_1 callback, + ) { + return _SimpleBlobDetector_Create_Async( + callback, + ); + } + + late final _SimpleBlobDetector_Create_AsyncPtr = + _lookup Function(CvCallback_1)>>( + 'SimpleBlobDetector_Create_Async'); + late final _SimpleBlobDetector_Create_Async = + _SimpleBlobDetector_Create_AsyncPtr.asFunction< + ffi.Pointer Function(CvCallback_1)>(); + ffi.Pointer SimpleBlobDetector_Create_WithParams( SimpleBlobDetectorParams params, ffi.Pointer rval, @@ -19827,6 +20726,25 @@ class CvNative { ffi.Pointer Function( SimpleBlobDetectorParams, ffi.Pointer)>(); + ffi.Pointer SimpleBlobDetector_Create_WithParams_Async( + SimpleBlobDetectorParams params, + CvCallback_1 callback, + ) { + return _SimpleBlobDetector_Create_WithParams_Async( + params, + callback, + ); + } + + late final _SimpleBlobDetector_Create_WithParams_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(SimpleBlobDetectorParams, + CvCallback_1)>>('SimpleBlobDetector_Create_WithParams_Async'); + late final _SimpleBlobDetector_Create_WithParams_Async = + _SimpleBlobDetector_Create_WithParams_AsyncPtr.asFunction< + ffi.Pointer Function( + SimpleBlobDetectorParams, CvCallback_1)>(); + ffi.Pointer SimpleBlobDetector_Detect( SimpleBlobDetector b, Mat src, @@ -19848,6 +20766,27 @@ class CvNative { ffi.Pointer Function( SimpleBlobDetector, Mat, ffi.Pointer)>(); + ffi.Pointer SimpleBlobDetector_Detect_Async( + SimpleBlobDetector self, + Mat src, + CvCallback_1 callback, + ) { + return _SimpleBlobDetector_Detect_Async( + self, + src, + callback, + ); + } + + late final _SimpleBlobDetector_Detect_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(SimpleBlobDetector, Mat, + CvCallback_1)>>('SimpleBlobDetector_Detect_Async'); + late final _SimpleBlobDetector_Detect_Async = + _SimpleBlobDetector_Detect_AsyncPtr.asFunction< + ffi.Pointer Function( + SimpleBlobDetector, Mat, CvCallback_1)>(); + ffi.Pointer Sobel( Mat src, Mat dst, @@ -28860,8 +29799,18 @@ class _SymbolAddresses { _SymbolAddresses(this._library); ffi.Pointer> get AKAZE_Close => _library._AKAZE_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(AKAZEPtr, CvCallback_0)>> + get AKAZE_Close_Async => _library._AKAZE_Close_AsyncPtr; ffi.Pointer> get AgastFeatureDetector_Close => _library._AgastFeatureDetector_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + AgastFeatureDetectorPtr, CvCallback_0)>> + get AgastFeatureDetector_Close_Async => + _library._AgastFeatureDetector_Close_AsyncPtr; ffi.Pointer> get AlignMTB_Close => _library._AlignMTB_ClosePtr; ffi.Pointer> @@ -28875,8 +29824,16 @@ class _SymbolAddresses { get AsyncArray_Close => _library._AsyncArray_ClosePtr; ffi.Pointer> get BFMatcher_Close => _library._BFMatcher_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(BFMatcherPtr, CvCallback_0)>> + get BFMatcher_Close_Async => _library._BFMatcher_Close_AsyncPtr; ffi.Pointer> get BRISK_Close => _library._BRISK_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(BRISKPtr, CvCallback_0)>> + get BRISK_Close_Async => _library._BRISK_Close_AsyncPtr; ffi.Pointer> get BackgroundSubtractorKNN_Close => _library._BackgroundSubtractorKNN_ClosePtr; @@ -28900,14 +29857,34 @@ class _SymbolAddresses { get FaceRecognizerSF_Close => _library._FaceRecognizerSF_ClosePtr; ffi.Pointer> get FastFeatureDetector_Close => _library._FastFeatureDetector_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + FastFeatureDetectorPtr, CvCallback_0)>> + get FastFeatureDetector_Close_Async => + _library._FastFeatureDetector_Close_AsyncPtr; ffi.Pointer> get FlannBasedMatcher_Close => _library._FlannBasedMatcher_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + FlannBasedMatcherPtr, CvCallback_0)>> + get FlannBasedMatcher_Close_Async => + _library._FlannBasedMatcher_Close_AsyncPtr; ffi.Pointer> get GFTTDetector_Close => _library._GFTTDetector_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(GFTTDetectorPtr, CvCallback_0)>> + get GFTTDetector_Close_Async => _library._GFTTDetector_Close_AsyncPtr; ffi.Pointer> get HOGDescriptor_Close => _library._HOGDescriptor_ClosePtr; ffi.Pointer> get KAZE_Close => _library._KAZE_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(KAZEPtr, CvCallback_0)>> + get KAZE_Close_Async => _library._KAZE_Close_AsyncPtr; ffi.Pointer> get KalmanFilter_Close => _library._KalmanFilter_ClosePtr; ffi.Pointer> @@ -28916,6 +29893,10 @@ class _SymbolAddresses { get Layer_Close_Async => _library._Layer_Close_AsyncPtr; ffi.Pointer> get MSER_Close => _library._MSER_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(MSERPtr, CvCallback_0)>> + get MSER_Close_Async => _library._MSER_Close_AsyncPtr; ffi.Pointer> get Mat_Close => _library._Mat_ClosePtr; ffi.Pointer)>> @@ -28928,15 +29909,22 @@ class _SymbolAddresses { get Net_Close_Async => _library._Net_Close_AsyncPtr; ffi.Pointer> get ORB_Close => _library._ORB_ClosePtr; + ffi.Pointer< + ffi + .NativeFunction Function(ORBPtr, CvCallback_0)>> + get ORB_Close_Async => _library._ORB_Close_AsyncPtr; ffi.Pointer> get QRCodeDetector_Close => _library._QRCodeDetector_ClosePtr; ffi.Pointer> get Rng_Close => _library._Rng_ClosePtr; ffi.Pointer> get SIFT_Close => _library._SIFT_ClosePtr; + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(SIFTPtr, CvCallback_0)>> + get SIFT_Close_Async => _library._SIFT_Close_AsyncPtr; ffi.Pointer> get SimpleBlobDetector_Close => _library._SimpleBlobDetector_ClosePtr; - ffi.Pointer> get Stitcher_Close => _library._Stitcher_ClosePtr; ffi.Pointer> get Stitcher_Close_Async => _library._Stitcher_Close_AsyncPtr; diff --git a/src/features2d/features2d.cpp b/src/features2d/features2d.cpp index 769021fe..d1ce63fb 100644 --- a/src/features2d/features2d.cpp +++ b/src/features2d/features2d.cpp @@ -7,6 +7,7 @@ */ #include "features2d.h" +#include "utils.hpp" CvStatus *AKAZE_Create(AKAZE *rval) { @@ -227,60 +228,6 @@ CvStatus *ORB_DetectAndCompute(ORB o, Mat src, Mat mask, Mat desc, VecKeyPoint * END_WRAP } -cv::SimpleBlobDetector::Params ConvertCParamsToCPPParams(SimpleBlobDetectorParams params) -{ - cv::SimpleBlobDetector::Params converted; - - converted.blobColor = params.blobColor; - converted.filterByArea = params.filterByArea; - converted.filterByCircularity = params.filterByCircularity; - converted.filterByColor = params.filterByColor; - converted.filterByConvexity = params.filterByConvexity; - converted.filterByInertia = params.filterByInertia; - converted.maxArea = params.maxArea; - converted.maxCircularity = params.maxCircularity; - converted.maxConvexity = params.maxConvexity; - converted.maxInertiaRatio = params.maxInertiaRatio; - converted.maxThreshold = params.maxThreshold; - converted.minArea = params.minArea; - converted.minCircularity = params.minCircularity; - converted.minConvexity = params.minConvexity; - converted.minDistBetweenBlobs = params.minDistBetweenBlobs; - converted.minInertiaRatio = params.minInertiaRatio; - converted.minRepeatability = params.minRepeatability; - converted.minThreshold = params.minThreshold; - converted.thresholdStep = params.thresholdStep; - - return converted; -} - -SimpleBlobDetectorParams ConvertCPPParamsToCParams(cv::SimpleBlobDetector::Params params) -{ - SimpleBlobDetectorParams converted; - - converted.blobColor = params.blobColor; - converted.filterByArea = params.filterByArea; - converted.filterByCircularity = params.filterByCircularity; - converted.filterByColor = params.filterByColor; - converted.filterByConvexity = params.filterByConvexity; - converted.filterByInertia = params.filterByInertia; - converted.maxArea = params.maxArea; - converted.maxCircularity = params.maxCircularity; - converted.maxConvexity = params.maxConvexity; - converted.maxInertiaRatio = params.maxInertiaRatio; - converted.maxThreshold = params.maxThreshold; - converted.minArea = params.minArea; - converted.minCircularity = params.minCircularity; - converted.minConvexity = params.minConvexity; - converted.minDistBetweenBlobs = params.minDistBetweenBlobs; - converted.minInertiaRatio = params.minInertiaRatio; - converted.minRepeatability = params.minRepeatability; - converted.minThreshold = params.minThreshold; - converted.thresholdStep = params.thresholdStep; - - return converted; -} - CvStatus *SimpleBlobDetector_Create(SimpleBlobDetector *rval) { BEGIN_WRAP diff --git a/src/features2d/features2d_async.cpp b/src/features2d/features2d_async.cpp new file mode 100644 index 00000000..85bbefbe --- /dev/null +++ b/src/features2d/features2d_async.cpp @@ -0,0 +1,426 @@ +/* Created by Abdelaziz Mahdy. Licensed: Apache 2.0 license. Copyright (c) 2024 Abdelaziz Mahdy. */ +#include "features2d_async.h" +#include "utils.hpp" + +#include "core/types.h" + +// Asynchronous functions for AKAZE +CvStatus *AKAZE_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new AKAZE{new cv::Ptr(cv::AKAZE::create())}); + END_WRAP +} + +CvStatus *AKAZE_Close_Async(AKAZEPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *AKAZE_Detect_Async(AKAZE self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *AKAZE_DetectAndCompute_Async(AKAZE self, Mat src, Mat mask, CvCallback_2 callback) +{ + BEGIN_WRAP + std::vector detected; + cv::Mat desc; + (*self.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, desc); + callback(new VecKeyPoint{new std::vector(detected)}, new Mat{new cv::Mat(desc)}); + END_WRAP +} + +// Asynchronous functions for AgastFeatureDetector +CvStatus *AgastFeatureDetector_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new AgastFeatureDetector{new cv::Ptr(cv::AgastFeatureDetector::create())}); + END_WRAP +} + +CvStatus *AgastFeatureDetector_Close_Async(AgastFeatureDetectorPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *AgastFeatureDetector_Detect_Async(AgastFeatureDetector self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +// Asynchronous functions for BRISK +CvStatus *BRISK_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new BRISK{new cv::Ptr(cv::BRISK::create())}); + END_WRAP +} + +CvStatus *BRISK_Close_Async(BRISKPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *BRISK_Detect_Async(BRISK self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *BRISK_DetectAndCompute_Async(BRISK self, Mat src, Mat mask, CvCallback_2 callback) +{ + BEGIN_WRAP + std::vector detected; + cv::Mat desc; + (*self.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, desc); + callback(new VecKeyPoint{new std::vector(detected)}, new Mat{new cv::Mat(desc)}); + END_WRAP +} + +// Asynchronous functions for FastFeatureDetector +CvStatus *FastFeatureDetector_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new FastFeatureDetector{new cv::Ptr(cv::FastFeatureDetector::create())}); + END_WRAP +} + +CvStatus *FastFeatureDetector_CreateWithParams_Async(int threshold, bool nonmaxSuppression, int type, CvCallback_1 callback) +{ + BEGIN_WRAP + auto type_ = static_cast(type); + callback(new FastFeatureDetector{new cv::Ptr(cv::FastFeatureDetector::create(threshold, nonmaxSuppression, type_))}); + END_WRAP +} + +CvStatus *FastFeatureDetector_Close_Async(FastFeatureDetectorPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *FastFeatureDetector_Detect_Async(FastFeatureDetector self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +// Asynchronous functions for GFTTDetector +CvStatus *GFTTDetector_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new GFTTDetector{new cv::Ptr(cv::GFTTDetector::create())}); + END_WRAP +} + +CvStatus *GFTTDetector_Close_Async(GFTTDetectorPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *GFTTDetector_Detect_Async(GFTTDetector self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +// Asynchronous functions for KAZE +CvStatus *KAZE_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new KAZE{new cv::Ptr(cv::KAZE::create())}); + END_WRAP +} + +CvStatus *KAZE_Close_Async(KAZEPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *KAZE_Detect_Async(KAZE self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *KAZE_DetectAndCompute_Async(KAZE self, Mat src, Mat mask, CvCallback_2 callback) +{ + BEGIN_WRAP + std::vector detected; + cv::Mat desc; + (*self.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, desc); + callback(new VecKeyPoint{new std::vector(detected)}, new Mat{new cv::Mat(desc)}); + END_WRAP +} + +// Asynchronous functions for MSER +CvStatus *MSER_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new MSER{new cv::Ptr(cv::MSER::create())}); + END_WRAP +} + +CvStatus *MSER_Close_Async(MSERPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *MSER_Detect_Async(MSER self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +// Asynchronous functions for ORB +CvStatus *ORB_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new ORB{new cv::Ptr(cv::ORB::create())}); + END_WRAP +} + +CvStatus *ORB_CreateWithParams_Async(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType, int patchSize, int fastThreshold, CvCallback_1 callback) +{ + BEGIN_WRAP + auto type = static_cast(scoreType); + callback(new ORB{new cv::Ptr(cv::ORB::create(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, type, patchSize, fastThreshold))}); + END_WRAP +} + +CvStatus *ORB_Close_Async(ORBPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *ORB_Detect_Async(ORB self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *ORB_DetectAndCompute_Async(ORB self, Mat src, Mat mask, CvCallback_2 callback) +{ + BEGIN_WRAP + std::vector detected; + cv::Mat desc; + (*self.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, desc); + callback(new VecKeyPoint{new std::vector(detected)}, new Mat{new cv::Mat(desc)}); + END_WRAP +} + +// Asynchronous functions for SimpleBlobDetector +CvStatus *SimpleBlobDetector_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new SimpleBlobDetector{new cv::Ptr(cv::SimpleBlobDetector::create())}); + END_WRAP +} + +CvStatus *SimpleBlobDetector_Create_WithParams_Async(SimpleBlobDetectorParams params, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new SimpleBlobDetector{new cv::Ptr(cv::SimpleBlobDetector::create(ConvertCParamsToCPPParams(params)))}); + END_WRAP +} + +CvStatus *SimpleBlobDetector_Close_Async(SimpleBlobDetectorPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *SimpleBlobDetector_Detect_Async(SimpleBlobDetector self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +// Asynchronous functions for BFMatcher +CvStatus *BFMatcher_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new BFMatcher{new cv::Ptr(cv::BFMatcher::create())}); + END_WRAP +} + +CvStatus *BFMatcher_CreateWithParams_Async(int normType, bool crossCheck, CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new BFMatcher{new cv::Ptr(cv::BFMatcher::create(normType, crossCheck))}); + END_WRAP +} + +CvStatus *BFMatcher_Close_Async(BFMatcherPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *BFMatcher_Match_Async(BFMatcher self, Mat query, Mat train, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector matches; + (*self.ptr)->match(*query.ptr, *train.ptr, matches); + callback(new VecDMatch{new std::vector(matches)}); + END_WRAP +} + +CvStatus *BFMatcher_KnnMatch_Async(BFMatcher self, Mat query, Mat train, int k, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector> matches; + (*self.ptr)->knnMatch(*query.ptr, *train.ptr, matches, k); + callback(new VecVecDMatch{new std::vector>(matches)}); + END_WRAP +} + +// Asynchronous functions for FlannBasedMatcher +CvStatus *FlannBasedMatcher_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new FlannBasedMatcher{new cv::Ptr(cv::FlannBasedMatcher::create())}); + END_WRAP +} + +CvStatus *FlannBasedMatcher_Close_Async(FlannBasedMatcherPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *FlannBasedMatcher_KnnMatch_Async(FlannBasedMatcher self, Mat query, Mat train, int k, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector> matches; + (*self.ptr)->knnMatch(*query.ptr, *train.ptr, matches, k); + callback(new VecVecDMatch{new std::vector>(matches)}); + END_WRAP +} + +// Asynchronous utility functions +CvStatus *DrawKeyPoints_Async(Mat src, VecKeyPoint kp, Mat dst, const Scalar color, int flags, CvCallback_0 callback) +{ + BEGIN_WRAP + auto color_ = cv::Scalar(color.val1, color.val2, color.val3, color.val4); + cv::drawKeypoints(*src.ptr, *kp.ptr, *dst.ptr, color_, static_cast(flags)); + callback(); + END_WRAP +} + +CvStatus *DrawMatches_Async(Mat img1, VecKeyPoint kp1, Mat img2, VecKeyPoint kp2, VecDMatch matches1to2, Mat outImg, const Scalar matchesColor, const Scalar pointColor, VecChar matchesMask, int flags, CvCallback_0 callback) +{ + BEGIN_WRAP + auto mColor = cv::Scalar(matchesColor.val1, matchesColor.val2, matchesColor.val3, matchesColor.val4); + auto pColor = cv::Scalar(pointColor.val1, pointColor.val2, pointColor.val3, pointColor.val4); + cv::drawMatches(*img1.ptr, *kp1.ptr, *img2.ptr, *kp2.ptr, *matches1to2.ptr, *outImg.ptr, mColor, pColor, *matchesMask.ptr, static_cast(flags)); + callback(); + END_WRAP +} + +// Asynchronous functions for SIFT +CvStatus *SIFT_Create_Async(CvCallback_1 callback) +{ + BEGIN_WRAP + callback(new SIFT{new cv::Ptr(cv::SIFT::create())}); + END_WRAP +} + +CvStatus *SIFT_Close_Async(SIFTPtr self, CvCallback_0 callback) +{ + BEGIN_WRAP + self->ptr->reset(); + CVD_FREE(self); + callback(); + END_WRAP +} + +CvStatus *SIFT_Detect_Async(SIFT self, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*self.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *SIFT_DetectAndCompute_Async(SIFT self, Mat src, Mat mask, CvCallback_2 callback) +{ + BEGIN_WRAP + std::vector detected; + cv::Mat desc; + (*self.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, desc); + callback(new VecKeyPoint{new std::vector(detected)}, new Mat{new cv::Mat(desc)}); + END_WRAP +} diff --git a/src/features2d/features2d_async.h b/src/features2d/features2d_async.h new file mode 100644 index 00000000..200bdd0e --- /dev/null +++ b/src/features2d/features2d_async.h @@ -0,0 +1,92 @@ +/* Created by Abdelaziz Mahdy. Licensed: Apache 2.0 license. Copyright (c) 2024 Abdelaziz Mahdy. */ +#ifndef CVD_FEATURES2D_ASYNC_H_ +#define CVD_FEATURES2D_ASYNC_H_ + +#include "core/types.h" +#include "features2d.h" +#include + +#ifdef __cplusplus +#include +extern "C" { +#endif + +// AKAZE +CvStatus *AKAZE_Create_Async(CvCallback_1 callback); +CvStatus *AKAZE_Close_Async(AKAZEPtr self, CvCallback_0 callback); +CvStatus *AKAZE_Detect_Async(AKAZE self, Mat src, CvCallback_1 callback); +CvStatus *AKAZE_DetectAndCompute_Async(AKAZE self, Mat src, Mat mask, CvCallback_2 callback); + +// AgastFeatureDetector +CvStatus *AgastFeatureDetector_Create_Async(CvCallback_1 callback); +CvStatus *AgastFeatureDetector_Close_Async(AgastFeatureDetectorPtr self, CvCallback_0 callback); +CvStatus *AgastFeatureDetector_Detect_Async(AgastFeatureDetector self, Mat src, CvCallback_1 callback); + +// BRISK +CvStatus *BRISK_Create_Async(CvCallback_1 callback); +CvStatus *BRISK_Close_Async(BRISKPtr self, CvCallback_0 callback); +CvStatus *BRISK_Detect_Async(BRISK self, Mat src, CvCallback_1 callback); +CvStatus *BRISK_DetectAndCompute_Async(BRISK self, Mat src, Mat mask, CvCallback_2 callback); + +// FastFeatureDetector +CvStatus *FastFeatureDetector_Create_Async(CvCallback_1 callback); +CvStatus *FastFeatureDetector_CreateWithParams_Async(int threshold, bool nonmaxSuppression, int type, CvCallback_1 callback); +CvStatus *FastFeatureDetector_Close_Async(FastFeatureDetectorPtr self, CvCallback_0 callback); +CvStatus *FastFeatureDetector_Detect_Async(FastFeatureDetector self, Mat src, CvCallback_1 callback); + +// GFTTDetector +CvStatus *GFTTDetector_Create_Async(CvCallback_1 callback); +CvStatus *GFTTDetector_Close_Async(GFTTDetectorPtr self, CvCallback_0 callback); +CvStatus *GFTTDetector_Detect_Async(GFTTDetector self, Mat src, CvCallback_1 callback); + +// KAZE +CvStatus *KAZE_Create_Async(CvCallback_1 callback); +CvStatus *KAZE_Close_Async(KAZEPtr self, CvCallback_0 callback); +CvStatus *KAZE_Detect_Async(KAZE self, Mat src, CvCallback_1 callback); +CvStatus *KAZE_DetectAndCompute_Async(KAZE self, Mat src, Mat mask, CvCallback_2 callback); + +// MSER +CvStatus *MSER_Create_Async(CvCallback_1 callback); +CvStatus *MSER_Close_Async(MSERPtr self, CvCallback_0 callback); +CvStatus *MSER_Detect_Async(MSER self, Mat src, CvCallback_1 callback); + +// ORB +CvStatus *ORB_Create_Async(CvCallback_1 callback); +CvStatus *ORB_CreateWithParams_Async(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType, int patchSize, int fastThreshold, CvCallback_1 callback); +CvStatus *ORB_Close_Async(ORBPtr self, CvCallback_0 callback); +CvStatus *ORB_Detect_Async(ORB self, Mat src, CvCallback_1 callback); +CvStatus *ORB_DetectAndCompute_Async(ORB self, Mat src, Mat mask, CvCallback_2 callback); + +// SimpleBlobDetector +CvStatus *SimpleBlobDetector_Create_Async(CvCallback_1 callback); +CvStatus *SimpleBlobDetector_Create_WithParams_Async(SimpleBlobDetectorParams params, CvCallback_1 callback); +CvStatus *SimpleBlobDetector_Close_Async(SimpleBlobDetectorPtr self, CvCallback_0 callback); +CvStatus *SimpleBlobDetector_Detect_Async(SimpleBlobDetector self, Mat src, CvCallback_1 callback); + +// BFMatcher +CvStatus *BFMatcher_Create_Async(CvCallback_1 callback); +CvStatus *BFMatcher_CreateWithParams_Async(int normType, bool crossCheck, CvCallback_1 callback); +CvStatus *BFMatcher_Close_Async(BFMatcherPtr self, CvCallback_0 callback); +CvStatus *BFMatcher_Match_Async(BFMatcher self, Mat query, Mat train, CvCallback_1 callback); +CvStatus *BFMatcher_KnnMatch_Async(BFMatcher self, Mat query, Mat train, int k, CvCallback_1 callback); + +// FlannBasedMatcher +CvStatus *FlannBasedMatcher_Create_Async(CvCallback_1 callback); +CvStatus *FlannBasedMatcher_Close_Async(FlannBasedMatcherPtr self, CvCallback_0 callback); +CvStatus *FlannBasedMatcher_KnnMatch_Async(FlannBasedMatcher self, Mat query, Mat train, int k, CvCallback_1 callback); + +// Utility functions +CvStatus *DrawKeyPoints_Async(Mat src, VecKeyPoint kp, Mat dst, const Scalar color, int flags, CvCallback_0 callback); +CvStatus *DrawMatches_Async(Mat img1, VecKeyPoint kp1, Mat img2, VecKeyPoint kp2, VecDMatch matches1to2, Mat outImg, const Scalar matchesColor, const Scalar pointColor, VecChar matchesMask, int flags, CvCallback_0 callback); + +// SIFT +CvStatus *SIFT_Create_Async(CvCallback_1 callback); +CvStatus *SIFT_Close_Async(SIFTPtr self, CvCallback_0 callback); +CvStatus *SIFT_Detect_Async(SIFT self, Mat src, CvCallback_1 callback); +CvStatus *SIFT_DetectAndCompute_Async(SIFT self, Mat src, Mat mask, CvCallback_2 callback); + +#ifdef __cplusplus +} +#endif + +#endif // CVD_FEATURES2D_ASYNC_H_ diff --git a/src/features2d/utils.hpp b/src/features2d/utils.hpp new file mode 100644 index 00000000..6110cfeb --- /dev/null +++ b/src/features2d/utils.hpp @@ -0,0 +1,61 @@ +#ifndef CVD_FEATURES2D_UTILS_H +#define CVD_FEATURES2D_UTILS_H + +#include "features2d/features2d.h" +#include + +inline cv::SimpleBlobDetector::Params ConvertCParamsToCPPParams(SimpleBlobDetectorParams params) +{ + cv::SimpleBlobDetector::Params converted; + + converted.blobColor = params.blobColor; + converted.filterByArea = params.filterByArea; + converted.filterByCircularity = params.filterByCircularity; + converted.filterByColor = params.filterByColor; + converted.filterByConvexity = params.filterByConvexity; + converted.filterByInertia = params.filterByInertia; + converted.maxArea = params.maxArea; + converted.maxCircularity = params.maxCircularity; + converted.maxConvexity = params.maxConvexity; + converted.maxInertiaRatio = params.maxInertiaRatio; + converted.maxThreshold = params.maxThreshold; + converted.minArea = params.minArea; + converted.minCircularity = params.minCircularity; + converted.minConvexity = params.minConvexity; + converted.minDistBetweenBlobs = params.minDistBetweenBlobs; + converted.minInertiaRatio = params.minInertiaRatio; + converted.minRepeatability = params.minRepeatability; + converted.minThreshold = params.minThreshold; + converted.thresholdStep = params.thresholdStep; + + return converted; +} + +inline SimpleBlobDetectorParams ConvertCPPParamsToCParams(cv::SimpleBlobDetector::Params params) +{ + SimpleBlobDetectorParams converted; + + converted.blobColor = params.blobColor; + converted.filterByArea = params.filterByArea; + converted.filterByCircularity = params.filterByCircularity; + converted.filterByColor = params.filterByColor; + converted.filterByConvexity = params.filterByConvexity; + converted.filterByInertia = params.filterByInertia; + converted.maxArea = params.maxArea; + converted.maxCircularity = params.maxCircularity; + converted.maxConvexity = params.maxConvexity; + converted.maxInertiaRatio = params.maxInertiaRatio; + converted.maxThreshold = params.maxThreshold; + converted.minArea = params.minArea; + converted.minCircularity = params.minCircularity; + converted.minConvexity = params.minConvexity; + converted.minDistBetweenBlobs = params.minDistBetweenBlobs; + converted.minInertiaRatio = params.minInertiaRatio; + converted.minRepeatability = params.minRepeatability; + converted.minThreshold = params.minThreshold; + converted.thresholdStep = params.thresholdStep; + + return converted; +} + +#endif // CVD_FEATURES2D_UTILS_H diff --git a/test/features2d/features2d_async_test.dart b/test/features2d/features2d_async_test.dart new file mode 100644 index 00000000..54bb750a --- /dev/null +++ b/test/features2d/features2d_async_test.dart @@ -0,0 +1,356 @@ +import 'package:opencv_dart/opencv_dart.dart' as cv; +import 'package:test/test.dart'; + +void main() async { + test('cv.AKAZEAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final ak = await cv.AKAZEAsync.emptyAsync(); + final kp = await ak.detectAsync(img); + expect(kp.length, greaterThan(512)); + + final mask = cv.Mat.empty(); + final (kp2, desc) = await ak.detectAndComputeAsync(img, mask); + expect(kp2.length, greaterThan(512)); + expect(desc.isEmpty, false); + + ak.dispose(); + }); + + test('cv.AgastFeatureDetectorAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final ad = await cv.AgastFeatureDetectorAsync.emptyAsync(); + final kp = await ad.detectAsync(img); + expect(kp.length, greaterThan(2800)); + + ad.dispose(); + }); + + test('cv.BRISKAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final br = await cv.BRISKAsync.emptyAsync(); + final kp = await br.detectAsync(img); + expect(kp.length, greaterThan(512)); + + final mask = cv.Mat.empty(); + final (kp2, desc) = await br.detectAndComputeAsync(img, mask); + expect(kp2.length, greaterThan(512)); + expect(desc.isEmpty, false); + + br.dispose(); + }); + + test('cv.FastFeatureDetectorAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final fd = await cv.FastFeatureDetectorAsync.emptyAsync(); + final kp = await fd.detectAsync(img); + expect(kp.length, greaterThan(2690)); + + final fd1 = await cv.FastFeatureDetectorAsync.createAsync(); + final kp1 = await fd1.detectAsync(img); + expect(kp1.length, greaterThan(2690)); + + fd.dispose(); + }); + + test('cv.GFTTDetectorAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final gf = await cv.GFTTDetectorAsync.emptyAsync(); + final kp = await gf.detectAsync(img); + expect(kp.length, greaterThan(512)); + + gf.dispose(); + }); + + test('cv.KAZEAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final ka = await cv.KAZEAsync.emptyAsync(); + final kp = await ka.detectAsync(img); + expect(kp.length, greaterThan(0)); + + final mask = cv.Mat.empty(); + final (kp2, desc) = await ka.detectAndComputeAsync(img, mask); + expect(kp2.length, greaterThan(0)); + expect(desc.isEmpty, false); + + ka.dispose(); + }); + + test('cv.MSERAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final gf = await cv.MSERAsync.emptyAsync(); + final kp = await gf.detectAsync(img); + expect(kp.length, greaterThan(0)); + + gf.dispose(); + }); + + test('cv.ORBAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final ka = await cv.ORBAsync.emptyAsync(); + final kp = await ka.detectAsync(img); + expect(kp.length, 500); + + final orb = await cv.ORBAsync.createAsync(); + final kp1 = await orb.detectAsync(img); + expect(kp1.length, 500); + + final mask = cv.Mat.empty(); + final (kp2, desc) = await ka.detectAndComputeAsync(img, mask); + expect(kp2.length, 500); + expect(desc.isEmpty, false); + + orb.dispose(); + }); + + test('cv.SimpleBlobDetectorAsync', () async { + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + expect(img.isEmpty, false); + + final detector = await cv.SimpleBlobDetectorAsync.emptyAsync(); + final kp = await detector.detectAsync(img); + expect(kp.length, 1); + + final params = cv.SimpleBlobDetectorParams( + blobColor: 200, + filterByArea: false, + filterByCircularity: true, + filterByConvexity: false, + filterByInertia: false, + filterByColor: false, + maxArea: 1000, + maxInertiaRatio: 0.97, + maxThreshold: 241, + maxCircularity: 0.99, + maxConvexity: 0.98, + minArea: 230, + minCircularity: 0.9, + minConvexity: 0.89, + minDistBetweenBlobs: 15.5, + minInertiaRatio: 0.8, + minRepeatability: 5, + minThreshold: 200, + thresholdStep: 2.0, + ); + + final params1 = cv.SimpleBlobDetectorParams.fromNative(params.ref); + expect(params1, params); + + expect(params.blobColor, 200); + params.blobColor = 201; + final blobColor = params.blobColor; + expect(blobColor, 201); + + expect(params.filterByArea, false); + params.filterByArea = true; + final filterByArea = params.filterByArea; + expect(filterByArea, true); + + expect(params.filterByCircularity, true); + params.filterByCircularity = false; + final filterByCircularity = params.filterByCircularity; + expect(filterByCircularity, false); + + expect(params.filterByColor, false); + params.filterByColor = true; + final filterByColor = params.filterByColor; + expect(filterByColor, true); + + expect(params.filterByConvexity, false); + params.filterByConvexity = true; + final filterByConvexity = params.filterByConvexity; + expect(filterByConvexity, true); + + expect(params.filterByInertia, false); + params.filterByInertia = true; + final filterByInertia = params.filterByInertia; + expect(filterByInertia, true); + + expect(params.maxArea, 1000); + params.maxArea = 2000; + final maxArea = params.maxArea; + expect(maxArea, 2000); + + expect(params.maxCircularity, closeTo(0.99, 1e-4)); + params.maxCircularity = 0.98; + final maxCircularity = params.maxCircularity; + expect(maxCircularity, closeTo(0.98, 1e-4)); + + expect(params.maxConvexity, closeTo(0.98, 1e-4)); + params.maxConvexity = 0.99; + final maxConvexity = params.maxConvexity; + expect(maxConvexity, closeTo(0.99, 1e-4)); + + expect(params.maxInertiaRatio, closeTo(0.97, 1e-4)); + params.maxInertiaRatio = 0.99; + final maxInertiaRatio = params.maxInertiaRatio; + expect(maxInertiaRatio, closeTo(0.99, 1e-4)); + + expect(params.maxThreshold, 241); + params.maxThreshold = 255; + final maxThreshold = params.maxThreshold; + expect(maxThreshold, 255); + + expect(params.minArea, 230); + params.minArea = 10; + final minArea = params.minArea; + expect(minArea, 10); + + expect(params.minCircularity, closeTo(0.9, 1e-4)); + params.minCircularity = 0.8; + final minCircularity = params.minCircularity; + expect(minCircularity, closeTo(0.8, 1e-4)); + + expect(params.minConvexity, closeTo(0.89, 1e-4)); + params.minConvexity = 0.8; + final minConvexity = params.minConvexity; + expect(minConvexity, closeTo(0.8, 1e-4)); + + expect(params.minDistBetweenBlobs, closeTo(15.5, 1e-4)); + params.minDistBetweenBlobs = 10; + final minDistBetweenBlobs = params.minDistBetweenBlobs; + expect(minDistBetweenBlobs, closeTo(10, 1e-4)); + + expect(params.minInertiaRatio, closeTo(0.8, 1e-4)); + params.minInertiaRatio = 0.7; + final minInertiaRatio = params.minInertiaRatio; + expect(minInertiaRatio, closeTo(0.7, 1e-4)); + + expect(params.minRepeatability, 5); + params.minRepeatability = 10; + final minRepeatability = params.minRepeatability; + expect(minRepeatability, 10); + + expect(params.minThreshold, 200); + params.minThreshold = 100; + final minThreshold = params.minThreshold; + expect(minThreshold, 100); + + expect(params.thresholdStep, closeTo(2.0, 1e-4)); + params.thresholdStep = 1.0; + final thresholdStep = params.thresholdStep; + expect(thresholdStep, closeTo(1.0, 1e-4)); + + final detector1 = await cv.SimpleBlobDetectorAsync.createAsync(params); + final kp1 = await detector1.detectAsync(img); + expect(kp1.length, 0); + + detector1.dispose(); + params.dispose(); + }); + + test('cv.BFMatcherAsync', () async { + final desc1 = await cv.imreadAsync( + "test/images/sift_descriptor.png", + flags: cv.IMREAD_GRAYSCALE, + ); + expect(desc1.isEmpty, false); + final desc2 = await cv.imreadAsync( + "test/images/sift_descriptor.png", + flags: cv.IMREAD_GRAYSCALE, + ); + expect(desc2.isEmpty, false); + + final matcher = await cv.BFMatcherAsync.emptyAsync(); + final dmatches = await matcher.knnMatchAsync(desc1, desc2, 2); + expect(dmatches.length, greaterThan(0)); + + final matcher1 = await cv.BFMatcherAsync.createAsync(); + final dmatches1 = await matcher1.knnMatchAsync(desc1, desc2, 2); + expect(dmatches1.length, greaterThan(0)); + + final matches = await matcher.matchAsync(desc1, desc2); + expect(matches.length, greaterThan(0)); + + matcher.dispose(); + }); + + test('cv.FlannBasedMatcherAsync', () async { + final desc1 = await cv.imreadAsync( + "test/images/sift_descriptor.png", + flags: cv.IMREAD_GRAYSCALE, + ); + expect(desc1.isEmpty, false); + final desc2 = await cv.imreadAsync( + "test/images/sift_descriptor.png", + flags: cv.IMREAD_GRAYSCALE, + ); + expect(desc2.isEmpty, false); + + final desc11 = desc1.convertTo(cv.MatType.CV_32FC1); + final desc21 = desc2.convertTo(cv.MatType.CV_32FC1); + + final matcher = await cv.FlannBasedMatcherAsync.emptyAsync(); + final dmatches = await matcher.knnMatchAsync(desc11, desc21, 2); + expect(dmatches.length, greaterThan(0)); + + matcher.dispose(); + }); + + test('cv.SIFTAsync', () async { + final img = await cv.imreadAsync( + "test/images/lenna.png", + flags: cv.IMREAD_GRAYSCALE, + ); + expect(img.isEmpty, false); + + final si = await cv.SIFTAsync.emptyAsync(); + final kp = await si.detectAsync(img); + expect(kp.length, greaterThan(0)); + + final mask = cv.Mat.empty(); + final (kp2, desc) = await si.detectAndComputeAsync(img, mask); + expect(kp2.length, greaterThan(0)); + expect(desc.isEmpty, false); + + si.dispose(); + }); + + test('cv.drawMatchesAsync', () async { + final query = await cv.imreadAsync("test/images/box.png", flags: cv.IMREAD_GRAYSCALE); + final train = await cv.imreadAsync( + "test/images/box_in_scene.png", + flags: cv.IMREAD_GRAYSCALE, + ); + expect(query.isEmpty, false); + expect(train.isEmpty, false); + + final m1 = cv.Mat.empty(), m2 = cv.Mat.empty(); + final (kp1, des1) = await (await cv.SIFTAsync.emptyAsync()).detectAndComputeAsync(query, m1); + final (kp2, des2) = await (await cv.SIFTAsync.emptyAsync()).detectAndComputeAsync(train, m2); + + final bf = await cv.BFMatcherAsync.emptyAsync(); + final dmatches = await bf.knnMatchAsync(des1, des2, 2); + expect(dmatches.length, greaterThan(0)); + + final out = cv.Mat.empty(); + await cv.drawMatchesAsync( + query, + kp1, + train, + kp2, + dmatches.first, + out, + matchColor: cv.Scalar.red, + singlePointColor: cv.Scalar.green, + ); + expect(out.cols, query.cols + train.cols); + + bf.dispose(); + }); +} diff --git a/test/features2d_test.dart b/test/features2d/features2d_test.dart similarity index 100% rename from test/features2d_test.dart rename to test/features2d/features2d_test.dart