From 6bbf8c7df2b21511fcab2c6de341bda29b21804a Mon Sep 17 00:00:00 2001 From: Abdelaziz Mahdy Date: Fri, 28 Jun 2024 14:44:43 +0300 Subject: [PATCH 01/10] c wrappers, and dart --- ffigen.yaml | 2 + lib/src/features2d/features2d.dart | 109 ++- lib/src/features2d/features2d_async.dart | 354 ++++++++ lib/src/opencv.g.dart | 1025 +++++++++++++++++++++- src/features2d/features2d_async.cpp | 421 +++++++++ src/features2d/features2d_async.h | 92 ++ 6 files changed, 1966 insertions(+), 37 deletions(-) create mode 100644 lib/src/features2d/features2d_async.dart create mode 100644 src/features2d/features2d_async.cpp create mode 100644 src/features2d/features2d_async.h diff --git a/ffigen.yaml b/ffigen.yaml index 2fef60f4..0ff6656c 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 @@ -58,6 +59,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/src/features2d/features2d.dart b/lib/src/features2d/features2d.dart index e0262c16..326baf36 100644 --- a/lib/src/features2d/features2d.dart +++ b/lib/src/features2d/features2d.dart @@ -22,6 +22,8 @@ class AKAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory AKAZE.fromPointer(cvg.AKAZEPtr ptr, [bool attach = true]) => + AKAZE._(ptr.cast(), attach); /// returns a new AKAZE algorithm /// @@ -50,11 +52,13 @@ 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); } - static final finalizer = OcvFinalizer(CFFI.addresses.AKAZE_Close); + static final finalizer = + OcvFinalizer(CFFI.addresses.AKAZE_Close); void dispose() { finalizer.detach(this); @@ -70,11 +74,15 @@ class AKAZE extends CvStruct { /// AgastFeatureDetector is a wrapper around the cv::AgastFeatureDetector. class AgastFeatureDetector extends CvStruct { - AgastFeatureDetector._(cvg.AgastFeatureDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { + AgastFeatureDetector._(cvg.AgastFeatureDetectorPtr ptr, [bool attach = true]) + : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } + factory AgastFeatureDetector.fromPointer(cvg.AgastFeatureDetectorPtr ptr, + [bool attach = true]) => + AgastFeatureDetector._(ptr.cast(), attach); /// returns a new AgastFeatureDetector algorithm /// @@ -96,8 +104,8 @@ 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 +126,8 @@ class BRISK extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory BRISK.fromPointer(cvg.BRISKPtr ptr, [bool attach = true]) => + BRISK._(ptr.cast(), attach); /// returns a new BRISK algorithm /// @@ -146,11 +156,13 @@ 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); } - static final finalizer = OcvFinalizer(CFFI.addresses.BRISK_Close); + static final finalizer = + OcvFinalizer(CFFI.addresses.BRISK_Close); void dispose() { finalizer.detach(this); @@ -180,11 +192,15 @@ enum FastFeatureDetectorType { /// FastFeatureDetector is a wrapper around the cv::FastFeatureDetector. class FastFeatureDetector extends CvStruct { - FastFeatureDetector._(cvg.FastFeatureDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { + FastFeatureDetector._(cvg.FastFeatureDetectorPtr ptr, [bool attach = true]) + : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } + factory FastFeatureDetector.fromPointer(cvg.FastFeatureDetectorPtr ptr, + [bool attach = true]) => + FastFeatureDetector._(ptr.cast(), attach); /// returns a new FastFeatureDetector algorithm /// @@ -227,7 +243,8 @@ 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); @@ -243,11 +260,15 @@ class FastFeatureDetector extends CvStruct { /// GFTTDetector is a wrapper around the cv::GFTTDetector. class GFTTDetector extends CvStruct { - GFTTDetector._(cvg.GFTTDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { + GFTTDetector._(cvg.GFTTDetectorPtr ptr, [bool attach = true]) + : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } + factory GFTTDetector.fromPointer(cvg.GFTTDetectorPtr ptr, + [bool attach = true]) => + GFTTDetector._(ptr.cast(), attach); /// returns a new GFTTDetector algorithm /// @@ -269,7 +290,8 @@ class GFTTDetector extends CvStruct { return VecKeyPoint.fromPointer(ret); } - static final finalizer = OcvFinalizer(CFFI.addresses.GFTTDetector_Close); + static final finalizer = + OcvFinalizer(CFFI.addresses.GFTTDetector_Close); void dispose() { finalizer.detach(this); @@ -290,6 +312,8 @@ class KAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory KAZE.fromPointer(cvg.KAZEPtr ptr, [bool attach = true]) => + KAZE._(ptr.cast(), attach); /// returns a new KAZE algorithm /// @@ -318,7 +342,8 @@ 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 +368,8 @@ class MSER extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory MSER.fromPointer(cvg.MSERPtr ptr, [bool attach = true]) => + MSER._(ptr.cast(), attach); /// returns a new MSER algorithm /// @@ -393,6 +420,8 @@ class ORB extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory ORB.fromPointer(cvg.ORBPtr ptr, [bool attach = true]) => + ORB._(ptr.cast(), attach); /// returns a new ORB algorithm /// @@ -454,7 +483,8 @@ 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,7 +503,8 @@ class ORB extends CvStruct { } class SimpleBlobDetectorParams extends CvStruct { - SimpleBlobDetectorParams._(ffi.Pointer ptr, [bool attach = true]) + SimpleBlobDetectorParams._(ffi.Pointer ptr, + [bool attach = true]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); @@ -510,7 +541,8 @@ 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 +554,8 @@ 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; @@ -531,7 +564,8 @@ class SimpleBlobDetectorParams extends CvStruct { return SimpleBlobDetectorParams._(p); } - factory SimpleBlobDetectorParams.fromNative(cvg.SimpleBlobDetectorParams r) => SimpleBlobDetectorParams( + factory SimpleBlobDetectorParams.fromNative(cvg.SimpleBlobDetectorParams r) => + SimpleBlobDetectorParams( blobColor: r.blobColor, filterByArea: r.filterByArea, filterByCircularity: r.filterByCircularity, @@ -685,12 +719,17 @@ class SimpleBlobDetectorParams extends CvStruct { /// SimpleBlobDetector is a wrapper around the cv::SimpleBlobDetector. class SimpleBlobDetector extends CvStruct { - SimpleBlobDetector._(cvg.SimpleBlobDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { + SimpleBlobDetector._(cvg.SimpleBlobDetectorPtr ptr, [bool attach = true]) + : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } + factory SimpleBlobDetector.fromPointer(cvg.SimpleBlobDetectorPtr ptr, + [bool attach = true]) => + SimpleBlobDetector._(ptr.cast(), attach); + /// returns a new SimpleBlobDetector algorithm /// /// For further details, please see: @@ -717,7 +756,8 @@ 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); @@ -733,11 +773,14 @@ class SimpleBlobDetector extends CvStruct { /// BFMatcher is a wrapper around the cv::BFMatcher. class BFMatcher extends CvStruct { - BFMatcher._(cvg.BFMatcherPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { + BFMatcher._(cvg.BFMatcherPtr ptr, [bool attach = true]) + : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } + factory BFMatcher.fromPointer(cvg.BFMatcherPtr ptr, [bool attach = true]) => + BFMatcher._(ptr.cast(), attach); /// returns a new BFMatcher algorithm /// @@ -775,7 +818,8 @@ class BFMatcher extends CvStruct { return VecVecDMatch.fromPointer(ret); } - static final finalizer = OcvFinalizer(CFFI.addresses.BFMatcher_Close); + static final finalizer = + OcvFinalizer(CFFI.addresses.BFMatcher_Close); void dispose() { finalizer.detach(this); @@ -791,11 +835,15 @@ class BFMatcher extends CvStruct { /// FlannBasedMatcher is a wrapper around the cv::FlannBasedMatcher. class FlannBasedMatcher extends CvStruct { - FlannBasedMatcher._(cvg.FlannBasedMatcherPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { + FlannBasedMatcher._(cvg.FlannBasedMatcherPtr ptr, [bool attach = true]) + : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } + factory FlannBasedMatcher.fromPointer(cvg.FlannBasedMatcherPtr ptr, + [bool attach = true]) => + FlannBasedMatcher._(ptr.cast(), attach); /// returns a new FlannBasedMatcher algorithm /// @@ -813,11 +861,13 @@ 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 +898,10 @@ 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 +911,8 @@ class SIFT extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } + factory SIFT.fromPointer(cvg.SIFTPtr ptr, [bool attach = true]) => + SIFT._(ptr.cast(), attach); /// returns a new SIFT algorithm /// @@ -887,7 +941,8 @@ 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); } diff --git a/lib/src/features2d/features2d_async.dart b/lib/src/features2d/features2d_async.dart new file mode 100644 index 00000000..10dacd4e --- /dev/null +++ b/lib/src/features2d/features2d_async.dart @@ -0,0 +1,354 @@ +library cv; + +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import '../core/base.dart'; +import '../core/mat.dart'; +import '../core/vec.dart'; +import '../opencv.g.dart' as cvg; +import './features2d.dart'; +import 'package:ffi/ffi.dart'; + +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; + +extension AKAZEAsync on AKAZE { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.AKAZE_Create_Async(callback), + (c, p) => c.complete(AKAZE.fromPointer(p.cast()))); + + 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; + } + + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { + final desc = Mat.empty(); + final rval = cvRunAsync<(VecKeyPoint, Mat)>( + (callback) => CFFI.AKAZE_DetectAndCompute_Async( + ref, src.ref, mask.ref, desc.ref, callback), + (c, keypoints) => c.complete(( + VecKeyPoint.fromPointer(keypoints.cast()), + desc + ))); + return rval; + } +} + +extension AgastFeatureDetectorAsync on AgastFeatureDetector { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.AgastFeatureDetector_Create_Async(callback), + (c, p) => c.complete(AgastFeatureDetector.fromPointer( + p.cast()))); + + 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 { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.BRISK_Create_Async(callback), + (c, p) => c.complete(BRISK.fromPointer(p.cast()))); + + 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; + } + + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { + final desc = Mat.empty(); + final rval = cvRunAsync<(VecKeyPoint, Mat)>( + (callback) => CFFI.BRISK_DetectAndCompute_Async( + ref, src.ref, mask.ref, desc.ref, callback), + (c, keypoints) => c.complete(( + VecKeyPoint.fromPointer(keypoints.cast()), + desc + ))); + return rval; + } +} + +extension FastFeatureDetectorAsync on FastFeatureDetector { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.FastFeatureDetector_Create_Async(callback), + (c, p) => c.complete( + FastFeatureDetector.fromPointer(p.cast()))); + + static Future createAsync(int threshold, + bool nonmaxSuppression, FastFeatureDetectorType type) async => + cvRunAsync( + (callback) => CFFI.FastFeatureDetector_CreateWithParams_Async( + threshold, nonmaxSuppression, type.value, callback), + (c, p) => c.complete(FastFeatureDetector.fromPointer( + p.cast()))); + + 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 { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.GFTTDetector_Create_Async(callback), + (c, p) => + c.complete(GFTTDetector.fromPointer(p.cast()))); + + 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 { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.KAZE_Create_Async(callback), + (c, p) => c.complete(KAZE.fromPointer(p.cast()))); + + 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; + } + + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { + final desc = Mat.empty(); + final rval = cvRunAsync<(VecKeyPoint, Mat)>( + (callback) => CFFI.KAZE_DetectAndCompute_Async( + ref, src.ref, mask.ref, desc.ref, callback), + (c, keypoints) => c.complete(( + VecKeyPoint.fromPointer(keypoints.cast()), + desc + ))); + return rval; + } +} + +extension MSERAsync on MSER { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.MSER_Create_Async(callback), + (c, p) => c.complete(MSER.fromPointer(p.cast()))); + + 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 { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.ORB_Create_Async(callback), + (c, p) => c.complete(ORB.fromPointer(p.cast()))); + + static Future createAsync( + int nFeatures, + double scaleFactor, + int nLevels, + int edgeThreshold, + int firstLevel, + int WTA_K, + ORBScoreType scoreType, + int patchSize, + int fastThreshold) 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()))); + + 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; + } + + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { + final desc = Mat.empty(); + final rval = cvRunAsync<(VecKeyPoint, Mat)>( + (callback) => CFFI.ORB_DetectAndCompute_Async( + ref, src.ref, mask.ref, desc.ref, callback), + (c, keypoints) => c.complete(( + VecKeyPoint.fromPointer(keypoints.cast()), + desc + ))); + return rval; + } +} + +extension SimpleBlobDetectorAsync on SimpleBlobDetector { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.SimpleBlobDetector_Create_Async(callback), + (c, p) => c.complete( + SimpleBlobDetector.fromPointer(p.cast()))); + + static Future createWithParamsAsync( + SimpleBlobDetectorParams params) async => + cvRunAsync( + (callback) => CFFI.SimpleBlobDetector_Create_WithParams_Async( + params.ref, callback), + (c, p) => c.complete(SimpleBlobDetector.fromPointer( + p.cast()))); + + 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 { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.BFMatcher_Create_Async(callback), + (c, p) => c.complete(BFMatcher.fromPointer(p.cast()))); + + static Future createAsync(int type, bool crossCheck) async => + cvRunAsync( + (callback) => + CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), + (c, p) => c.complete(BFMatcher.fromPointer(p.cast()))); + + 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; + } + + 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 { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.FlannBasedMatcher_Create_Async(callback), + (c, p) => c.complete( + FlannBasedMatcher.fromPointer(p.cast()))); + + 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 { + static Future emptyNewAsync() async => cvRunAsync( + (callback) => CFFI.SIFT_Create_Async(callback), + (c, p) => c.complete(SIFT.fromPointer(p.cast()))); + + 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; + } + + Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { + final desc = Mat.empty(); + final rval = cvRunAsync<(VecKeyPoint, Mat)>( + (callback) => CFFI.SIFT_DetectAndCompute_Async( + ref, src.ref, mask.ref, desc.ref, callback), + ( + c, + keypoints, + ) => + c.complete(( + VecKeyPoint.fromPointer(keypoints.cast()), + desc + ))); + return rval; + } +} + +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()); +} + +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.fromList([]); + 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 fa6640b9..f13ffcec 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 a, + CvCallback_0 callback, + ) { + return _AKAZE_Close_Async( + a, + 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,49 @@ class CvNative { ffi.Pointer Function( AKAZE, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer AKAZE_DetectAndCompute_Async( + AKAZE a, + Mat src, + Mat mask, + Mat desc, + CvCallback_1 callback, + ) { + return _AKAZE_DetectAndCompute_Async( + a, + src, + mask, + desc, + callback, + ); + } + + late final _AKAZE_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(AKAZE, Mat, Mat, Mat, + CvCallback_1)>>('AKAZE_DetectAndCompute_Async'); + late final _AKAZE_DetectAndCompute_Async = + _AKAZE_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(AKAZE, Mat, Mat, Mat, CvCallback_1)>(); + + ffi.Pointer AKAZE_Detect_Async( + AKAZE a, + Mat src, + CvCallback_1 callback, + ) { + return _AKAZE_Detect_Async( + a, + 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 +242,25 @@ class CvNative { late final _AgastFeatureDetector_Close = _AgastFeatureDetector_ClosePtr .asFunction(); + ffi.Pointer AgastFeatureDetector_Close_Async( + AgastFeatureDetectorPtr a, + CvCallback_0 callback, + ) { + return _AgastFeatureDetector_Close_Async( + a, + 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 +278,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 +314,27 @@ class CvNative { ffi.Pointer Function( AgastFeatureDetector, Mat, ffi.Pointer)>(); + ffi.Pointer AgastFeatureDetector_Detect_Async( + AgastFeatureDetector a, + Mat src, + CvCallback_1 callback, + ) { + return _AgastFeatureDetector_Detect_Async( + a, + 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, ) { @@ -1872,6 +2001,23 @@ class CvNative { late final _BFMatcher_Close = _BFMatcher_ClosePtr.asFunction(); + ffi.Pointer BFMatcher_Close_Async( + BFMatcherPtr b, + CvCallback_0 callback, + ) { + return _BFMatcher_Close_Async( + b, + 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, ) { @@ -1907,6 +2053,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, @@ -1931,6 +2111,31 @@ class CvNative { ffi.Pointer Function( BFMatcher, Mat, Mat, int, ffi.Pointer)>(); + ffi.Pointer BFMatcher_KnnMatch_Async( + BFMatcher b, + Mat query, + Mat train, + int k, + CvCallback_1 callback, + ) { + return _BFMatcher_KnnMatch_Async( + b, + 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, @@ -1953,6 +2158,27 @@ class CvNative { ffi.Pointer Function( BFMatcher, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer BFMatcher_Match_Async( + BFMatcher b, + Mat query, + Mat train, + CvCallback_1 callback, + ) { + return _BFMatcher_Match_Async( + b, + 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, ) { @@ -1966,6 +2192,23 @@ class CvNative { late final _BRISK_Close = _BRISK_ClosePtr.asFunction(); + ffi.Pointer BRISK_Close_Async( + BRISKPtr b, + CvCallback_0 callback, + ) { + return _BRISK_Close_Async( + b, + 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, ) { @@ -1980,6 +2223,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, @@ -2023,6 +2280,49 @@ class CvNative { ffi.Pointer Function( BRISK, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer BRISK_DetectAndCompute_Async( + BRISK b, + Mat src, + Mat mask, + Mat desc, + CvCallback_1 callback, + ) { + return _BRISK_DetectAndCompute_Async( + b, + src, + mask, + desc, + callback, + ); + } + + late final _BRISK_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(BRISK, Mat, Mat, Mat, + CvCallback_1)>>('BRISK_DetectAndCompute_Async'); + late final _BRISK_DetectAndCompute_Async = + _BRISK_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(BRISK, Mat, Mat, Mat, CvCallback_1)>(); + + ffi.Pointer BRISK_Detect_Async( + BRISK b, + Mat src, + CvCallback_1 callback, + ) { + return _BRISK_Detect_Async( + b, + 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, @@ -4557,6 +4857,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, @@ -4600,6 +4926,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, @@ -5820,6 +6192,25 @@ class CvNative { late final _FastFeatureDetector_Close = _FastFeatureDetector_ClosePtr .asFunction(); + ffi.Pointer FastFeatureDetector_Close_Async( + FastFeatureDetectorPtr f, + CvCallback_0 callback, + ) { + return _FastFeatureDetector_Close_Async( + f, + 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, ) { @@ -5860,6 +6251,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, @@ -5881,6 +6309,27 @@ class CvNative { ffi.Pointer Function( FastFeatureDetector, Mat, ffi.Pointer)>(); + ffi.Pointer FastFeatureDetector_Detect_Async( + FastFeatureDetector f, + Mat src, + CvCallback_1 callback, + ) { + return _FastFeatureDetector_Detect_Async( + f, + 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, @@ -6585,6 +7034,24 @@ class CvNative { late final _FlannBasedMatcher_Close = _FlannBasedMatcher_ClosePtr.asFunction< void Function(FlannBasedMatcherPtr)>(); + ffi.Pointer FlannBasedMatcher_Close_Async( + FlannBasedMatcherPtr f, + CvCallback_0 callback, + ) { + return _FlannBasedMatcher_Close_Async( + f, + 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, ) { @@ -6601,6 +7068,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, @@ -6626,6 +7108,31 @@ class CvNative { ffi.Pointer Function( FlannBasedMatcher, Mat, Mat, int, ffi.Pointer)>(); + ffi.Pointer FlannBasedMatcher_KnnMatch_Async( + FlannBasedMatcher f, + Mat query, + Mat train, + int k, + CvCallback_1 callback, + ) { + return _FlannBasedMatcher_KnnMatch_Async( + f, + 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, @@ -6812,6 +7319,24 @@ class CvNative { late final _GFTTDetector_Close = _GFTTDetector_ClosePtr.asFunction(); + ffi.Pointer GFTTDetector_Close_Async( + GFTTDetectorPtr a, + CvCallback_0 callback, + ) { + return _GFTTDetector_Close_Async( + a, + 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, ) { @@ -6827,6 +7352,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, @@ -6847,6 +7386,26 @@ class CvNative { ffi.Pointer Function( GFTTDetector, Mat, ffi.Pointer)>(); + ffi.Pointer GFTTDetector_Detect_Async( + GFTTDetector a, + Mat src, + CvCallback_1 callback, + ) { + return _GFTTDetector_Detect_Async( + a, + 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, @@ -9166,6 +9725,23 @@ class CvNative { _lookup>('KAZE_Close'); late final _KAZE_Close = _KAZE_ClosePtr.asFunction(); + ffi.Pointer KAZE_Close_Async( + KAZEPtr a, + CvCallback_0 callback, + ) { + return _KAZE_Close_Async( + a, + 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, ) { @@ -9180,6 +9756,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, @@ -9206,22 +9796,65 @@ class CvNative { Mat desc, ffi.Pointer rval, ) { - return _KAZE_DetectAndCompute( + return _KAZE_DetectAndCompute( + a, + src, + mask, + desc, + rval, + ); + } + + late final _KAZE_DetectAndComputePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(KAZE, Mat, Mat, Mat, + ffi.Pointer)>>('KAZE_DetectAndCompute'); + late final _KAZE_DetectAndCompute = _KAZE_DetectAndComputePtr.asFunction< + ffi.Pointer Function( + KAZE, Mat, Mat, Mat, ffi.Pointer)>(); + + ffi.Pointer KAZE_DetectAndCompute_Async( + KAZE a, + Mat src, + Mat mask, + Mat desc, + CvCallback_1 callback, + ) { + return _KAZE_DetectAndCompute_Async( + a, + src, + mask, + desc, + callback, + ); + } + + late final _KAZE_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(KAZE, Mat, Mat, Mat, + CvCallback_1)>>('KAZE_DetectAndCompute_Async'); + late final _KAZE_DetectAndCompute_Async = + _KAZE_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(KAZE, Mat, Mat, Mat, CvCallback_1)>(); + + ffi.Pointer KAZE_Detect_Async( + KAZE a, + Mat src, + CvCallback_1 callback, + ) { + return _KAZE_Detect_Async( a, src, - mask, - desc, - rval, + callback, ); } - late final _KAZE_DetectAndComputePtr = _lookup< + late final _KAZE_Detect_AsyncPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(KAZE, Mat, Mat, Mat, - ffi.Pointer)>>('KAZE_DetectAndCompute'); - late final _KAZE_DetectAndCompute = _KAZE_DetectAndComputePtr.asFunction< - ffi.Pointer Function( - KAZE, Mat, Mat, Mat, ffi.Pointer)>(); + 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, @@ -10277,6 +10910,23 @@ class CvNative { _lookup>('MSER_Close'); late final _MSER_Close = _MSER_ClosePtr.asFunction(); + ffi.Pointer MSER_Close_Async( + MSERPtr a, + CvCallback_0 callback, + ) { + return _MSER_Close_Async( + a, + 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, ) { @@ -10291,6 +10941,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, @@ -10310,6 +10974,25 @@ class CvNative { late final _MSER_Detect = _MSER_DetectPtr.asFunction< ffi.Pointer Function(MSER, Mat, ffi.Pointer)>(); + ffi.Pointer MSER_Detect_Async( + MSER a, + Mat src, + CvCallback_1 callback, + ) { + return _MSER_Detect_Async( + a, + 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, @@ -17244,6 +17927,23 @@ class CvNative { _lookup>('ORB_Close'); late final _ORB_Close = _ORB_ClosePtr.asFunction(); + ffi.Pointer ORB_Close_Async( + ORBPtr o, + CvCallback_0 callback, + ) { + return _ORB_Close_Async( + o, + 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, ) { @@ -17301,6 +18001,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, @@ -17344,6 +18102,49 @@ class CvNative { ffi.Pointer Function( ORB, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer ORB_DetectAndCompute_Async( + ORB o, + Mat src, + Mat mask, + Mat desc, + CvCallback_1 callback, + ) { + return _ORB_DetectAndCompute_Async( + o, + src, + mask, + desc, + callback, + ); + } + + late final _ORB_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ORB, Mat, Mat, Mat, CvCallback_1)>>('ORB_DetectAndCompute_Async'); + late final _ORB_DetectAndCompute_Async = + _ORB_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(ORB, Mat, Mat, Mat, CvCallback_1)>(); + + ffi.Pointer ORB_Detect_Async( + ORB o, + Mat src, + CvCallback_1 callback, + ) { + return _ORB_Detect_Async( + o, + 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, @@ -19012,6 +19813,23 @@ class CvNative { _lookup>('SIFT_Close'); late final _SIFT_Close = _SIFT_ClosePtr.asFunction(); + ffi.Pointer SIFT_Close_Async( + SIFTPtr f, + CvCallback_0 callback, + ) { + return _SIFT_Close_Async( + f, + 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, ) { @@ -19026,6 +19844,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, @@ -19069,6 +19901,49 @@ class CvNative { ffi.Pointer Function( SIFT, Mat, Mat, Mat, ffi.Pointer)>(); + ffi.Pointer SIFT_DetectAndCompute_Async( + SIFT f, + Mat src, + Mat mask, + Mat desc, + CvCallback_1 callback, + ) { + return _SIFT_DetectAndCompute_Async( + f, + src, + mask, + desc, + callback, + ); + } + + late final _SIFT_DetectAndCompute_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(SIFT, Mat, Mat, Mat, + CvCallback_1)>>('SIFT_DetectAndCompute_Async'); + late final _SIFT_DetectAndCompute_Async = + _SIFT_DetectAndCompute_AsyncPtr.asFunction< + ffi.Pointer Function(SIFT, Mat, Mat, Mat, CvCallback_1)>(); + + ffi.Pointer SIFT_Detect_Async( + SIFT f, + Mat src, + CvCallback_1 callback, + ) { + return _SIFT_Detect_Async( + f, + 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, @@ -19363,6 +20238,25 @@ class CvNative { late final _SimpleBlobDetector_Close = _SimpleBlobDetector_ClosePtr .asFunction(); + ffi.Pointer SimpleBlobDetector_Close_Async( + SimpleBlobDetectorPtr b, + CvCallback_0 callback, + ) { + return _SimpleBlobDetector_Close_Async( + b, + 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, ) { @@ -19379,6 +20273,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, @@ -19399,6 +20308,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, @@ -19420,6 +20348,27 @@ class CvNative { ffi.Pointer Function( SimpleBlobDetector, Mat, ffi.Pointer)>(); + ffi.Pointer SimpleBlobDetector_Detect_Async( + SimpleBlobDetector b, + Mat src, + CvCallback_1 callback, + ) { + return _SimpleBlobDetector_Detect_Async( + b, + 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, @@ -27968,8 +28917,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> @@ -27983,8 +28942,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; @@ -28008,14 +28975,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> @@ -28024,6 +29011,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)>> @@ -28036,14 +29027,28 @@ 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< + ffi.NativeFunction< + ffi.Pointer Function( + SimpleBlobDetectorPtr, CvCallback_0)>> + get SimpleBlobDetector_Close_Async => + _library._SimpleBlobDetector_Close_AsyncPtr; ffi.Pointer> get Stitcher_Close => _library._Stitcher_ClosePtr; ffi.Pointer> diff --git a/src/features2d/features2d_async.cpp b/src/features2d/features2d_async.cpp new file mode 100644 index 00000000..43a57f56 --- /dev/null +++ b/src/features2d/features2d_async.cpp @@ -0,0 +1,421 @@ +/* Created by Rainyl. Licensed: Apache 2.0 license. Copyright (c) 2024 Rainyl. */ +#include "features2d_async.h" +#include "features2d.cpp" + +#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 a, CvCallback_0 callback) +{ + BEGIN_WRAP + a->ptr->reset(); + CVD_FREE(a); + callback(); + END_WRAP +} + +CvStatus *AKAZE_Detect_Async(AKAZE a, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*a.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *AKAZE_DetectAndCompute_Async(AKAZE a, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*a.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); + callback(new VecKeyPoint{new std::vector(detected)}); + 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 a, CvCallback_0 callback) +{ + BEGIN_WRAP + a->ptr->reset(); + CVD_FREE(a); + callback(); + END_WRAP +} + +CvStatus *AgastFeatureDetector_Detect_Async(AgastFeatureDetector a, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*a.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 b, CvCallback_0 callback) +{ + BEGIN_WRAP + b->ptr->reset(); + CVD_FREE(b); + callback(); + END_WRAP +} + +CvStatus *BRISK_Detect_Async(BRISK b, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*b.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *BRISK_DetectAndCompute_Async(BRISK b, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*b.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); + callback(new VecKeyPoint{new std::vector(detected)}); + 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 f, CvCallback_0 callback) +{ + BEGIN_WRAP + f->ptr->reset(); + CVD_FREE(f); + callback(); + END_WRAP +} + +CvStatus *FastFeatureDetector_Detect_Async(FastFeatureDetector f, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*f.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 a, CvCallback_0 callback) +{ + BEGIN_WRAP + a->ptr->reset(); + CVD_FREE(a); + callback(); + END_WRAP +} + +CvStatus *GFTTDetector_Detect_Async(GFTTDetector a, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*a.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 a, CvCallback_0 callback) +{ + BEGIN_WRAP + a->ptr->reset(); + CVD_FREE(a); + callback(); + END_WRAP +} + +CvStatus *KAZE_Detect_Async(KAZE a, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*a.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *KAZE_DetectAndCompute_Async(KAZE a, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*a.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); + callback(new VecKeyPoint{new std::vector(detected)}); + 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 a, CvCallback_0 callback) +{ + BEGIN_WRAP + a->ptr->reset(); + CVD_FREE(a); + callback(); + END_WRAP +} + +CvStatus *MSER_Detect_Async(MSER a, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*a.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 o, CvCallback_0 callback) +{ + BEGIN_WRAP + o->ptr->reset(); + CVD_FREE(o); + callback(); + END_WRAP +} + +CvStatus *ORB_Detect_Async(ORB o, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*o.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *ORB_DetectAndCompute_Async(ORB o, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*o.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); + callback(new VecKeyPoint{new std::vector(detected)}); + 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 b, CvCallback_0 callback) +{ + BEGIN_WRAP + b->ptr->reset(); + CVD_FREE(b); + callback(); + END_WRAP +} + +CvStatus *SimpleBlobDetector_Detect_Async(SimpleBlobDetector b, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*b.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 b, CvCallback_0 callback) +{ + BEGIN_WRAP + b->ptr->reset(); + CVD_FREE(b); + callback(); + END_WRAP +} + +CvStatus *BFMatcher_Match_Async(BFMatcher b, Mat query, Mat train, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector matches; + (*b.ptr)->match(*query.ptr, *train.ptr, matches); + callback(new VecDMatch{new std::vector(matches)}); + END_WRAP +} + +CvStatus *BFMatcher_KnnMatch_Async(BFMatcher b, Mat query, Mat train, int k, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector> matches; + (*b.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 f, CvCallback_0 callback) +{ + BEGIN_WRAP + f->ptr->reset(); + CVD_FREE(f); + callback(); + END_WRAP +} + +CvStatus *FlannBasedMatcher_KnnMatch_Async(FlannBasedMatcher f, Mat query, Mat train, int k, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector> matches; + (*f.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 f, CvCallback_0 callback) +{ + BEGIN_WRAP + f->ptr->reset(); + CVD_FREE(f); + callback(); + END_WRAP +} + +CvStatus *SIFT_Detect_Async(SIFT f, Mat src, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*f.ptr)->detect(*src.ptr, detected); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} + +CvStatus *SIFT_DetectAndCompute_Async(SIFT f, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +{ + BEGIN_WRAP + std::vector detected; + (*f.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); + callback(new VecKeyPoint{new std::vector(detected)}); + END_WRAP +} diff --git a/src/features2d/features2d_async.h b/src/features2d/features2d_async.h new file mode 100644 index 00000000..c281c3d6 --- /dev/null +++ b/src/features2d/features2d_async.h @@ -0,0 +1,92 @@ +/* Created by Rainyl. Licensed: Apache 2.0 license. Copyright (c) 2024 Rainyl. */ +#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 a, CvCallback_0 callback); +CvStatus *AKAZE_Detect_Async(AKAZE a, Mat src, CvCallback_1 callback); +CvStatus *AKAZE_DetectAndCompute_Async(AKAZE a, Mat src, Mat mask, Mat desc, CvCallback_1 callback); + +// AgastFeatureDetector +CvStatus *AgastFeatureDetector_Create_Async(CvCallback_1 callback); +CvStatus *AgastFeatureDetector_Close_Async(AgastFeatureDetectorPtr a, CvCallback_0 callback); +CvStatus *AgastFeatureDetector_Detect_Async(AgastFeatureDetector a, Mat src, CvCallback_1 callback); + +// BRISK +CvStatus *BRISK_Create_Async(CvCallback_1 callback); +CvStatus *BRISK_Close_Async(BRISKPtr b, CvCallback_0 callback); +CvStatus *BRISK_Detect_Async(BRISK b, Mat src, CvCallback_1 callback); +CvStatus *BRISK_DetectAndCompute_Async(BRISK b, Mat src, Mat mask, Mat desc, CvCallback_1 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 f, CvCallback_0 callback); +CvStatus *FastFeatureDetector_Detect_Async(FastFeatureDetector f, Mat src, CvCallback_1 callback); + +// GFTTDetector +CvStatus *GFTTDetector_Create_Async(CvCallback_1 callback); +CvStatus *GFTTDetector_Close_Async(GFTTDetectorPtr a, CvCallback_0 callback); +CvStatus *GFTTDetector_Detect_Async(GFTTDetector a, Mat src, CvCallback_1 callback); + +// KAZE +CvStatus *KAZE_Create_Async(CvCallback_1 callback); +CvStatus *KAZE_Close_Async(KAZEPtr a, CvCallback_0 callback); +CvStatus *KAZE_Detect_Async(KAZE a, Mat src, CvCallback_1 callback); +CvStatus *KAZE_DetectAndCompute_Async(KAZE a, Mat src, Mat mask, Mat desc, CvCallback_1 callback); + +// MSER +CvStatus *MSER_Create_Async(CvCallback_1 callback); +CvStatus *MSER_Close_Async(MSERPtr a, CvCallback_0 callback); +CvStatus *MSER_Detect_Async(MSER a, 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 o, CvCallback_0 callback); +CvStatus *ORB_Detect_Async(ORB o, Mat src, CvCallback_1 callback); +CvStatus *ORB_DetectAndCompute_Async(ORB o, Mat src, Mat mask, Mat desc, CvCallback_1 callback); + +// SimpleBlobDetector +CvStatus *SimpleBlobDetector_Create_Async(CvCallback_1 callback); +CvStatus *SimpleBlobDetector_Create_WithParams_Async(SimpleBlobDetectorParams params, CvCallback_1 callback); +CvStatus *SimpleBlobDetector_Close_Async(SimpleBlobDetectorPtr b, CvCallback_0 callback); +CvStatus *SimpleBlobDetector_Detect_Async(SimpleBlobDetector b, 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 b, CvCallback_0 callback); +CvStatus *BFMatcher_Match_Async(BFMatcher b, Mat query, Mat train, CvCallback_1 callback); +CvStatus *BFMatcher_KnnMatch_Async(BFMatcher b, Mat query, Mat train, int k, CvCallback_1 callback); + +// FlannBasedMatcher +CvStatus *FlannBasedMatcher_Create_Async(CvCallback_1 callback); +CvStatus *FlannBasedMatcher_Close_Async(FlannBasedMatcherPtr f, CvCallback_0 callback); +CvStatus *FlannBasedMatcher_KnnMatch_Async(FlannBasedMatcher f, 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 f, CvCallback_0 callback); +CvStatus *SIFT_Detect_Async(SIFT f, Mat src, CvCallback_1 callback); +CvStatus *SIFT_DetectAndCompute_Async(SIFT f, Mat src, Mat mask, Mat desc, CvCallback_1 callback); + +#ifdef __cplusplus +} +#endif + +#endif // CVD_FEATURES2D_ASYNC_H_ From 90ce41ae1c9c6a407986a47d088c677fd30847e1 Mon Sep 17 00:00:00 2001 From: Abdelaziz Mahdy Date: Fri, 28 Jun 2024 14:45:38 +0300 Subject: [PATCH 02/10] general cleaning --- lib/src/dnn/dnn_async.dart | 7 +- lib/src/features2d/features2d.dart | 42 +++---- lib/src/features2d/features2d_async.dart | 145 +++++++++++------------ lib/src/objdetect/objdetect_async.dart | 20 ++-- 4 files changed, 104 insertions(+), 110 deletions(-) diff --git a/lib/src/dnn/dnn_async.dart b/lib/src/dnn/dnn_async.dart index a8d6c008..7159390e 100644 --- a/lib/src/dnn/dnn_async.dart +++ b/lib/src/dnn/dnn_async.dart @@ -2,8 +2,8 @@ library cv; import 'dart:ffi' as ffi; import 'dart:typed_data'; + import 'package:ffi/ffi.dart'; -import './dnn.dart'; import '../core/base.dart'; import '../core/mat.dart'; @@ -13,6 +13,7 @@ import '../core/scalar.dart'; import '../core/size.dart'; import '../core/vec.dart'; import '../opencv.g.dart' as cvg; +import './dnn.dart'; extension LayerAsync on Layer { Future get nameAsync async { @@ -94,7 +95,7 @@ extension NetAsync on Net { } static Future fromBytesAsync(String framework, Uint8List bufferModel, - {Uint8List? bufferConfig}) async { + {Uint8List? bufferConfig,}) async { bufferConfig ??= Uint8List(0); final cFramework = framework.toNativeUtf8().cast(); final bufM = VecUChar.fromList(bufferModel); @@ -302,7 +303,7 @@ extension NetAsync on Net { final rval = cvRunAsync2<(VecFloat, VecInt)>( (callback) => CFFI.Net_GetInputDetails_Async(ref, callback), (c, sc, zp) => c.complete( - (VecFloat.fromPointer(sc.cast()), VecInt.fromPointer(zp.cast()))), + (VecFloat.fromPointer(sc.cast()), VecInt.fromPointer(zp.cast())),), ); return rval; } diff --git a/lib/src/features2d/features2d.dart b/lib/src/features2d/features2d.dart index 326baf36..8a4283ab 100644 --- a/lib/src/features2d/features2d.dart +++ b/lib/src/features2d/features2d.dart @@ -53,7 +53,7 @@ class AKAZE extends CvStruct { final desc = Mat.empty(); final ret = calloc(); cvRun(() => - CFFI.AKAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + CFFI.AKAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret),); return (VecKeyPoint.fromPointer(ret), desc); } @@ -81,7 +81,7 @@ class AgastFeatureDetector extends CvStruct { } } factory AgastFeatureDetector.fromPointer(cvg.AgastFeatureDetectorPtr ptr, - [bool attach = true]) => + [bool attach = true,]) => AgastFeatureDetector._(ptr.cast(), attach); /// returns a new AgastFeatureDetector algorithm @@ -105,7 +105,7 @@ class AgastFeatureDetector extends CvStruct { } static final finalizer = OcvFinalizer( - CFFI.addresses.AgastFeatureDetector_Close); + CFFI.addresses.AgastFeatureDetector_Close,); void dispose() { finalizer.detach(this); @@ -157,7 +157,7 @@ class BRISK extends CvStruct { final desc = Mat.empty(); final ret = calloc(); cvRun(() => - CFFI.BRISK_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + CFFI.BRISK_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret),); return (VecKeyPoint.fromPointer(ret), desc); } @@ -199,7 +199,7 @@ class FastFeatureDetector extends CvStruct { } } factory FastFeatureDetector.fromPointer(cvg.FastFeatureDetectorPtr ptr, - [bool attach = true]) => + [bool attach = true,]) => FastFeatureDetector._(ptr.cast(), attach); /// returns a new FastFeatureDetector algorithm @@ -244,7 +244,7 @@ class FastFeatureDetector extends CvStruct { } static final finalizer = OcvFinalizer( - CFFI.addresses.FastFeatureDetector_Close); + CFFI.addresses.FastFeatureDetector_Close,); void dispose() { finalizer.detach(this); @@ -267,7 +267,7 @@ class GFTTDetector extends CvStruct { } } factory GFTTDetector.fromPointer(cvg.GFTTDetectorPtr ptr, - [bool attach = true]) => + [bool attach = true,]) => GFTTDetector._(ptr.cast(), attach); /// returns a new GFTTDetector algorithm @@ -343,7 +343,7 @@ class KAZE extends CvStruct { final desc = Mat.empty(); final ret = calloc(); cvRun(() => - CFFI.KAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + CFFI.KAZE_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret),); return (VecKeyPoint.fromPointer(ret), desc); } @@ -484,7 +484,7 @@ class ORB extends CvStruct { final desc = Mat.empty(); final ret = calloc(); cvRun(() => - CFFI.ORB_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + CFFI.ORB_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret),); return (VecKeyPoint.fromPointer(ret), desc); } @@ -504,7 +504,7 @@ class ORB extends CvStruct { class SimpleBlobDetectorParams extends CvStruct { SimpleBlobDetectorParams._(ffi.Pointer ptr, - [bool attach = true]) + [bool attach = true,]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); @@ -541,8 +541,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) + 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; @@ -554,8 +555,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) + 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; @@ -727,7 +729,7 @@ class SimpleBlobDetector extends CvStruct { } factory SimpleBlobDetector.fromPointer(cvg.SimpleBlobDetectorPtr ptr, - [bool attach = true]) => + [bool attach = true,]) => SimpleBlobDetector._(ptr.cast(), attach); /// returns a new SimpleBlobDetector algorithm @@ -757,7 +759,7 @@ class SimpleBlobDetector extends CvStruct { } static final finalizer = OcvFinalizer( - CFFI.addresses.SimpleBlobDetector_Close); + CFFI.addresses.SimpleBlobDetector_Close,); void dispose() { finalizer.detach(this); @@ -842,7 +844,7 @@ class FlannBasedMatcher extends CvStruct { } } factory FlannBasedMatcher.fromPointer(cvg.FlannBasedMatcherPtr ptr, - [bool attach = true]) => + [bool attach = true,]) => FlannBasedMatcher._(ptr.cast(), attach); /// returns a new FlannBasedMatcher algorithm @@ -862,12 +864,12 @@ class FlannBasedMatcher extends CvStruct { VecVecDMatch knnMatch(Mat query, Mat train, int k) { final ret = calloc(); cvRun(() => - CFFI.FlannBasedMatcher_KnnMatch(ptr.ref, query.ref, train.ref, k, ret)); + CFFI.FlannBasedMatcher_KnnMatch(ptr.ref, query.ref, train.ref, k, ret),); return VecVecDMatch.fromPointer(ret); } static final finalizer = OcvFinalizer( - CFFI.addresses.FlannBasedMatcher_Close); + CFFI.addresses.FlannBasedMatcher_Close,); void dispose() { finalizer.detach(this); @@ -899,9 +901,9 @@ enum DrawMatchesFlag { } void drawKeyPoints(Mat src, VecKeyPoint keypoints, Mat dst, Scalar color, - DrawMatchesFlag flag) { + DrawMatchesFlag flag,) { cvRun(() => CFFI.DrawKeyPoints( - src.ref, keypoints.ref, dst.ref, color.ref, flag.value)); + src.ref, keypoints.ref, dst.ref, color.ref, flag.value,),); } /// SIFT is a wrapper around the cv::SIFT. @@ -942,7 +944,7 @@ class SIFT extends CvStruct { final desc = Mat.empty(); final ret = calloc(); cvRun(() => - CFFI.SIFT_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret)); + CFFI.SIFT_DetectAndCompute(ptr.ref, src.ref, mask.ref, desc.ref, ret),); return (VecKeyPoint.fromPointer(ret), desc); } diff --git a/lib/src/features2d/features2d_async.dart b/lib/src/features2d/features2d_async.dart index 10dacd4e..c67acf76 100644 --- a/lib/src/features2d/features2d_async.dart +++ b/lib/src/features2d/features2d_async.dart @@ -1,15 +1,5 @@ library cv; -import 'dart:ffi' as ffi; -import 'package:ffi/ffi.dart'; -import '../core/base.dart'; -import '../core/mat.dart'; -import '../core/vec.dart'; -import '../opencv.g.dart' as cvg; -import './features2d.dart'; -import 'package:ffi/ffi.dart'; - -import '../constants.g.dart'; import '../core/base.dart'; import '../core/dmatch.dart'; import '../core/keypoint.dart'; @@ -17,17 +7,18 @@ 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 { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.AKAZE_Create_Async(callback), - (c, p) => c.complete(AKAZE.fromPointer(p.cast()))); + CFFI.AKAZE_Create_Async, + (c, p) => c.complete(AKAZE.fromPointer(p.cast())),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } @@ -35,41 +26,41 @@ extension AKAZEAsync on AKAZE { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( (callback) => CFFI.AKAZE_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback), + ref, src.ref, mask.ref, desc.ref, callback,), (c, keypoints) => c.complete(( VecKeyPoint.fromPointer(keypoints.cast()), desc - ))); + ),),); return rval; } } extension AgastFeatureDetectorAsync on AgastFeatureDetector { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.AgastFeatureDetector_Create_Async(callback), + CFFI.AgastFeatureDetector_Create_Async, (c, p) => c.complete(AgastFeatureDetector.fromPointer( - p.cast()))); + p.cast(),),),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } } extension BRISKAsync on BRISK { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.BRISK_Create_Async(callback), - (c, p) => c.complete(BRISK.fromPointer(p.cast()))); + CFFI.BRISK_Create_Async, + (c, p) => c.complete(BRISK.fromPointer(p.cast())),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } @@ -77,64 +68,64 @@ extension BRISKAsync on BRISK { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( (callback) => CFFI.BRISK_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback), + ref, src.ref, mask.ref, desc.ref, callback,), (c, keypoints) => c.complete(( VecKeyPoint.fromPointer(keypoints.cast()), desc - ))); + ),),); return rval; } } extension FastFeatureDetectorAsync on FastFeatureDetector { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.FastFeatureDetector_Create_Async(callback), + CFFI.FastFeatureDetector_Create_Async, (c, p) => c.complete( - FastFeatureDetector.fromPointer(p.cast()))); + FastFeatureDetector.fromPointer(p.cast()),),); static Future createAsync(int threshold, - bool nonmaxSuppression, FastFeatureDetectorType type) async => + bool nonmaxSuppression, FastFeatureDetectorType type,) async => cvRunAsync( (callback) => CFFI.FastFeatureDetector_CreateWithParams_Async( - threshold, nonmaxSuppression, type.value, callback), + threshold, nonmaxSuppression, type.value, callback,), (c, p) => c.complete(FastFeatureDetector.fromPointer( - p.cast()))); + p.cast(),),),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } } extension GFTTDetectorAsync on GFTTDetector { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.GFTTDetector_Create_Async(callback), + CFFI.GFTTDetector_Create_Async, (c, p) => - c.complete(GFTTDetector.fromPointer(p.cast()))); + c.complete(GFTTDetector.fromPointer(p.cast())),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } } extension KAZEAsync on KAZE { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.KAZE_Create_Async(callback), - (c, p) => c.complete(KAZE.fromPointer(p.cast()))); + CFFI.KAZE_Create_Async, + (c, p) => c.complete(KAZE.fromPointer(p.cast())),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } @@ -142,33 +133,33 @@ extension KAZEAsync on KAZE { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( (callback) => CFFI.KAZE_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback), + ref, src.ref, mask.ref, desc.ref, callback,), (c, keypoints) => c.complete(( VecKeyPoint.fromPointer(keypoints.cast()), desc - ))); + ),),); return rval; } } extension MSERAsync on MSER { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.MSER_Create_Async(callback), - (c, p) => c.complete(MSER.fromPointer(p.cast()))); + CFFI.MSER_Create_Async, + (c, p) => c.complete(MSER.fromPointer(p.cast())),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } } extension ORBAsync on ORB { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.ORB_Create_Async(callback), - (c, p) => c.complete(ORB.fromPointer(p.cast()))); + CFFI.ORB_Create_Async, + (c, p) => c.complete(ORB.fromPointer(p.cast())),); static Future createAsync( int nFeatures, @@ -176,10 +167,10 @@ extension ORBAsync on ORB { int nLevels, int edgeThreshold, int firstLevel, - int WTA_K, + int wtaK, ORBScoreType scoreType, int patchSize, - int fastThreshold) async => + int fastThreshold,) async => cvRunAsync( (callback) => CFFI.ORB_CreateWithParams_Async( nFeatures, @@ -187,18 +178,18 @@ extension ORBAsync on ORB { nLevels, edgeThreshold, firstLevel, - WTA_K, + wtaK, scoreType.value, patchSize, fastThreshold, - callback), - (c, p) => c.complete(ORB.fromPointer(p.cast()))); + callback,), + (c, p) => c.complete(ORB.fromPointer(p.cast())),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } @@ -206,95 +197,95 @@ extension ORBAsync on ORB { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( (callback) => CFFI.ORB_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback), + ref, src.ref, mask.ref, desc.ref, callback,), (c, keypoints) => c.complete(( VecKeyPoint.fromPointer(keypoints.cast()), desc - ))); + ),),); return rval; } } extension SimpleBlobDetectorAsync on SimpleBlobDetector { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.SimpleBlobDetector_Create_Async(callback), + CFFI.SimpleBlobDetector_Create_Async, (c, p) => c.complete( - SimpleBlobDetector.fromPointer(p.cast()))); + SimpleBlobDetector.fromPointer(p.cast()),),); static Future createWithParamsAsync( - SimpleBlobDetectorParams params) async => + SimpleBlobDetectorParams params,) async => cvRunAsync( (callback) => CFFI.SimpleBlobDetector_Create_WithParams_Async( - params.ref, callback), + params.ref, callback,), (c, p) => c.complete(SimpleBlobDetector.fromPointer( - p.cast()))); + p.cast(),),),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } } extension BFMatcherAsync on BFMatcher { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.BFMatcher_Create_Async(callback), - (c, p) => c.complete(BFMatcher.fromPointer(p.cast()))); + CFFI.BFMatcher_Create_Async, + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())),); static Future createAsync(int type, bool crossCheck) async => cvRunAsync( (callback) => CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), - (c, p) => c.complete(BFMatcher.fromPointer(p.cast()))); + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())),); 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()))); + c.complete(VecDMatch.fromPointer(ret.cast())),); return rval; } Future knnMatchAsync(Mat query, Mat train, int k) async { final rval = cvRunAsync( (callback) => CFFI.BFMatcher_KnnMatch_Async( - ref, query.ref, train.ref, k, callback), + ref, query.ref, train.ref, k, callback,), (c, ret) => - c.complete(VecVecDMatch.fromPointer(ret.cast()))); + c.complete(VecVecDMatch.fromPointer(ret.cast())),); return rval; } } extension FlannBasedMatcherAsync on FlannBasedMatcher { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.FlannBasedMatcher_Create_Async(callback), + CFFI.FlannBasedMatcher_Create_Async, (c, p) => c.complete( - FlannBasedMatcher.fromPointer(p.cast()))); + FlannBasedMatcher.fromPointer(p.cast()),),); Future knnMatchAsync(Mat query, Mat train, int k) async { final rval = cvRunAsync( (callback) => CFFI.FlannBasedMatcher_KnnMatch_Async( - ref, query.ref, train.ref, k, callback), + ref, query.ref, train.ref, k, callback,), (c, ret) => - c.complete(VecVecDMatch.fromPointer(ret.cast()))); + c.complete(VecVecDMatch.fromPointer(ret.cast())),); return rval; } } extension SIFTAsync on SIFT { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.SIFT_Create_Async(callback), - (c, p) => c.complete(SIFT.fromPointer(p.cast()))); + CFFI.SIFT_Create_Async, + (c, p) => c.complete(SIFT.fromPointer(p.cast())),); 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()))); + c.complete(VecKeyPoint.fromPointer(ret.cast())),); return rval; } @@ -302,7 +293,7 @@ extension SIFTAsync on SIFT { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( (callback) => CFFI.SIFT_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback), + ref, src.ref, mask.ref, desc.ref, callback,), ( c, keypoints, @@ -310,17 +301,17 @@ extension SIFTAsync on SIFT { c.complete(( VecKeyPoint.fromPointer(keypoints.cast()), desc - ))); + ),),); return rval; } } Future drawKeyPointsAsync(Mat src, VecKeyPoint keypoints, Mat dst, - Scalar color, DrawMatchesFlag flag) async { + 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()); + src.ref, keypoints.ref, dst.ref, color.ref, flag.value, callback,), + (c) => c.complete(),); } Future drawMatchesAsync( @@ -333,7 +324,7 @@ Future drawMatchesAsync( {Scalar? matchColor, Scalar? singlePointColor, VecChar? matchesMask, - DrawMatchesFlag flags = DrawMatchesFlag.DEFAULT}) async { + DrawMatchesFlag flags = DrawMatchesFlag.DEFAULT,}) async { matchColor ??= Scalar.all(-1); singlePointColor ??= Scalar.all(-1); matchesMask ??= VecChar.fromList([]); @@ -349,6 +340,6 @@ Future drawMatchesAsync( singlePointColor!.ref, matchesMask!.ref, flags.value, - callback), - (c) => c.complete()); + callback,), + (c) => c.complete(),); } diff --git a/lib/src/objdetect/objdetect_async.dart b/lib/src/objdetect/objdetect_async.dart index 203e7ff8..9dc90762 100644 --- a/lib/src/objdetect/objdetect_async.dart +++ b/lib/src/objdetect/objdetect_async.dart @@ -16,8 +16,8 @@ import './objdetect.dart'; extension CascadeClassifierAsync on CascadeClassifier { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.CascadeClassifier_New_Async(callback), - (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast()))); + CFFI.CascadeClassifier_New_Async, + (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast())),); static Future fromFileAsync(String filename) async { final cp = filename.toNativeUtf8().cast(); @@ -167,8 +167,8 @@ extension CascadeClassifierAsync on CascadeClassifier { extension HOGDescriptorAsync on HOGDescriptor { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.HOGDescriptor_New_Async(callback), - (c, p) => c.complete(HOGDescriptor.fromPointer(p.cast()))); + CFFI.HOGDescriptor_New_Async, + (c, p) => c.complete(HOGDescriptor.fromPointer(p.cast())),); static Future fromFileAsync(String filename) async { final cp = filename.toNativeUtf8().cast(); @@ -391,8 +391,8 @@ Future groupRectanglesAsync( extension QRCodeDetectorAsync on QRCodeDetector { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.QRCodeDetector_New_Async(callback), - (c, p) => c.complete(QRCodeDetector.fromPointer(p.cast()))); + CFFI.QRCodeDetector_New_Async, + (c, p) => c.complete(QRCodeDetector.fromPointer(p.cast())),); Future<(String rval, Mat straightQRcode)> decodeCurvedAsync( InputArray img, @@ -551,8 +551,8 @@ extension QRCodeDetectorAsync on QRCodeDetector { extension FaceDetectorYNAsync on FaceDetectorYN { static Future emptyNewAsync() async => cvRunAsync( - (callback) => CFFI.CascadeClassifier_New_Async(callback), - (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast()))); + CFFI.CascadeClassifier_New_Async, + (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast())),); static Future fromFileAsync( String model, @@ -568,7 +568,7 @@ extension FaceDetectorYNAsync on FaceDetectorYN { final cConfig = config.toNativeUtf8().cast(); final rval = await cvRunAsync( (callback) => CFFI.FaceDetectorYN_New_Async(cModel, cConfig, inputSize.cvd.ref, scoreThreshold, - nmsThreshold, topK, backendId, targetId, callback), (c, p) { + nmsThreshold, topK, backendId, targetId, callback,), (c, p) { return c.complete(FaceDetectorYN.fromPointer(p.cast())); }); calloc.free(cModel); @@ -600,7 +600,7 @@ extension FaceDetectorYNAsync on FaceDetectorYN { topK, backendId, targetId, - callback), (c, p) { + callback,), (c, p) { return c.complete(FaceDetectorYN.fromPointer(p.cast())); }); calloc.free(cFramework); From f09947741c6b426d1e209728d965190d943136a1 Mon Sep 17 00:00:00 2001 From: abdelaziz-mahdy Date: Fri, 28 Jun 2024 11:51:34 +0000 Subject: [PATCH 03/10] =?UTF-8?q?dart=20format=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/dnn/dnn_async.dart | 10 +- lib/src/features2d/features2d.dart | 150 ++++---- lib/src/features2d/features2d_async.dart | 431 ++++++++++++++--------- lib/src/objdetect/objdetect_async.dart | 54 +-- 4 files changed, 381 insertions(+), 264 deletions(-) diff --git a/lib/src/dnn/dnn_async.dart b/lib/src/dnn/dnn_async.dart index 7159390e..46c5014a 100644 --- a/lib/src/dnn/dnn_async.dart +++ b/lib/src/dnn/dnn_async.dart @@ -94,8 +94,11 @@ extension NetAsync on Net { return rval; } - static Future fromBytesAsync(String framework, Uint8List bufferModel, - {Uint8List? bufferConfig,}) async { + static Future fromBytesAsync( + String framework, + Uint8List bufferModel, { + Uint8List? bufferConfig, + }) async { bufferConfig ??= Uint8List(0); final cFramework = framework.toNativeUtf8().cast(); final bufM = VecUChar.fromList(bufferModel); @@ -303,7 +306,8 @@ extension NetAsync on Net { final rval = cvRunAsync2<(VecFloat, VecInt)>( (callback) => CFFI.Net_GetInputDetails_Async(ref, callback), (c, sc, zp) => c.complete( - (VecFloat.fromPointer(sc.cast()), VecInt.fromPointer(zp.cast())),), + (VecFloat.fromPointer(sc.cast()), VecInt.fromPointer(zp.cast())), + ), ); return rval; } diff --git a/lib/src/features2d/features2d.dart b/lib/src/features2d/features2d.dart index 8a4283ab..06cd515d 100644 --- a/lib/src/features2d/features2d.dart +++ b/lib/src/features2d/features2d.dart @@ -22,8 +22,7 @@ class AKAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory AKAZE.fromPointer(cvg.AKAZEPtr ptr, [bool attach = true]) => - AKAZE._(ptr.cast(), attach); + factory AKAZE.fromPointer(cvg.AKAZEPtr ptr, [bool attach = true]) => AKAZE._(ptr.cast(), attach); /// returns a new AKAZE algorithm /// @@ -52,13 +51,13 @@ 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); } - static final finalizer = - OcvFinalizer(CFFI.addresses.AKAZE_Close); + static final finalizer = OcvFinalizer(CFFI.addresses.AKAZE_Close); void dispose() { finalizer.detach(this); @@ -74,14 +73,15 @@ class AKAZE extends CvStruct { /// AgastFeatureDetector is a wrapper around the cv::AgastFeatureDetector. class AgastFeatureDetector extends CvStruct { - AgastFeatureDetector._(cvg.AgastFeatureDetectorPtr ptr, [bool attach = true]) - : super.fromPointer(ptr) { + AgastFeatureDetector._(cvg.AgastFeatureDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } - factory AgastFeatureDetector.fromPointer(cvg.AgastFeatureDetectorPtr ptr, - [bool attach = true,]) => + factory AgastFeatureDetector.fromPointer( + cvg.AgastFeatureDetectorPtr ptr, [ + bool attach = true, + ]) => AgastFeatureDetector._(ptr.cast(), attach); /// returns a new AgastFeatureDetector algorithm @@ -105,7 +105,8 @@ class AgastFeatureDetector extends CvStruct { } static final finalizer = OcvFinalizer( - CFFI.addresses.AgastFeatureDetector_Close,); + CFFI.addresses.AgastFeatureDetector_Close, + ); void dispose() { finalizer.detach(this); @@ -126,8 +127,7 @@ class BRISK extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory BRISK.fromPointer(cvg.BRISKPtr ptr, [bool attach = true]) => - BRISK._(ptr.cast(), attach); + factory BRISK.fromPointer(cvg.BRISKPtr ptr, [bool attach = true]) => BRISK._(ptr.cast(), attach); /// returns a new BRISK algorithm /// @@ -156,13 +156,13 @@ 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); } - static final finalizer = - OcvFinalizer(CFFI.addresses.BRISK_Close); + static final finalizer = OcvFinalizer(CFFI.addresses.BRISK_Close); void dispose() { finalizer.detach(this); @@ -192,14 +192,15 @@ enum FastFeatureDetectorType { /// FastFeatureDetector is a wrapper around the cv::FastFeatureDetector. class FastFeatureDetector extends CvStruct { - FastFeatureDetector._(cvg.FastFeatureDetectorPtr ptr, [bool attach = true]) - : super.fromPointer(ptr) { + FastFeatureDetector._(cvg.FastFeatureDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } - factory FastFeatureDetector.fromPointer(cvg.FastFeatureDetectorPtr ptr, - [bool attach = true,]) => + factory FastFeatureDetector.fromPointer( + cvg.FastFeatureDetectorPtr ptr, [ + bool attach = true, + ]) => FastFeatureDetector._(ptr.cast(), attach); /// returns a new FastFeatureDetector algorithm @@ -244,7 +245,8 @@ class FastFeatureDetector extends CvStruct { } static final finalizer = OcvFinalizer( - CFFI.addresses.FastFeatureDetector_Close,); + CFFI.addresses.FastFeatureDetector_Close, + ); void dispose() { finalizer.detach(this); @@ -260,14 +262,15 @@ class FastFeatureDetector extends CvStruct { /// GFTTDetector is a wrapper around the cv::GFTTDetector. class GFTTDetector extends CvStruct { - GFTTDetector._(cvg.GFTTDetectorPtr ptr, [bool attach = true]) - : super.fromPointer(ptr) { + GFTTDetector._(cvg.GFTTDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } - factory GFTTDetector.fromPointer(cvg.GFTTDetectorPtr ptr, - [bool attach = true,]) => + factory GFTTDetector.fromPointer( + cvg.GFTTDetectorPtr ptr, [ + bool attach = true, + ]) => GFTTDetector._(ptr.cast(), attach); /// returns a new GFTTDetector algorithm @@ -290,8 +293,7 @@ class GFTTDetector extends CvStruct { return VecKeyPoint.fromPointer(ret); } - static final finalizer = - OcvFinalizer(CFFI.addresses.GFTTDetector_Close); + static final finalizer = OcvFinalizer(CFFI.addresses.GFTTDetector_Close); void dispose() { finalizer.detach(this); @@ -312,8 +314,7 @@ class KAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory KAZE.fromPointer(cvg.KAZEPtr ptr, [bool attach = true]) => - KAZE._(ptr.cast(), attach); + factory KAZE.fromPointer(cvg.KAZEPtr ptr, [bool attach = true]) => KAZE._(ptr.cast(), attach); /// returns a new KAZE algorithm /// @@ -342,8 +343,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); } @@ -368,8 +370,7 @@ class MSER extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory MSER.fromPointer(cvg.MSERPtr ptr, [bool attach = true]) => - MSER._(ptr.cast(), attach); + factory MSER.fromPointer(cvg.MSERPtr ptr, [bool attach = true]) => MSER._(ptr.cast(), attach); /// returns a new MSER algorithm /// @@ -420,8 +421,7 @@ class ORB extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory ORB.fromPointer(cvg.ORBPtr ptr, [bool attach = true]) => - ORB._(ptr.cast(), attach); + factory ORB.fromPointer(cvg.ORBPtr ptr, [bool attach = true]) => ORB._(ptr.cast(), attach); /// returns a new ORB algorithm /// @@ -483,8 +483,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); } @@ -503,9 +504,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); } @@ -566,8 +568,7 @@ class SimpleBlobDetectorParams extends CvStruct { return SimpleBlobDetectorParams._(p); } - factory SimpleBlobDetectorParams.fromNative(cvg.SimpleBlobDetectorParams r) => - SimpleBlobDetectorParams( + factory SimpleBlobDetectorParams.fromNative(cvg.SimpleBlobDetectorParams r) => SimpleBlobDetectorParams( blobColor: r.blobColor, filterByArea: r.filterByArea, filterByCircularity: r.filterByCircularity, @@ -721,15 +722,16 @@ class SimpleBlobDetectorParams extends CvStruct { /// SimpleBlobDetector is a wrapper around the cv::SimpleBlobDetector. class SimpleBlobDetector extends CvStruct { - SimpleBlobDetector._(cvg.SimpleBlobDetectorPtr ptr, [bool attach = true]) - : super.fromPointer(ptr) { + SimpleBlobDetector._(cvg.SimpleBlobDetectorPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } - factory SimpleBlobDetector.fromPointer(cvg.SimpleBlobDetectorPtr ptr, - [bool attach = true,]) => + factory SimpleBlobDetector.fromPointer( + cvg.SimpleBlobDetectorPtr ptr, [ + bool attach = true, + ]) => SimpleBlobDetector._(ptr.cast(), attach); /// returns a new SimpleBlobDetector algorithm @@ -759,7 +761,8 @@ class SimpleBlobDetector extends CvStruct { } static final finalizer = OcvFinalizer( - CFFI.addresses.SimpleBlobDetector_Close,); + CFFI.addresses.SimpleBlobDetector_Close, + ); void dispose() { finalizer.detach(this); @@ -775,8 +778,7 @@ class SimpleBlobDetector extends CvStruct { /// BFMatcher is a wrapper around the cv::BFMatcher. class BFMatcher extends CvStruct { - BFMatcher._(cvg.BFMatcherPtr ptr, [bool attach = true]) - : super.fromPointer(ptr) { + BFMatcher._(cvg.BFMatcherPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } @@ -820,8 +822,7 @@ class BFMatcher extends CvStruct { return VecVecDMatch.fromPointer(ret); } - static final finalizer = - OcvFinalizer(CFFI.addresses.BFMatcher_Close); + static final finalizer = OcvFinalizer(CFFI.addresses.BFMatcher_Close); void dispose() { finalizer.detach(this); @@ -837,14 +838,15 @@ class BFMatcher extends CvStruct { /// FlannBasedMatcher is a wrapper around the cv::FlannBasedMatcher. class FlannBasedMatcher extends CvStruct { - FlannBasedMatcher._(cvg.FlannBasedMatcherPtr ptr, [bool attach = true]) - : super.fromPointer(ptr) { + FlannBasedMatcher._(cvg.FlannBasedMatcherPtr ptr, [bool attach = true]) : super.fromPointer(ptr) { if (attach) { finalizer.attach(this, ptr.cast(), detach: this); } } - factory FlannBasedMatcher.fromPointer(cvg.FlannBasedMatcherPtr ptr, - [bool attach = true,]) => + factory FlannBasedMatcher.fromPointer( + cvg.FlannBasedMatcherPtr ptr, [ + bool attach = true, + ]) => FlannBasedMatcher._(ptr.cast(), attach); /// returns a new FlannBasedMatcher algorithm @@ -863,13 +865,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,); + CFFI.addresses.FlannBasedMatcher_Close, + ); void dispose() { finalizer.detach(this); @@ -900,10 +904,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. @@ -913,8 +929,7 @@ class SIFT extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory SIFT.fromPointer(cvg.SIFTPtr ptr, [bool attach = true]) => - SIFT._(ptr.cast(), attach); + factory SIFT.fromPointer(cvg.SIFTPtr ptr, [bool attach = true]) => SIFT._(ptr.cast(), attach); /// returns a new SIFT algorithm /// @@ -943,8 +958,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); } diff --git a/lib/src/features2d/features2d_async.dart b/lib/src/features2d/features2d_async.dart index c67acf76..61d5b600 100644 --- a/lib/src/features2d/features2d_async.dart +++ b/lib/src/features2d/features2d_async.dart @@ -11,335 +11,418 @@ import './features2d.dart'; extension AKAZEAsync on AKAZE { static Future emptyNewAsync() async => cvRunAsync( - CFFI.AKAZE_Create_Async, - (c, p) => c.complete(AKAZE.fromPointer(p.cast())),); + CFFI.AKAZE_Create_Async, + (c, p) => c.complete(AKAZE.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.AKAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.AKAZE_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.AKAZE_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension AgastFeatureDetectorAsync on AgastFeatureDetector { static Future emptyNewAsync() async => cvRunAsync( - CFFI.AgastFeatureDetector_Create_Async, - (c, p) => c.complete(AgastFeatureDetector.fromPointer( - p.cast(),),),); + CFFI.AgastFeatureDetector_Create_Async, + (c, p) => c.complete( + AgastFeatureDetector.fromPointer( + p.cast(), + ), + ), + ); 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())),); + (callback) => CFFI.AgastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension BRISKAsync on BRISK { static Future emptyNewAsync() async => cvRunAsync( - CFFI.BRISK_Create_Async, - (c, p) => c.complete(BRISK.fromPointer(p.cast())),); + CFFI.BRISK_Create_Async, + (c, p) => c.complete(BRISK.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.BRISK_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.BRISK_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.BRISK_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension FastFeatureDetectorAsync on FastFeatureDetector { static Future emptyNewAsync() async => cvRunAsync( - CFFI.FastFeatureDetector_Create_Async, - (c, p) => c.complete( - FastFeatureDetector.fromPointer(p.cast()),),); - - static Future createAsync(int threshold, - bool nonmaxSuppression, FastFeatureDetectorType type,) async => + CFFI.FastFeatureDetector_Create_Async, + (c, p) => c.complete( + FastFeatureDetector.fromPointer(p.cast()), + ), + ); + + static Future createAsync( + int threshold, + bool nonmaxSuppression, + FastFeatureDetectorType type, + ) async => cvRunAsync( - (callback) => CFFI.FastFeatureDetector_CreateWithParams_Async( - threshold, nonmaxSuppression, type.value, callback,), - (c, p) => c.complete(FastFeatureDetector.fromPointer( - p.cast(),),),); + (callback) => CFFI.FastFeatureDetector_CreateWithParams_Async( + threshold, + nonmaxSuppression, + type.value, + callback, + ), + (c, p) => c.complete( + FastFeatureDetector.fromPointer( + p.cast(), + ), + ), + ); 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())),); + (callback) => CFFI.FastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension GFTTDetectorAsync on GFTTDetector { static Future emptyNewAsync() async => cvRunAsync( - CFFI.GFTTDetector_Create_Async, - (c, p) => - c.complete(GFTTDetector.fromPointer(p.cast())),); + CFFI.GFTTDetector_Create_Async, + (c, p) => c.complete(GFTTDetector.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.GFTTDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension KAZEAsync on KAZE { static Future emptyNewAsync() async => cvRunAsync( - CFFI.KAZE_Create_Async, - (c, p) => c.complete(KAZE.fromPointer(p.cast())),); + CFFI.KAZE_Create_Async, + (c, p) => c.complete(KAZE.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.KAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.KAZE_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.KAZE_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension MSERAsync on MSER { static Future emptyNewAsync() async => cvRunAsync( - CFFI.MSER_Create_Async, - (c, p) => c.complete(MSER.fromPointer(p.cast())),); + CFFI.MSER_Create_Async, + (c, p) => c.complete(MSER.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.MSER_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension ORBAsync on ORB { static Future emptyNewAsync() async => cvRunAsync( - CFFI.ORB_Create_Async, - (c, p) => c.complete(ORB.fromPointer(p.cast())),); + CFFI.ORB_Create_Async, + (c, p) => c.complete(ORB.fromPointer(p.cast())), + ); static Future createAsync( - int nFeatures, - double scaleFactor, - int nLevels, - int edgeThreshold, - int firstLevel, - int wtaK, - ORBScoreType scoreType, - int patchSize, - int fastThreshold,) async => + int nFeatures, + double scaleFactor, + int nLevels, + int edgeThreshold, + int firstLevel, + int wtaK, + ORBScoreType scoreType, + int patchSize, + int fastThreshold, + ) async => cvRunAsync( - (callback) => CFFI.ORB_CreateWithParams_Async( - nFeatures, - scaleFactor, - nLevels, - edgeThreshold, - firstLevel, - wtaK, - scoreType.value, - patchSize, - fastThreshold, - callback,), - (c, p) => c.complete(ORB.fromPointer(p.cast())),); + (callback) => CFFI.ORB_CreateWithParams_Async( + nFeatures, + scaleFactor, + nLevels, + edgeThreshold, + firstLevel, + wtaK, + scoreType.value, + patchSize, + fastThreshold, + callback, + ), + (c, p) => c.complete(ORB.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.ORB_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.ORB_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.ORB_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension SimpleBlobDetectorAsync on SimpleBlobDetector { static Future emptyNewAsync() async => cvRunAsync( - CFFI.SimpleBlobDetector_Create_Async, - (c, p) => c.complete( - SimpleBlobDetector.fromPointer(p.cast()),),); + CFFI.SimpleBlobDetector_Create_Async, + (c, p) => c.complete( + SimpleBlobDetector.fromPointer(p.cast()), + ), + ); static Future createWithParamsAsync( - SimpleBlobDetectorParams params,) async => + SimpleBlobDetectorParams params, + ) async => cvRunAsync( - (callback) => CFFI.SimpleBlobDetector_Create_WithParams_Async( - params.ref, callback,), - (c, p) => c.complete(SimpleBlobDetector.fromPointer( - p.cast(),),),); + (callback) => CFFI.SimpleBlobDetector_Create_WithParams_Async( + params.ref, + callback, + ), + (c, p) => c.complete( + SimpleBlobDetector.fromPointer( + p.cast(), + ), + ), + ); 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())),); + (callback) => CFFI.SimpleBlobDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension BFMatcherAsync on BFMatcher { static Future emptyNewAsync() async => cvRunAsync( - CFFI.BFMatcher_Create_Async, - (c, p) => c.complete(BFMatcher.fromPointer(p.cast())),); + CFFI.BFMatcher_Create_Async, + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); - static Future createAsync(int type, bool crossCheck) async => - cvRunAsync( - (callback) => - CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), - (c, p) => c.complete(BFMatcher.fromPointer(p.cast())),); + static Future createAsync(int type, bool crossCheck) async => cvRunAsync( + (callback) => CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.BFMatcher_Match_Async(ref, query.ref, train.ref, callback), + (c, ret) => c.complete(VecDMatch.fromPointer(ret.cast())), + ); return rval; } 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())),); + (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 { static Future emptyNewAsync() async => cvRunAsync( - CFFI.FlannBasedMatcher_Create_Async, - (c, p) => c.complete( - FlannBasedMatcher.fromPointer(p.cast()),),); + CFFI.FlannBasedMatcher_Create_Async, + (c, p) => c.complete( + FlannBasedMatcher.fromPointer(p.cast()), + ), + ); 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())),); + (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 { static Future emptyNewAsync() async => cvRunAsync( - CFFI.SIFT_Create_Async, - (c, p) => c.complete(SIFT.fromPointer(p.cast())),); + CFFI.SIFT_Create_Async, + (c, p) => c.complete(SIFT.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.SIFT_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.SIFT_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - ( - c, - keypoints, - ) => - c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.SIFT_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + ( + c, + keypoints, + ) => + c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } -Future drawKeyPointsAsync(Mat src, VecKeyPoint keypoints, Mat dst, - Scalar color, DrawMatchesFlag flag,) async { +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(),); + (callback) => CFFI.DrawKeyPoints_Async( + src.ref, + keypoints.ref, + dst.ref, + color.ref, + flag.value, + callback, + ), + (c) => c.complete(), + ); } 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 { + 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.fromList([]); 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(),); + (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/objdetect/objdetect_async.dart b/lib/src/objdetect/objdetect_async.dart index 9dc90762..f3978f34 100644 --- a/lib/src/objdetect/objdetect_async.dart +++ b/lib/src/objdetect/objdetect_async.dart @@ -16,8 +16,9 @@ import './objdetect.dart'; extension CascadeClassifierAsync on CascadeClassifier { static Future emptyNewAsync() async => cvRunAsync( - CFFI.CascadeClassifier_New_Async, - (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast())),); + CFFI.CascadeClassifier_New_Async, + (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast())), + ); static Future fromFileAsync(String filename) async { final cp = filename.toNativeUtf8().cast(); @@ -167,8 +168,9 @@ extension CascadeClassifierAsync on CascadeClassifier { extension HOGDescriptorAsync on HOGDescriptor { static Future emptyNewAsync() async => cvRunAsync( - CFFI.HOGDescriptor_New_Async, - (c, p) => c.complete(HOGDescriptor.fromPointer(p.cast())),); + CFFI.HOGDescriptor_New_Async, + (c, p) => c.complete(HOGDescriptor.fromPointer(p.cast())), + ); static Future fromFileAsync(String filename) async { final cp = filename.toNativeUtf8().cast(); @@ -391,8 +393,9 @@ Future groupRectanglesAsync( extension QRCodeDetectorAsync on QRCodeDetector { static Future emptyNewAsync() async => cvRunAsync( - CFFI.QRCodeDetector_New_Async, - (c, p) => c.complete(QRCodeDetector.fromPointer(p.cast())),); + CFFI.QRCodeDetector_New_Async, + (c, p) => c.complete(QRCodeDetector.fromPointer(p.cast())), + ); Future<(String rval, Mat straightQRcode)> decodeCurvedAsync( InputArray img, @@ -551,8 +554,9 @@ extension QRCodeDetectorAsync on QRCodeDetector { extension FaceDetectorYNAsync on FaceDetectorYN { static Future emptyNewAsync() async => cvRunAsync( - CFFI.CascadeClassifier_New_Async, - (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast())),); + CFFI.CascadeClassifier_New_Async, + (c, p) => c.complete(CascadeClassifier.fromPointer(p.cast())), + ); static Future fromFileAsync( String model, @@ -567,8 +571,17 @@ extension FaceDetectorYNAsync on FaceDetectorYN { final cModel = model.toNativeUtf8().cast(); final cConfig = config.toNativeUtf8().cast(); final rval = await cvRunAsync( - (callback) => CFFI.FaceDetectorYN_New_Async(cModel, cConfig, inputSize.cvd.ref, scoreThreshold, - nmsThreshold, topK, backendId, targetId, callback,), (c, p) { + (callback) => CFFI.FaceDetectorYN_New_Async( + cModel, + cConfig, + inputSize.cvd.ref, + scoreThreshold, + nmsThreshold, + topK, + backendId, + targetId, + callback, + ), (c, p) { return c.complete(FaceDetectorYN.fromPointer(p.cast())); }); calloc.free(cModel); @@ -591,16 +604,17 @@ extension FaceDetectorYNAsync on FaceDetectorYN { final rval = await cvRunAsync( (callback) => CFFI.FaceDetectorYN_NewFromBuffer_Async( - cFramework, - VecUChar.fromList(bufferModel).ref, - VecUChar.fromList(bufferConfig).ref, - inputSize.cvd.ref, - scoreThreshold, - nmsThreshold, - topK, - backendId, - targetId, - callback,), (c, p) { + cFramework, + VecUChar.fromList(bufferModel).ref, + VecUChar.fromList(bufferConfig).ref, + inputSize.cvd.ref, + scoreThreshold, + nmsThreshold, + topK, + backendId, + targetId, + callback, + ), (c, p) { return c.complete(FaceDetectorYN.fromPointer(p.cast())); }); calloc.free(cFramework); From e5a41a202d556231ea6b37036877852679d8088a Mon Sep 17 00:00:00 2001 From: Abdelaziz Mahdy Date: Fri, 28 Jun 2024 14:57:14 +0300 Subject: [PATCH 04/10] tests and improve params --- lib/opencv_dart.dart | 1 + lib/src/features2d/features2d_async.dart | 483 +++++++++++++-------- test/features2d/features2d_async_test.dart | 356 +++++++++++++++ test/{ => features2d}/features2d_test.dart | 0 4 files changed, 651 insertions(+), 189 deletions(-) create mode 100644 test/features2d/features2d_async_test.dart rename test/{ => features2d}/features2d_test.dart (100%) diff --git a/lib/opencv_dart.dart b/lib/opencv_dart.dart index 9c286afc..6acd2560 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_async.dart b/lib/src/features2d/features2d_async.dart index c67acf76..d7a8774c 100644 --- a/lib/src/features2d/features2d_async.dart +++ b/lib/src/features2d/features2d_async.dart @@ -1,5 +1,7 @@ library cv; +import 'package:opencv_dart/src/constants.g.dart'; + import '../core/base.dart'; import '../core/dmatch.dart'; import '../core/keypoint.dart'; @@ -10,336 +12,439 @@ import '../opencv.g.dart' as cvg; import './features2d.dart'; extension AKAZEAsync on AKAZE { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.AKAZE_Create_Async, - (c, p) => c.complete(AKAZE.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.AKAZE_Create_Async, + (c, p) => c.complete(AKAZE.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.AKAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.AKAZE_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.AKAZE_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension AgastFeatureDetectorAsync on AgastFeatureDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.AgastFeatureDetector_Create_Async, - (c, p) => c.complete(AgastFeatureDetector.fromPointer( - p.cast(),),),); + static Future emptyAsync() async => cvRunAsync( + CFFI.AgastFeatureDetector_Create_Async, + (c, p) => c.complete( + AgastFeatureDetector.fromPointer( + p.cast(), + ), + ), + ); 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())),); + (callback) => + CFFI.AgastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension BRISKAsync on BRISK { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.BRISK_Create_Async, - (c, p) => c.complete(BRISK.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.BRISK_Create_Async, + (c, p) => c.complete(BRISK.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.BRISK_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.BRISK_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.BRISK_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension FastFeatureDetectorAsync on FastFeatureDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.FastFeatureDetector_Create_Async, - (c, p) => c.complete( - FastFeatureDetector.fromPointer(p.cast()),),); - - static Future createAsync(int threshold, - bool nonmaxSuppression, FastFeatureDetectorType type,) async => + static Future emptyAsync() async => cvRunAsync( + CFFI.FastFeatureDetector_Create_Async, + (c, p) => c.complete( + FastFeatureDetector.fromPointer(p.cast()), + ), + ); + + 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(),),),); + (callback) => CFFI.FastFeatureDetector_CreateWithParams_Async( + threshold, + nonmaxSuppression, + type.value, + callback, + ), + (c, p) => c.complete( + FastFeatureDetector.fromPointer( + p.cast(), + ), + ), + ); 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())),); + (callback) => + CFFI.FastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension GFTTDetectorAsync on GFTTDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.GFTTDetector_Create_Async, - (c, p) => - c.complete(GFTTDetector.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.GFTTDetector_Create_Async, + (c, p) => + c.complete(GFTTDetector.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.GFTTDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension KAZEAsync on KAZE { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.KAZE_Create_Async, - (c, p) => c.complete(KAZE.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.KAZE_Create_Async, + (c, p) => c.complete(KAZE.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.KAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.KAZE_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.KAZE_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension MSERAsync on MSER { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.MSER_Create_Async, - (c, p) => c.complete(MSER.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.MSER_Create_Async, + (c, p) => c.complete(MSER.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.MSER_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension ORBAsync on ORB { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.ORB_Create_Async, - (c, p) => c.complete(ORB.fromPointer(p.cast())),); - - static Future createAsync( - int nFeatures, - double scaleFactor, - int nLevels, - int edgeThreshold, - int firstLevel, - int wtaK, - ORBScoreType scoreType, - int patchSize, - int fastThreshold,) async => + static Future emptyAsync() async => cvRunAsync( + CFFI.ORB_Create_Async, + (c, p) => c.complete(ORB.fromPointer(p.cast())), + ); + + 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, - wtaK, - scoreType.value, - patchSize, - fastThreshold, - callback,), - (c, p) => c.complete(ORB.fromPointer(p.cast())),); + (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())), + ); 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())),); + (callback) => CFFI.ORB_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.ORB_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - (c, keypoints) => c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.ORB_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + (c, keypoints) => c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } extension SimpleBlobDetectorAsync on SimpleBlobDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.SimpleBlobDetector_Create_Async, - (c, p) => c.complete( - SimpleBlobDetector.fromPointer(p.cast()),),); - - static Future createWithParamsAsync( - SimpleBlobDetectorParams params,) async => + 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(),),),); + (callback) => CFFI.SimpleBlobDetector_Create_WithParams_Async( + params.ref, + callback, + ), + (c, p) => c.complete( + SimpleBlobDetector.fromPointer( + p.cast(), + ), + ), + ); 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())),); + (callback) => + CFFI.SimpleBlobDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension BFMatcherAsync on BFMatcher { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.BFMatcher_Create_Async, - (c, p) => c.complete(BFMatcher.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.BFMatcher_Create_Async, + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); - static Future createAsync(int type, bool crossCheck) async => + 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())),); + (callback) => + CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); 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())),); + (callback) => + CFFI.BFMatcher_Match_Async(ref, query.ref, train.ref, callback), + (c, ret) => c.complete(VecDMatch.fromPointer(ret.cast())), + ); return rval; } 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())),); + (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 { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.FlannBasedMatcher_Create_Async, - (c, p) => c.complete( - FlannBasedMatcher.fromPointer(p.cast()),),); + static Future emptyAsync() async => cvRunAsync( + CFFI.FlannBasedMatcher_Create_Async, + (c, p) => c.complete( + FlannBasedMatcher.fromPointer(p.cast()), + ), + ); 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())),); + (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 { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.SIFT_Create_Async, - (c, p) => c.complete(SIFT.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.SIFT_Create_Async, + (c, p) => c.complete(SIFT.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.SIFT_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } Future<(VecKeyPoint, Mat)> detectAndComputeAsync(Mat src, Mat mask) async { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.SIFT_DetectAndCompute_Async( - ref, src.ref, mask.ref, desc.ref, callback,), - ( - c, - keypoints, - ) => - c.complete(( - VecKeyPoint.fromPointer(keypoints.cast()), - desc - ),),); + (callback) => CFFI.SIFT_DetectAndCompute_Async( + ref, + src.ref, + mask.ref, + desc.ref, + callback, + ), + ( + c, + keypoints, + ) => + c.complete( + (VecKeyPoint.fromPointer(keypoints.cast()), desc), + ), + ); return rval; } } -Future drawKeyPointsAsync(Mat src, VecKeyPoint keypoints, Mat dst, - Scalar color, DrawMatchesFlag flag,) async { +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(),); + (callback) => CFFI.DrawKeyPoints_Async( + src.ref, + keypoints.ref, + dst.ref, + color.ref, + flag.value, + callback, + ), + (c) => c.complete(), + ); } 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 { + 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.fromList([]); 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(),); + (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/test/features2d/features2d_async_test.dart b/test/features2d/features2d_async_test.dart new file mode 100644 index 00000000..10a756ca --- /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 From c22b713f03b02581b835db31dc008b7af9049b50 Mon Sep 17 00:00:00 2001 From: Abdelaziz Mahdy Date: Fri, 28 Jun 2024 14:59:07 +0300 Subject: [PATCH 05/10] fix merge conflicts --- lib/src/features2d/features2d_async.dart | 283 +++++++++++++---------- 1 file changed, 166 insertions(+), 117 deletions(-) diff --git a/lib/src/features2d/features2d_async.dart b/lib/src/features2d/features2d_async.dart index fa246e11..d7a8774c 100644 --- a/lib/src/features2d/features2d_async.dart +++ b/lib/src/features2d/features2d_async.dart @@ -12,15 +12,17 @@ import '../opencv.g.dart' as cvg; import './features2d.dart'; extension AKAZEAsync on AKAZE { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.AKAZE_Create_Async, - (c, p) => c.complete(AKAZE.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.AKAZE_Create_Async, + (c, p) => c.complete(AKAZE.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.AKAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } @@ -43,31 +45,38 @@ extension AKAZEAsync on AKAZE { } extension AgastFeatureDetectorAsync on AgastFeatureDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.AgastFeatureDetector_Create_Async, - (c, p) => c.complete(AgastFeatureDetector.fromPointer( - p.cast(),),),); + static Future emptyAsync() async => cvRunAsync( + CFFI.AgastFeatureDetector_Create_Async, + (c, p) => c.complete( + AgastFeatureDetector.fromPointer( + p.cast(), + ), + ), + ); 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())),); + (callback) => + CFFI.AgastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension BRISKAsync on BRISK { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.BRISK_Create_Async, - (c, p) => c.complete(BRISK.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.BRISK_Create_Async, + (c, p) => c.complete(BRISK.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.BRISK_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } @@ -90,13 +99,18 @@ extension BRISKAsync on BRISK { } extension FastFeatureDetectorAsync on FastFeatureDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.FastFeatureDetector_Create_Async, - (c, p) => c.complete( - FastFeatureDetector.fromPointer(p.cast()),),); + static Future emptyAsync() async => cvRunAsync( + CFFI.FastFeatureDetector_Create_Async, + (c, p) => c.complete( + FastFeatureDetector.fromPointer(p.cast()), + ), + ); - static Future createAsync(int threshold, - bool nonmaxSuppression, FastFeatureDetectorType type,) async => + static Future createAsync({ + int threshold = 10, + bool nonmaxSuppression = true, + FastFeatureDetectorType type = FastFeatureDetectorType.TYPE_9_16, + }) async => cvRunAsync( (callback) => CFFI.FastFeatureDetector_CreateWithParams_Async( threshold, @@ -113,39 +127,44 @@ extension FastFeatureDetectorAsync on FastFeatureDetector { 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())),); + (callback) => + CFFI.FastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension GFTTDetectorAsync on GFTTDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.GFTTDetector_Create_Async, - (c, p) => - c.complete(GFTTDetector.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.GFTTDetector_Create_Async, + (c, p) => + c.complete(GFTTDetector.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.GFTTDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension KAZEAsync on KAZE { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.KAZE_Create_Async, - (c, p) => c.complete(KAZE.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.KAZE_Create_Async, + (c, p) => c.complete(KAZE.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.KAZE_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } @@ -168,53 +187,60 @@ extension KAZEAsync on KAZE { } extension MSERAsync on MSER { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.MSER_Create_Async, - (c, p) => c.complete(MSER.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.MSER_Create_Async, + (c, p) => c.complete(MSER.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.MSER_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension ORBAsync on ORB { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.ORB_Create_Async, - (c, p) => c.complete(ORB.fromPointer(p.cast())),); - - static Future createAsync( - int nFeatures, - double scaleFactor, - int nLevels, - int edgeThreshold, - int firstLevel, - int wtaK, - ORBScoreType scoreType, - int patchSize, - int fastThreshold,) async => + static Future emptyAsync() async => cvRunAsync( + CFFI.ORB_Create_Async, + (c, p) => c.complete(ORB.fromPointer(p.cast())), + ); + + 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, - wtaK, - scoreType.value, - patchSize, - fastThreshold, - callback,), - (c, p) => c.complete(ORB.fromPointer(p.cast())),); + (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())), + ); 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())),); + (callback) => CFFI.ORB_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } @@ -237,13 +263,16 @@ extension ORBAsync on ORB { } extension SimpleBlobDetectorAsync on SimpleBlobDetector { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.SimpleBlobDetector_Create_Async, - (c, p) => c.complete( - SimpleBlobDetector.fromPointer(p.cast()),),); + static Future emptyAsync() async => cvRunAsync( + CFFI.SimpleBlobDetector_Create_Async, + (c, p) => c.complete( + SimpleBlobDetector.fromPointer(p.cast()), + ), + ); - static Future createWithParamsAsync( - SimpleBlobDetectorParams params,) async => + static Future createAsync( + SimpleBlobDetectorParams params, + ) async => cvRunAsync( (callback) => CFFI.SimpleBlobDetector_Create_WithParams_Async( params.ref, @@ -258,70 +287,90 @@ extension SimpleBlobDetectorAsync on SimpleBlobDetector { 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())),); + (callback) => + CFFI.SimpleBlobDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } } extension BFMatcherAsync on BFMatcher { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.BFMatcher_Create_Async, - (c, p) => c.complete(BFMatcher.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.BFMatcher_Create_Async, + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); - static Future createAsync(int type, bool crossCheck) async => + 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())),); + (callback) => + CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), + (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), + ); 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())),); + (callback) => + CFFI.BFMatcher_Match_Async(ref, query.ref, train.ref, callback), + (c, ret) => c.complete(VecDMatch.fromPointer(ret.cast())), + ); return rval; } 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())),); + (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 { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.FlannBasedMatcher_Create_Async, - (c, p) => c.complete( - FlannBasedMatcher.fromPointer(p.cast()),),); + static Future emptyAsync() async => cvRunAsync( + CFFI.FlannBasedMatcher_Create_Async, + (c, p) => c.complete( + FlannBasedMatcher.fromPointer(p.cast()), + ), + ); 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())),); + (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 { - static Future emptyNewAsync() async => cvRunAsync( - CFFI.SIFT_Create_Async, - (c, p) => c.complete(SIFT.fromPointer(p.cast())),); + static Future emptyAsync() async => cvRunAsync( + CFFI.SIFT_Create_Async, + (c, p) => c.complete(SIFT.fromPointer(p.cast())), + ); 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())),); + (callback) => CFFI.SIFT_Detect_Async(ref, src.ref, callback), + (c, ret) => + c.complete(VecKeyPoint.fromPointer(ret.cast())), + ); return rval; } From 7d9cebe2671d70dc5c3564b145ff3cd844a0666f Mon Sep 17 00:00:00 2001 From: abdelaziz-mahdy Date: Fri, 28 Jun 2024 12:00:03 +0000 Subject: [PATCH 06/10] =?UTF-8?q?dart=20format=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/features2d/features2d_async.dart | 60 +++++++----------- test/features2d/features2d_async_test.dart | 72 +++++++++++----------- 2 files changed, 58 insertions(+), 74 deletions(-) diff --git a/lib/src/features2d/features2d_async.dart b/lib/src/features2d/features2d_async.dart index d7a8774c..b018d513 100644 --- a/lib/src/features2d/features2d_async.dart +++ b/lib/src/features2d/features2d_async.dart @@ -20,8 +20,7 @@ extension AKAZEAsync on AKAZE { 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())), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -56,10 +55,8 @@ extension AgastFeatureDetectorAsync on AgastFeatureDetector { 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())), + (callback) => CFFI.AgastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -74,8 +71,7 @@ extension BRISKAsync on BRISK { 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())), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -127,10 +123,8 @@ extension FastFeatureDetectorAsync on FastFeatureDetector { 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())), + (callback) => CFFI.FastFeatureDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -139,15 +133,13 @@ extension FastFeatureDetectorAsync on FastFeatureDetector { extension GFTTDetectorAsync on GFTTDetector { static Future emptyAsync() async => cvRunAsync( CFFI.GFTTDetector_Create_Async, - (c, p) => - c.complete(GFTTDetector.fromPointer(p.cast())), + (c, p) => c.complete(GFTTDetector.fromPointer(p.cast())), ); 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())), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -162,8 +154,7 @@ extension KAZEAsync on KAZE { 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())), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -195,8 +186,7 @@ extension MSERAsync on MSER { 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())), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -238,8 +228,7 @@ extension ORBAsync on ORB { 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())), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -287,10 +276,8 @@ extension SimpleBlobDetectorAsync on SimpleBlobDetector { 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())), + (callback) => CFFI.SimpleBlobDetector_Detect_Async(ref, src.ref, callback), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } @@ -302,18 +289,18 @@ extension BFMatcherAsync on BFMatcher { (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), ); - static Future createAsync( - {int type = NORM_L2, bool crossCheck = false,}) async => + static Future createAsync({ + int type = NORM_L2, + bool crossCheck = false, + }) async => cvRunAsync( - (callback) => - CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), + (callback) => CFFI.BFMatcher_CreateWithParams_Async(type, crossCheck, callback), (c, p) => c.complete(BFMatcher.fromPointer(p.cast())), ); Future matchAsync(Mat query, Mat train) async { final rval = cvRunAsync( - (callback) => - CFFI.BFMatcher_Match_Async(ref, query.ref, train.ref, callback), + (callback) => CFFI.BFMatcher_Match_Async(ref, query.ref, train.ref, callback), (c, ret) => c.complete(VecDMatch.fromPointer(ret.cast())), ); return rval; @@ -328,8 +315,7 @@ extension BFMatcherAsync on BFMatcher { k, callback, ), - (c, ret) => - c.complete(VecVecDMatch.fromPointer(ret.cast())), + (c, ret) => c.complete(VecVecDMatch.fromPointer(ret.cast())), ); return rval; } @@ -352,8 +338,7 @@ extension FlannBasedMatcherAsync on FlannBasedMatcher { k, callback, ), - (c, ret) => - c.complete(VecVecDMatch.fromPointer(ret.cast())), + (c, ret) => c.complete(VecVecDMatch.fromPointer(ret.cast())), ); return rval; } @@ -368,8 +353,7 @@ extension SIFTAsync on SIFT { 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())), + (c, ret) => c.complete(VecKeyPoint.fromPointer(ret.cast())), ); return rval; } diff --git a/test/features2d/features2d_async_test.dart b/test/features2d/features2d_async_test.dart index 10a756ca..54bb750a 100644 --- a/test/features2d/features2d_async_test.dart +++ b/test/features2d/features2d_async_test.dart @@ -3,8 +3,7 @@ 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); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final ak = await cv.AKAZEAsync.emptyAsync(); @@ -20,8 +19,7 @@ void main() async { }); test('cv.AgastFeatureDetectorAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final ad = await cv.AgastFeatureDetectorAsync.emptyAsync(); @@ -32,8 +30,7 @@ void main() async { }); test('cv.BRISKAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final br = await cv.BRISKAsync.emptyAsync(); @@ -49,8 +46,7 @@ void main() async { }); test('cv.FastFeatureDetectorAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final fd = await cv.FastFeatureDetectorAsync.emptyAsync(); @@ -65,8 +61,7 @@ void main() async { }); test('cv.GFTTDetectorAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final gf = await cv.GFTTDetectorAsync.emptyAsync(); @@ -77,8 +72,7 @@ void main() async { }); test('cv.KAZEAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final ka = await cv.KAZEAsync.emptyAsync(); @@ -94,8 +88,7 @@ void main() async { }); test('cv.MSERAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final gf = await cv.MSERAsync.emptyAsync(); @@ -106,8 +99,7 @@ void main() async { }); test('cv.ORBAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final ka = await cv.ORBAsync.emptyAsync(); @@ -127,8 +119,7 @@ void main() async { }); test('cv.SimpleBlobDetectorAsync', () async { - final img = - await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); + final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_COLOR); expect(img.isEmpty, false); final detector = await cv.SimpleBlobDetectorAsync.emptyAsync(); @@ -264,11 +255,15 @@ void main() async { }); test('cv.BFMatcherAsync', () async { - final desc1 = await cv.imreadAsync("test/images/sift_descriptor.png", - flags: cv.IMREAD_GRAYSCALE,); + 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,); + final desc2 = await cv.imreadAsync( + "test/images/sift_descriptor.png", + flags: cv.IMREAD_GRAYSCALE, + ); expect(desc2.isEmpty, false); final matcher = await cv.BFMatcherAsync.emptyAsync(); @@ -286,11 +281,15 @@ void main() async { }); test('cv.FlannBasedMatcherAsync', () async { - final desc1 = await cv.imreadAsync("test/images/sift_descriptor.png", - flags: cv.IMREAD_GRAYSCALE,); + 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,); + 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); @@ -304,8 +303,10 @@ void main() async { }); test('cv.SIFTAsync', () async { - final img = await cv.imreadAsync("test/images/lenna.png", - flags: cv.IMREAD_GRAYSCALE,); + final img = await cv.imreadAsync( + "test/images/lenna.png", + flags: cv.IMREAD_GRAYSCALE, + ); expect(img.isEmpty, false); final si = await cv.SIFTAsync.emptyAsync(); @@ -321,18 +322,17 @@ void main() async { }); 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,); + 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 (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); From 3ae5ddce631d6fe1a5f8fc0e4504bb2045bbd52c Mon Sep 17 00:00:00 2001 From: Abdelaziz Mahdy Date: Fri, 28 Jun 2024 15:20:53 +0300 Subject: [PATCH 07/10] updating name --- src/features2d/features2d_async.cpp | 2 +- src/features2d/features2d_async.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features2d/features2d_async.cpp b/src/features2d/features2d_async.cpp index 43a57f56..d44de121 100644 --- a/src/features2d/features2d_async.cpp +++ b/src/features2d/features2d_async.cpp @@ -1,4 +1,4 @@ -/* Created by Rainyl. Licensed: Apache 2.0 license. Copyright (c) 2024 Rainyl. */ +/* Created by Abdelaziz Mahdy. Licensed: Apache 2.0 license. Copyright (c) 2024 Abdelaziz Mahdy. */ #include "features2d_async.h" #include "features2d.cpp" diff --git a/src/features2d/features2d_async.h b/src/features2d/features2d_async.h index c281c3d6..2428cb27 100644 --- a/src/features2d/features2d_async.h +++ b/src/features2d/features2d_async.h @@ -1,4 +1,4 @@ -/* Created by Rainyl. Licensed: Apache 2.0 license. Copyright (c) 2024 Rainyl. */ +/* Created by Abdelaziz Mahdy. Licensed: Apache 2.0 license. Copyright (c) 2024 Abdelaziz Mahdy. */ #ifndef CVD_FEATURES2D_ASYNC_H_ #define CVD_FEATURES2D_ASYNC_H_ From 5c61cc3cd72ddbb3b5a39364ee3b8d4e6cdad876 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Fri, 28 Jun 2024 21:35:38 +0800 Subject: [PATCH 08/10] fix redefinition in cpp --- src/features2d/features2d.cpp | 55 +------------------------- src/features2d/features2d_async.cpp | 2 +- src/features2d/utils.hpp | 61 +++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 55 deletions(-) create mode 100644 src/features2d/utils.hpp 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 index d44de121..ac7aadf0 100644 --- a/src/features2d/features2d_async.cpp +++ b/src/features2d/features2d_async.cpp @@ -1,6 +1,6 @@ /* Created by Abdelaziz Mahdy. Licensed: Apache 2.0 license. Copyright (c) 2024 Abdelaziz Mahdy. */ #include "features2d_async.h" -#include "features2d.cpp" +#include "utils.hpp" #include "core/types.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 From 73a861b43fc474e8e4821c4d3ade6175bde83fc9 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Fri, 28 Jun 2024 23:07:42 +0800 Subject: [PATCH 09/10] add doc --- lib/src/features2d/features2d.dart | 58 +++---- lib/src/features2d/features2d_async.dart | 199 +++++++++++++++++------ 2 files changed, 170 insertions(+), 87 deletions(-) diff --git a/lib/src/features2d/features2d.dart b/lib/src/features2d/features2d.dart index 06cd515d..bb16c71e 100644 --- a/lib/src/features2d/features2d.dart +++ b/lib/src/features2d/features2d.dart @@ -22,7 +22,7 @@ class AKAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory AKAZE.fromPointer(cvg.AKAZEPtr ptr, [bool attach = true]) => AKAZE._(ptr.cast(), attach); + factory AKAZE.fromPointer(cvg.AKAZEPtr ptr, [bool attach = true]) => AKAZE._(ptr, attach); /// returns a new AKAZE algorithm /// @@ -78,11 +78,8 @@ class AgastFeatureDetector extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory AgastFeatureDetector.fromPointer( - cvg.AgastFeatureDetectorPtr ptr, [ - bool attach = true, - ]) => - AgastFeatureDetector._(ptr.cast(), attach); + factory AgastFeatureDetector.fromPointer(cvg.AgastFeatureDetectorPtr ptr, [bool attach = true]) => + AgastFeatureDetector._(ptr, attach); /// returns a new AgastFeatureDetector algorithm /// @@ -127,7 +124,7 @@ class BRISK extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory BRISK.fromPointer(cvg.BRISKPtr ptr, [bool attach = true]) => BRISK._(ptr.cast(), attach); + factory BRISK.fromPointer(cvg.BRISKPtr ptr, [bool attach = true]) => BRISK._(ptr, attach); /// returns a new BRISK algorithm /// @@ -197,11 +194,8 @@ class FastFeatureDetector extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory FastFeatureDetector.fromPointer( - cvg.FastFeatureDetectorPtr ptr, [ - bool attach = true, - ]) => - FastFeatureDetector._(ptr.cast(), attach); + factory FastFeatureDetector.fromPointer(cvg.FastFeatureDetectorPtr ptr, [bool attach = true]) => + FastFeatureDetector._(ptr, attach); /// returns a new FastFeatureDetector algorithm /// @@ -267,11 +261,8 @@ class GFTTDetector extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory GFTTDetector.fromPointer( - cvg.GFTTDetectorPtr ptr, [ - bool attach = true, - ]) => - GFTTDetector._(ptr.cast(), attach); + factory GFTTDetector.fromPointer(cvg.GFTTDetectorPtr ptr, [bool attach = true]) => + GFTTDetector._(ptr, attach); /// returns a new GFTTDetector algorithm /// @@ -314,7 +305,7 @@ class KAZE extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory KAZE.fromPointer(cvg.KAZEPtr ptr, [bool attach = true]) => KAZE._(ptr.cast(), attach); + factory KAZE.fromPointer(cvg.KAZEPtr ptr, [bool attach = true]) => KAZE._(ptr, attach); /// returns a new KAZE algorithm /// @@ -370,7 +361,7 @@ class MSER extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory MSER.fromPointer(cvg.MSERPtr ptr, [bool attach = true]) => MSER._(ptr.cast(), attach); + factory MSER.fromPointer(cvg.MSERPtr ptr, [bool attach = true]) => MSER._(ptr, attach); /// returns a new MSER algorithm /// @@ -421,7 +412,7 @@ class ORB extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory ORB.fromPointer(cvg.ORBPtr ptr, [bool attach = true]) => ORB._(ptr.cast(), attach); + factory ORB.fromPointer(cvg.ORBPtr ptr, [bool attach = true]) => ORB._(ptr, attach); /// returns a new ORB algorithm /// @@ -728,11 +719,8 @@ class SimpleBlobDetector extends CvStruct { } } - factory SimpleBlobDetector.fromPointer( - cvg.SimpleBlobDetectorPtr ptr, [ - bool attach = true, - ]) => - SimpleBlobDetector._(ptr.cast(), attach); + factory SimpleBlobDetector.fromPointer(cvg.SimpleBlobDetectorPtr ptr, [bool attach = true]) => + SimpleBlobDetector._(ptr, attach); /// returns a new SimpleBlobDetector algorithm /// @@ -783,8 +771,7 @@ class BFMatcher extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory BFMatcher.fromPointer(cvg.BFMatcherPtr ptr, [bool attach = true]) => - BFMatcher._(ptr.cast(), attach); + factory BFMatcher.fromPointer(cvg.BFMatcherPtr ptr, [bool attach = true]) => BFMatcher._(ptr, attach); /// returns a new BFMatcher algorithm /// @@ -843,11 +830,8 @@ class FlannBasedMatcher extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory FlannBasedMatcher.fromPointer( - cvg.FlannBasedMatcherPtr ptr, [ - bool attach = true, - ]) => - FlannBasedMatcher._(ptr.cast(), attach); + factory FlannBasedMatcher.fromPointer(cvg.FlannBasedMatcherPtr ptr, [bool attach = true]) => + FlannBasedMatcher._(ptr, attach); /// returns a new FlannBasedMatcher algorithm /// @@ -929,7 +913,7 @@ class SIFT extends CvStruct { finalizer.attach(this, ptr.cast(), detach: this); } } - factory SIFT.fromPointer(cvg.SIFTPtr ptr, [bool attach = true]) => SIFT._(ptr.cast(), attach); + factory SIFT.fromPointer(cvg.SIFTPtr ptr, [bool attach = true]) => SIFT._(ptr, attach); /// returns a new SIFT algorithm /// @@ -978,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 index b018d513..48a83db7 100644 --- a/lib/src/features2d/features2d_async.dart +++ b/lib/src/features2d/features2d_async.dart @@ -1,7 +1,6 @@ library cv; -import 'package:opencv_dart/src/constants.g.dart'; - +import '../constants.g.dart'; import '../core/base.dart'; import '../core/dmatch.dart'; import '../core/keypoint.dart'; @@ -12,11 +11,19 @@ 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), @@ -25,6 +32,10 @@ extension AKAZEAsync on AKAZE { 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 { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( @@ -35,24 +46,26 @@ extension AKAZEAsync on AKAZE { desc.ref, callback, ), - (c, keypoints) => c.complete( - (VecKeyPoint.fromPointer(keypoints.cast()), desc), - ), + (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), ); return rval; } } 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(), - ), - ), + (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), @@ -63,11 +76,19 @@ extension AgastFeatureDetectorAsync on AgastFeatureDetector { } 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), @@ -76,6 +97,10 @@ extension BRISKAsync on BRISK { 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 { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( @@ -86,22 +111,26 @@ extension BRISKAsync on BRISK { desc.ref, callback, ), - (c, keypoints) => c.complete( - (VecKeyPoint.fromPointer(keypoints.cast()), desc), - ), + (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), ); return rval; } } 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()), - ), + (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, @@ -114,13 +143,13 @@ extension FastFeatureDetectorAsync on FastFeatureDetector { type.value, callback, ), - (c, p) => c.complete( - FastFeatureDetector.fromPointer( - p.cast(), - ), - ), + (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), @@ -131,11 +160,19 @@ extension FastFeatureDetectorAsync on FastFeatureDetector { } 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), @@ -146,11 +183,19 @@ extension GFTTDetectorAsync on GFTTDetector { } 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), @@ -159,6 +204,10 @@ extension KAZEAsync on KAZE { 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 { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( @@ -178,11 +227,19 @@ extension KAZEAsync on KAZE { } 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), @@ -193,11 +250,17 @@ extension MSERAsync on MSER { } extension ORBAsync on ORB { - static Future emptyAsync() async => cvRunAsync( - CFFI.ORB_Create_Async, - (c, p) => c.complete(ORB.fromPointer(p.cast())), - ); - + /// 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, @@ -225,6 +288,10 @@ extension ORBAsync on ORB { (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), @@ -233,6 +300,10 @@ extension ORBAsync on ORB { 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 { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( @@ -243,20 +314,20 @@ extension ORBAsync on ORB { desc.ref, callback, ), - (c, keypoints) => c.complete( - (VecKeyPoint.fromPointer(keypoints.cast()), desc), - ), + (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), ); return rval; } } 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()), - ), + (c, p) => c.complete(SimpleBlobDetector.fromPointer(p.cast())), ); static Future createAsync( @@ -268,12 +339,14 @@ extension SimpleBlobDetectorAsync on SimpleBlobDetector { callback, ), (c, p) => c.complete( - SimpleBlobDetector.fromPointer( - p.cast(), - ), + 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), @@ -284,6 +357,10 @@ extension SimpleBlobDetectorAsync on SimpleBlobDetector { } 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())), @@ -298,6 +375,10 @@ extension BFMatcherAsync on BFMatcher { (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), @@ -306,6 +387,10 @@ extension BFMatcherAsync on BFMatcher { 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( @@ -322,13 +407,19 @@ extension BFMatcherAsync on BFMatcher { } 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()), - ), + (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( @@ -345,11 +436,17 @@ extension FlannBasedMatcherAsync on FlannBasedMatcher { } extension SIFTAsync on SIFT { - static Future emptyAsync() async => cvRunAsync( - CFFI.SIFT_Create_Async, - (c, p) => c.complete(SIFT.fromPointer(p.cast())), - ); - + /// 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), @@ -358,6 +455,10 @@ extension SIFTAsync on SIFT { 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 { final desc = Mat.empty(); final rval = cvRunAsync<(VecKeyPoint, Mat)>( @@ -368,13 +469,7 @@ extension SIFTAsync on SIFT { desc.ref, callback, ), - ( - c, - keypoints, - ) => - c.complete( - (VecKeyPoint.fromPointer(keypoints.cast()), desc), - ), + (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), ); return rval; } @@ -400,6 +495,10 @@ Future drawKeyPointsAsync( ); } +/// 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, From 99e395bf52a09c86fab24df7a25683f4b765dd73 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Sat, 29 Jun 2024 10:11:26 +0800 Subject: [PATCH 10/10] fix desc=Mat.empty() --- lib/src/features2d/features2d_async.dart | 151 ++++++++++---------- lib/src/opencv.g.dart | 168 +++++++++++------------ src/features2d/features2d_async.cpp | 159 ++++++++++----------- src/features2d/features2d_async.h | 60 ++++---- 4 files changed, 269 insertions(+), 269 deletions(-) diff --git a/lib/src/features2d/features2d_async.dart b/lib/src/features2d/features2d_async.dart index 48a83db7..11c39690 100644 --- a/lib/src/features2d/features2d_async.dart +++ b/lib/src/features2d/features2d_async.dart @@ -1,3 +1,5 @@ +// ignore_for_file: non_constant_identifier_names + library cv; import '../constants.g.dart'; @@ -36,20 +38,21 @@ extension AKAZEAsync on 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 { - final desc = Mat.empty(); - final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.AKAZE_DetectAndCompute_Async( - ref, - src.ref, - mask.ref, - desc.ref, - callback, - ), - (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), - ); - return rval; - } + 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 { @@ -101,20 +104,21 @@ extension BRISKAsync on 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 { - final desc = Mat.empty(); - final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.BRISK_DetectAndCompute_Async( - ref, - src.ref, - mask.ref, - desc.ref, - callback, - ), - (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), - ); - return rval; - } + 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 { @@ -208,22 +212,21 @@ extension KAZEAsync on 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 { - final desc = Mat.empty(); - final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.KAZE_DetectAndCompute_Async( - ref, - src.ref, - mask.ref, - desc.ref, - callback, - ), - (c, keypoints) => c.complete( - (VecKeyPoint.fromPointer(keypoints.cast()), desc), - ), - ); - return rval; - } + 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 { @@ -304,20 +307,21 @@ extension ORBAsync on 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 { - final desc = Mat.empty(); - final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.ORB_DetectAndCompute_Async( - ref, - src.ref, - mask.ref, - desc.ref, - callback, - ), - (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), - ); - return rval; - } + 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 { @@ -459,20 +463,21 @@ extension SIFTAsync on 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 { - final desc = Mat.empty(); - final rval = cvRunAsync<(VecKeyPoint, Mat)>( - (callback) => CFFI.SIFT_DetectAndCompute_Async( - ref, - src.ref, - mask.ref, - desc.ref, - callback, - ), - (c, keypoints) => c.complete((VecKeyPoint.fromPointer(keypoints.cast()), desc)), - ); - return rval; - } + 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( @@ -513,7 +518,7 @@ Future drawMatchesAsync( }) async { matchColor ??= Scalar.all(-1); singlePointColor ??= Scalar.all(-1); - matchesMask ??= VecChar.fromList([]); + matchesMask ??= VecChar(); await cvRunAsync0( (callback) => CFFI.DrawMatches_Async( img1.ref, diff --git a/lib/src/opencv.g.dart b/lib/src/opencv.g.dart index f13ffcec..31775d22 100644 --- a/lib/src/opencv.g.dart +++ b/lib/src/opencv.g.dart @@ -42,11 +42,11 @@ class CvNative { _AKAZE_ClosePtr.asFunction(); ffi.Pointer AKAZE_Close_Async( - AKAZEPtr a, + AKAZEPtr self, CvCallback_0 callback, ) { return _AKAZE_Close_Async( - a, + self, callback, ); } @@ -130,36 +130,34 @@ class CvNative { AKAZE, Mat, Mat, Mat, ffi.Pointer)>(); ffi.Pointer AKAZE_DetectAndCompute_Async( - AKAZE a, + AKAZE self, Mat src, Mat mask, - Mat desc, - CvCallback_1 callback, + CvCallback_2 callback, ) { return _AKAZE_DetectAndCompute_Async( - a, + self, src, mask, - desc, callback, ); } late final _AKAZE_DetectAndCompute_AsyncPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(AKAZE, Mat, Mat, Mat, - CvCallback_1)>>('AKAZE_DetectAndCompute_Async'); + 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, Mat, CvCallback_1)>(); + ffi.Pointer Function(AKAZE, Mat, Mat, CvCallback_2)>(); ffi.Pointer AKAZE_Detect_Async( - AKAZE a, + AKAZE self, Mat src, CvCallback_1 callback, ) { return _AKAZE_Detect_Async( - a, + self, src, callback, ); @@ -243,11 +241,11 @@ class CvNative { .asFunction(); ffi.Pointer AgastFeatureDetector_Close_Async( - AgastFeatureDetectorPtr a, + AgastFeatureDetectorPtr self, CvCallback_0 callback, ) { return _AgastFeatureDetector_Close_Async( - a, + self, callback, ); } @@ -315,12 +313,12 @@ class CvNative { AgastFeatureDetector, Mat, ffi.Pointer)>(); ffi.Pointer AgastFeatureDetector_Detect_Async( - AgastFeatureDetector a, + AgastFeatureDetector self, Mat src, CvCallback_1 callback, ) { return _AgastFeatureDetector_Detect_Async( - a, + self, src, callback, ); @@ -2002,11 +2000,11 @@ class CvNative { _BFMatcher_ClosePtr.asFunction(); ffi.Pointer BFMatcher_Close_Async( - BFMatcherPtr b, + BFMatcherPtr self, CvCallback_0 callback, ) { return _BFMatcher_Close_Async( - b, + self, callback, ); } @@ -2112,14 +2110,14 @@ class CvNative { BFMatcher, Mat, Mat, int, ffi.Pointer)>(); ffi.Pointer BFMatcher_KnnMatch_Async( - BFMatcher b, + BFMatcher self, Mat query, Mat train, int k, CvCallback_1 callback, ) { return _BFMatcher_KnnMatch_Async( - b, + self, query, train, k, @@ -2159,13 +2157,13 @@ class CvNative { BFMatcher, Mat, Mat, ffi.Pointer)>(); ffi.Pointer BFMatcher_Match_Async( - BFMatcher b, + BFMatcher self, Mat query, Mat train, CvCallback_1 callback, ) { return _BFMatcher_Match_Async( - b, + self, query, train, callback, @@ -2193,11 +2191,11 @@ class CvNative { _BRISK_ClosePtr.asFunction(); ffi.Pointer BRISK_Close_Async( - BRISKPtr b, + BRISKPtr self, CvCallback_0 callback, ) { return _BRISK_Close_Async( - b, + self, callback, ); } @@ -2281,36 +2279,34 @@ class CvNative { BRISK, Mat, Mat, Mat, ffi.Pointer)>(); ffi.Pointer BRISK_DetectAndCompute_Async( - BRISK b, + BRISK self, Mat src, Mat mask, - Mat desc, - CvCallback_1 callback, + CvCallback_2 callback, ) { return _BRISK_DetectAndCompute_Async( - b, + self, src, mask, - desc, callback, ); } late final _BRISK_DetectAndCompute_AsyncPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(BRISK, Mat, Mat, Mat, - CvCallback_1)>>('BRISK_DetectAndCompute_Async'); + 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, Mat, CvCallback_1)>(); + ffi.Pointer Function(BRISK, Mat, Mat, CvCallback_2)>(); ffi.Pointer BRISK_Detect_Async( - BRISK b, + BRISK self, Mat src, CvCallback_1 callback, ) { return _BRISK_Detect_Async( - b, + self, src, callback, ); @@ -6193,11 +6189,11 @@ class CvNative { .asFunction(); ffi.Pointer FastFeatureDetector_Close_Async( - FastFeatureDetectorPtr f, + FastFeatureDetectorPtr self, CvCallback_0 callback, ) { return _FastFeatureDetector_Close_Async( - f, + self, callback, ); } @@ -6310,12 +6306,12 @@ class CvNative { FastFeatureDetector, Mat, ffi.Pointer)>(); ffi.Pointer FastFeatureDetector_Detect_Async( - FastFeatureDetector f, + FastFeatureDetector self, Mat src, CvCallback_1 callback, ) { return _FastFeatureDetector_Detect_Async( - f, + self, src, callback, ); @@ -7035,11 +7031,11 @@ class CvNative { void Function(FlannBasedMatcherPtr)>(); ffi.Pointer FlannBasedMatcher_Close_Async( - FlannBasedMatcherPtr f, + FlannBasedMatcherPtr self, CvCallback_0 callback, ) { return _FlannBasedMatcher_Close_Async( - f, + self, callback, ); } @@ -7109,14 +7105,14 @@ class CvNative { FlannBasedMatcher, Mat, Mat, int, ffi.Pointer)>(); ffi.Pointer FlannBasedMatcher_KnnMatch_Async( - FlannBasedMatcher f, + FlannBasedMatcher self, Mat query, Mat train, int k, CvCallback_1 callback, ) { return _FlannBasedMatcher_KnnMatch_Async( - f, + self, query, train, k, @@ -7320,11 +7316,11 @@ class CvNative { _GFTTDetector_ClosePtr.asFunction(); ffi.Pointer GFTTDetector_Close_Async( - GFTTDetectorPtr a, + GFTTDetectorPtr self, CvCallback_0 callback, ) { return _GFTTDetector_Close_Async( - a, + self, callback, ); } @@ -7387,12 +7383,12 @@ class CvNative { GFTTDetector, Mat, ffi.Pointer)>(); ffi.Pointer GFTTDetector_Detect_Async( - GFTTDetector a, + GFTTDetector self, Mat src, CvCallback_1 callback, ) { return _GFTTDetector_Detect_Async( - a, + self, src, callback, ); @@ -9726,11 +9722,11 @@ class CvNative { late final _KAZE_Close = _KAZE_ClosePtr.asFunction(); ffi.Pointer KAZE_Close_Async( - KAZEPtr a, + KAZEPtr self, CvCallback_0 callback, ) { return _KAZE_Close_Async( - a, + self, callback, ); } @@ -9814,36 +9810,34 @@ class CvNative { KAZE, Mat, Mat, Mat, ffi.Pointer)>(); ffi.Pointer KAZE_DetectAndCompute_Async( - KAZE a, + KAZE self, Mat src, Mat mask, - Mat desc, - CvCallback_1 callback, + CvCallback_2 callback, ) { return _KAZE_DetectAndCompute_Async( - a, + self, src, mask, - desc, callback, ); } late final _KAZE_DetectAndCompute_AsyncPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(KAZE, Mat, Mat, Mat, - CvCallback_1)>>('KAZE_DetectAndCompute_Async'); + 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, Mat, CvCallback_1)>(); + ffi.Pointer Function(KAZE, Mat, Mat, CvCallback_2)>(); ffi.Pointer KAZE_Detect_Async( - KAZE a, + KAZE self, Mat src, CvCallback_1 callback, ) { return _KAZE_Detect_Async( - a, + self, src, callback, ); @@ -10911,11 +10905,11 @@ class CvNative { late final _MSER_Close = _MSER_ClosePtr.asFunction(); ffi.Pointer MSER_Close_Async( - MSERPtr a, + MSERPtr self, CvCallback_0 callback, ) { return _MSER_Close_Async( - a, + self, callback, ); } @@ -10975,12 +10969,12 @@ class CvNative { ffi.Pointer Function(MSER, Mat, ffi.Pointer)>(); ffi.Pointer MSER_Detect_Async( - MSER a, + MSER self, Mat src, CvCallback_1 callback, ) { return _MSER_Detect_Async( - a, + self, src, callback, ); @@ -17928,11 +17922,11 @@ class CvNative { late final _ORB_Close = _ORB_ClosePtr.asFunction(); ffi.Pointer ORB_Close_Async( - ORBPtr o, + ORBPtr self, CvCallback_0 callback, ) { return _ORB_Close_Async( - o, + self, callback, ); } @@ -18103,17 +18097,15 @@ class CvNative { ORB, Mat, Mat, Mat, ffi.Pointer)>(); ffi.Pointer ORB_DetectAndCompute_Async( - ORB o, + ORB self, Mat src, Mat mask, - Mat desc, - CvCallback_1 callback, + CvCallback_2 callback, ) { return _ORB_DetectAndCompute_Async( - o, + self, src, mask, - desc, callback, ); } @@ -18121,18 +18113,18 @@ class CvNative { late final _ORB_DetectAndCompute_AsyncPtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( - ORB, Mat, Mat, Mat, CvCallback_1)>>('ORB_DetectAndCompute_Async'); + ORB, Mat, Mat, CvCallback_2)>>('ORB_DetectAndCompute_Async'); late final _ORB_DetectAndCompute_Async = _ORB_DetectAndCompute_AsyncPtr.asFunction< - ffi.Pointer Function(ORB, Mat, Mat, Mat, CvCallback_1)>(); + ffi.Pointer Function(ORB, Mat, Mat, CvCallback_2)>(); ffi.Pointer ORB_Detect_Async( - ORB o, + ORB self, Mat src, CvCallback_1 callback, ) { return _ORB_Detect_Async( - o, + self, src, callback, ); @@ -19814,11 +19806,11 @@ class CvNative { late final _SIFT_Close = _SIFT_ClosePtr.asFunction(); ffi.Pointer SIFT_Close_Async( - SIFTPtr f, + SIFTPtr self, CvCallback_0 callback, ) { return _SIFT_Close_Async( - f, + self, callback, ); } @@ -19902,36 +19894,34 @@ class CvNative { SIFT, Mat, Mat, Mat, ffi.Pointer)>(); ffi.Pointer SIFT_DetectAndCompute_Async( - SIFT f, + SIFT self, Mat src, Mat mask, - Mat desc, - CvCallback_1 callback, + CvCallback_2 callback, ) { return _SIFT_DetectAndCompute_Async( - f, + self, src, mask, - desc, callback, ); } late final _SIFT_DetectAndCompute_AsyncPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(SIFT, Mat, Mat, Mat, - CvCallback_1)>>('SIFT_DetectAndCompute_Async'); + 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, Mat, CvCallback_1)>(); + ffi.Pointer Function(SIFT, Mat, Mat, CvCallback_2)>(); ffi.Pointer SIFT_Detect_Async( - SIFT f, + SIFT self, Mat src, CvCallback_1 callback, ) { return _SIFT_Detect_Async( - f, + self, src, callback, ); @@ -20239,11 +20229,11 @@ class CvNative { .asFunction(); ffi.Pointer SimpleBlobDetector_Close_Async( - SimpleBlobDetectorPtr b, + SimpleBlobDetectorPtr self, CvCallback_0 callback, ) { return _SimpleBlobDetector_Close_Async( - b, + self, callback, ); } @@ -20349,12 +20339,12 @@ class CvNative { SimpleBlobDetector, Mat, ffi.Pointer)>(); ffi.Pointer SimpleBlobDetector_Detect_Async( - SimpleBlobDetector b, + SimpleBlobDetector self, Mat src, CvCallback_1 callback, ) { return _SimpleBlobDetector_Detect_Async( - b, + self, src, callback, ); diff --git a/src/features2d/features2d_async.cpp b/src/features2d/features2d_async.cpp index ac7aadf0..85bbefbe 100644 --- a/src/features2d/features2d_async.cpp +++ b/src/features2d/features2d_async.cpp @@ -12,30 +12,31 @@ CvStatus *AKAZE_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *AKAZE_Close_Async(AKAZEPtr a, CvCallback_0 callback) +CvStatus *AKAZE_Close_Async(AKAZEPtr self, CvCallback_0 callback) { BEGIN_WRAP - a->ptr->reset(); - CVD_FREE(a); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *AKAZE_Detect_Async(AKAZE a, Mat src, CvCallback_1 callback) +CvStatus *AKAZE_Detect_Async(AKAZE self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*a.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } -CvStatus *AKAZE_DetectAndCompute_Async(AKAZE a, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +CvStatus *AKAZE_DetectAndCompute_Async(AKAZE self, Mat src, Mat mask, CvCallback_2 callback) { BEGIN_WRAP std::vector detected; - (*a.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); - callback(new VecKeyPoint{new 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 } @@ -47,20 +48,20 @@ CvStatus *AgastFeatureDetector_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *AgastFeatureDetector_Close_Async(AgastFeatureDetectorPtr a, CvCallback_0 callback) +CvStatus *AgastFeatureDetector_Close_Async(AgastFeatureDetectorPtr self, CvCallback_0 callback) { BEGIN_WRAP - a->ptr->reset(); - CVD_FREE(a); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *AgastFeatureDetector_Detect_Async(AgastFeatureDetector a, Mat src, CvCallback_1 callback) +CvStatus *AgastFeatureDetector_Detect_Async(AgastFeatureDetector self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*a.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } @@ -73,30 +74,31 @@ CvStatus *BRISK_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *BRISK_Close_Async(BRISKPtr b, CvCallback_0 callback) +CvStatus *BRISK_Close_Async(BRISKPtr self, CvCallback_0 callback) { BEGIN_WRAP - b->ptr->reset(); - CVD_FREE(b); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *BRISK_Detect_Async(BRISK b, Mat src, CvCallback_1 callback) +CvStatus *BRISK_Detect_Async(BRISK self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*b.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } -CvStatus *BRISK_DetectAndCompute_Async(BRISK b, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +CvStatus *BRISK_DetectAndCompute_Async(BRISK self, Mat src, Mat mask, CvCallback_2 callback) { BEGIN_WRAP std::vector detected; - (*b.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); - callback(new VecKeyPoint{new 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 } @@ -116,20 +118,20 @@ CvStatus *FastFeatureDetector_CreateWithParams_Async(int threshold, bool nonmaxS END_WRAP } -CvStatus *FastFeatureDetector_Close_Async(FastFeatureDetectorPtr f, CvCallback_0 callback) +CvStatus *FastFeatureDetector_Close_Async(FastFeatureDetectorPtr self, CvCallback_0 callback) { BEGIN_WRAP - f->ptr->reset(); - CVD_FREE(f); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *FastFeatureDetector_Detect_Async(FastFeatureDetector f, Mat src, CvCallback_1 callback) +CvStatus *FastFeatureDetector_Detect_Async(FastFeatureDetector self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*f.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } @@ -142,20 +144,20 @@ CvStatus *GFTTDetector_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *GFTTDetector_Close_Async(GFTTDetectorPtr a, CvCallback_0 callback) +CvStatus *GFTTDetector_Close_Async(GFTTDetectorPtr self, CvCallback_0 callback) { BEGIN_WRAP - a->ptr->reset(); - CVD_FREE(a); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *GFTTDetector_Detect_Async(GFTTDetector a, Mat src, CvCallback_1 callback) +CvStatus *GFTTDetector_Detect_Async(GFTTDetector self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*a.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } @@ -168,30 +170,31 @@ CvStatus *KAZE_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *KAZE_Close_Async(KAZEPtr a, CvCallback_0 callback) +CvStatus *KAZE_Close_Async(KAZEPtr self, CvCallback_0 callback) { BEGIN_WRAP - a->ptr->reset(); - CVD_FREE(a); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *KAZE_Detect_Async(KAZE a, Mat src, CvCallback_1 callback) +CvStatus *KAZE_Detect_Async(KAZE self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*a.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } -CvStatus *KAZE_DetectAndCompute_Async(KAZE a, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +CvStatus *KAZE_DetectAndCompute_Async(KAZE self, Mat src, Mat mask, CvCallback_2 callback) { BEGIN_WRAP std::vector detected; - (*a.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); - callback(new VecKeyPoint{new 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 } @@ -203,20 +206,20 @@ CvStatus *MSER_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *MSER_Close_Async(MSERPtr a, CvCallback_0 callback) +CvStatus *MSER_Close_Async(MSERPtr self, CvCallback_0 callback) { BEGIN_WRAP - a->ptr->reset(); - CVD_FREE(a); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *MSER_Detect_Async(MSER a, Mat src, CvCallback_1 callback) +CvStatus *MSER_Detect_Async(MSER self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*a.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } @@ -237,30 +240,31 @@ CvStatus *ORB_CreateWithParams_Async(int nfeatures, float scaleFactor, int nleve END_WRAP } -CvStatus *ORB_Close_Async(ORBPtr o, CvCallback_0 callback) +CvStatus *ORB_Close_Async(ORBPtr self, CvCallback_0 callback) { BEGIN_WRAP - o->ptr->reset(); - CVD_FREE(o); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *ORB_Detect_Async(ORB o, Mat src, CvCallback_1 callback) +CvStatus *ORB_Detect_Async(ORB self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*o.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } -CvStatus *ORB_DetectAndCompute_Async(ORB o, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +CvStatus *ORB_DetectAndCompute_Async(ORB self, Mat src, Mat mask, CvCallback_2 callback) { BEGIN_WRAP std::vector detected; - (*o.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); - callback(new VecKeyPoint{new 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 } @@ -279,20 +283,20 @@ CvStatus *SimpleBlobDetector_Create_WithParams_Async(SimpleBlobDetectorParams pa END_WRAP } -CvStatus *SimpleBlobDetector_Close_Async(SimpleBlobDetectorPtr b, CvCallback_0 callback) +CvStatus *SimpleBlobDetector_Close_Async(SimpleBlobDetectorPtr self, CvCallback_0 callback) { BEGIN_WRAP - b->ptr->reset(); - CVD_FREE(b); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *SimpleBlobDetector_Detect_Async(SimpleBlobDetector b, Mat src, CvCallback_1 callback) +CvStatus *SimpleBlobDetector_Detect_Async(SimpleBlobDetector self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*b.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } @@ -312,29 +316,29 @@ CvStatus *BFMatcher_CreateWithParams_Async(int normType, bool crossCheck, CvCall END_WRAP } -CvStatus *BFMatcher_Close_Async(BFMatcherPtr b, CvCallback_0 callback) +CvStatus *BFMatcher_Close_Async(BFMatcherPtr self, CvCallback_0 callback) { BEGIN_WRAP - b->ptr->reset(); - CVD_FREE(b); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *BFMatcher_Match_Async(BFMatcher b, Mat query, Mat train, CvCallback_1 callback) +CvStatus *BFMatcher_Match_Async(BFMatcher self, Mat query, Mat train, CvCallback_1 callback) { BEGIN_WRAP std::vector matches; - (*b.ptr)->match(*query.ptr, *train.ptr, matches); + (*self.ptr)->match(*query.ptr, *train.ptr, matches); callback(new VecDMatch{new std::vector(matches)}); END_WRAP } -CvStatus *BFMatcher_KnnMatch_Async(BFMatcher b, Mat query, Mat train, int k, CvCallback_1 callback) +CvStatus *BFMatcher_KnnMatch_Async(BFMatcher self, Mat query, Mat train, int k, CvCallback_1 callback) { BEGIN_WRAP std::vector> matches; - (*b.ptr)->knnMatch(*query.ptr, *train.ptr, matches, k); + (*self.ptr)->knnMatch(*query.ptr, *train.ptr, matches, k); callback(new VecVecDMatch{new std::vector>(matches)}); END_WRAP } @@ -347,20 +351,20 @@ CvStatus *FlannBasedMatcher_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *FlannBasedMatcher_Close_Async(FlannBasedMatcherPtr f, CvCallback_0 callback) +CvStatus *FlannBasedMatcher_Close_Async(FlannBasedMatcherPtr self, CvCallback_0 callback) { BEGIN_WRAP - f->ptr->reset(); - CVD_FREE(f); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *FlannBasedMatcher_KnnMatch_Async(FlannBasedMatcher f, Mat query, Mat train, int k, CvCallback_1 callback) +CvStatus *FlannBasedMatcher_KnnMatch_Async(FlannBasedMatcher self, Mat query, Mat train, int k, CvCallback_1 callback) { BEGIN_WRAP std::vector> matches; - (*f.ptr)->knnMatch(*query.ptr, *train.ptr, matches, k); + (*self.ptr)->knnMatch(*query.ptr, *train.ptr, matches, k); callback(new VecVecDMatch{new std::vector>(matches)}); END_WRAP } @@ -393,29 +397,30 @@ CvStatus *SIFT_Create_Async(CvCallback_1 callback) END_WRAP } -CvStatus *SIFT_Close_Async(SIFTPtr f, CvCallback_0 callback) +CvStatus *SIFT_Close_Async(SIFTPtr self, CvCallback_0 callback) { BEGIN_WRAP - f->ptr->reset(); - CVD_FREE(f); + self->ptr->reset(); + CVD_FREE(self); callback(); END_WRAP } -CvStatus *SIFT_Detect_Async(SIFT f, Mat src, CvCallback_1 callback) +CvStatus *SIFT_Detect_Async(SIFT self, Mat src, CvCallback_1 callback) { BEGIN_WRAP std::vector detected; - (*f.ptr)->detect(*src.ptr, detected); + (*self.ptr)->detect(*src.ptr, detected); callback(new VecKeyPoint{new std::vector(detected)}); END_WRAP } -CvStatus *SIFT_DetectAndCompute_Async(SIFT f, Mat src, Mat mask, Mat desc, CvCallback_1 callback) +CvStatus *SIFT_DetectAndCompute_Async(SIFT self, Mat src, Mat mask, CvCallback_2 callback) { BEGIN_WRAP std::vector detected; - (*f.ptr)->detectAndCompute(*src.ptr, *mask.ptr, detected, *desc.ptr); - callback(new VecKeyPoint{new 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 index 2428cb27..200bdd0e 100644 --- a/src/features2d/features2d_async.h +++ b/src/features2d/features2d_async.h @@ -13,67 +13,67 @@ extern "C" { // AKAZE CvStatus *AKAZE_Create_Async(CvCallback_1 callback); -CvStatus *AKAZE_Close_Async(AKAZEPtr a, CvCallback_0 callback); -CvStatus *AKAZE_Detect_Async(AKAZE a, Mat src, CvCallback_1 callback); -CvStatus *AKAZE_DetectAndCompute_Async(AKAZE a, Mat src, Mat mask, Mat desc, 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 a, CvCallback_0 callback); -CvStatus *AgastFeatureDetector_Detect_Async(AgastFeatureDetector a, Mat src, 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 b, CvCallback_0 callback); -CvStatus *BRISK_Detect_Async(BRISK b, Mat src, CvCallback_1 callback); -CvStatus *BRISK_DetectAndCompute_Async(BRISK b, Mat src, Mat mask, Mat desc, 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 f, CvCallback_0 callback); -CvStatus *FastFeatureDetector_Detect_Async(FastFeatureDetector f, Mat src, 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 a, CvCallback_0 callback); -CvStatus *GFTTDetector_Detect_Async(GFTTDetector a, Mat src, 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 a, CvCallback_0 callback); -CvStatus *KAZE_Detect_Async(KAZE a, Mat src, CvCallback_1 callback); -CvStatus *KAZE_DetectAndCompute_Async(KAZE a, Mat src, Mat mask, Mat desc, 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 a, CvCallback_0 callback); -CvStatus *MSER_Detect_Async(MSER a, Mat src, 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 o, CvCallback_0 callback); -CvStatus *ORB_Detect_Async(ORB o, Mat src, CvCallback_1 callback); -CvStatus *ORB_DetectAndCompute_Async(ORB o, Mat src, Mat mask, Mat desc, 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 b, CvCallback_0 callback); -CvStatus *SimpleBlobDetector_Detect_Async(SimpleBlobDetector b, Mat src, 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 b, CvCallback_0 callback); -CvStatus *BFMatcher_Match_Async(BFMatcher b, Mat query, Mat train, CvCallback_1 callback); -CvStatus *BFMatcher_KnnMatch_Async(BFMatcher b, Mat query, Mat train, int k, 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 f, CvCallback_0 callback); -CvStatus *FlannBasedMatcher_KnnMatch_Async(FlannBasedMatcher f, Mat query, Mat train, int k, 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); @@ -81,9 +81,9 @@ CvStatus *DrawMatches_Async(Mat img1, VecKeyPoint kp1, Mat img2, VecKeyPoint kp2 // SIFT CvStatus *SIFT_Create_Async(CvCallback_1 callback); -CvStatus *SIFT_Close_Async(SIFTPtr f, CvCallback_0 callback); -CvStatus *SIFT_Detect_Async(SIFT f, Mat src, CvCallback_1 callback); -CvStatus *SIFT_DetectAndCompute_Async(SIFT f, Mat src, Mat mask, Mat desc, 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 }