From 8df83f95b989907da463b08d8ed0426702e0d4ec Mon Sep 17 00:00:00 2001 From: rainyl Date: Sat, 18 May 2024 12:59:32 +0800 Subject: [PATCH] New API: cv.Subdiv2D --- lib/src/imgproc/imgproc.dart | 17 -- lib/src/imgproc/subdiv2d.dart | 253 +++++++++++++++++ lib/src/opencv.dart | 4 + lib/src/opencv.g.dart | 402 +++++++++++++++++++++++++-- src/core/core.h | 1 - src/imgproc/imgproc.cpp | 176 +++++++++--- src/imgproc/imgproc.h | 102 +++++-- test/imgproc/clahe_test.dart | 12 + test/{ => imgproc}/imgproc_test.dart | 0 9 files changed, 866 insertions(+), 101 deletions(-) create mode 100644 lib/src/imgproc/subdiv2d.dart create mode 100644 test/imgproc/clahe_test.dart rename test/{ => imgproc}/imgproc_test.dart (100%) diff --git a/lib/src/imgproc/imgproc.dart b/lib/src/imgproc/imgproc.dart index ffa4a9b3..026eedbf 100644 --- a/lib/src/imgproc/imgproc.dart +++ b/lib/src/imgproc/imgproc.dart @@ -6,7 +6,6 @@ import 'dart:ffi' as ffi; import 'package:ffi/ffi.dart'; -import '../../opencv_dart.dart'; import '../core/contours.dart'; import '../core/scalar.dart'; import '../core/base.dart'; @@ -21,22 +20,6 @@ import '../core/termcriteria.dart'; import '../constants.g.dart'; import '../opencv.g.dart' as cvg; -List getTriangles(List pts) { - final p = calloc>(); - final pSize = malloc(); - cvRun(() => CFFI.GetTriangles(pts.cvd.ref, p, pSize)); - return List.generate( - pSize.value, - (index) => Vec6f( - p.value[index].val1, - p.value[index].val2, - p.value[index].val3, - p.value[index].val4, - p.value[index].val5, - p.value[index].val6, - )); -} - /// ApproxPolyDP approximates a polygonal curve(s) with the specified precision. /// /// For further details, please see: diff --git a/lib/src/imgproc/subdiv2d.dart b/lib/src/imgproc/subdiv2d.dart new file mode 100644 index 00000000..be4de4e2 --- /dev/null +++ b/lib/src/imgproc/subdiv2d.dart @@ -0,0 +1,253 @@ +// ignore_for_file: constant_identifier_names + +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; + +import '../core/base.dart'; +import '../core/cv_vec.dart'; +import '../core/point.dart'; +import '../core/rect.dart'; +import '../core/vec.dart'; +import '../opencv.g.dart' as cvg; + +class Subdiv2D extends CvStruct { + Subdiv2D._(cvg.Subdiv2DPtr ptr) : super.fromPointer(ptr) { + finalizer.attach(this, ptr.cast()); + } + + factory Subdiv2D.empty() { + final p = calloc(); + cvRun(() => CFFI.Subdiv2D_NewEmpty(p)); + return Subdiv2D._(p); + } + + factory Subdiv2D.fromRect(Rect rect) { + final p = calloc(); + cvRun(() => CFFI.Subdiv2D_NewWithRect(rect.ref, p)); + return Subdiv2D._(p); + } + + static final finalizer = OcvFinalizer(CFFI.addresses.Subdiv2D_Close); + + /// Returns the edge destination. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#aee192f95bf19c74619641496c457586d + (int rval, Point2f dstpt) edgeDst(int edge) { + return using<(int, Point2f)>((arena) { + final pp = calloc(); + final p = arena(); + cvRun(() => CFFI.Subdiv2D_EdgeDst(ref, edge, pp, p)); + return (p.value, Point2f.fromPointer(pp)); + }); + } + + /// Returns the edge origin. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a5563e3cae0a9b95df63e72f0c12f9389 + (int rval, Point2f orgpt) edgeOrg(int edge) { + return using<(int, Point2f)>((arena) { + final pp = calloc(); + final p = arena(); + cvRun(() => CFFI.Subdiv2D_EdgeOrg(ref, edge, pp, p)); + return (p.value, Point2f.fromPointer(pp)); + }); + } + + /// Finds the subdivision vertex closest to the given point. + /// + /// The function is another function that locates the input point within the subdivision. + /// It finds the subdivision vertex that is the closest to the input point. + /// It is not necessarily one of vertices of the facet containing the input point, + /// though the facet (located using locate() ) is used as a starting point. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a3ec256af000e129e08eb5f269ccdeb0f + (int rval, Point2f nearestPt) findNearest(Point2f pt) { + return using<(int, Point2f)>((arena) { + final pp = calloc(); + final p = arena(); + cvRun(() => CFFI.Subdiv2D_FindNearest(ref, pt.ref, pp, p)); + return (p.value, Point2f.fromPointer(pp)); + }); + } + + /// Returns one of the edges related to the given edge. + /// + /// [nextEdgeType] : Parameter specifying which of the related edges to return. + /// The following values are possible: + /// + /// - [NEXT_AROUND_ORG] next around the edge origin ( eOnext on the picture below if e is the input edge) + /// - [NEXT_AROUND_DST] next around the edge vertex ( eDnext ) + /// - [PREV_AROUND_ORG] previous around the edge origin (reversed eRnext ) + /// - [PREV_AROUND_DST] previous around the edge destination (reversed eLnext ) + /// - [NEXT_AROUND_LEFT] next around the left facet ( eLnext ) + /// - [NEXT_AROUND_RIGHT] next around the right facet ( eRnext ) + /// - [PREV_AROUND_LEFT] previous around the left facet (reversed eOnext ) + /// - [PREV_AROUND_RIGHT] previous around the right facet (reversed eDnext ) + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#af73f08576709bad7a36f8f8e5fc43c84 + int getEdge(int edge, int nextEdgeType) { + return using((arena) { + final p = arena(); + cvRun(() => CFFI.Subdiv2D_GetEdge(ref, edge, nextEdgeType, p)); + return p.value; + }); + } + + /// Returns a list of all edges. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#ab527c11e9938eed53cf9c790afa9416d + List getEdgeList() { + return using>((arena) { + final pv = arena>(); + final psize = arena(); + cvRun(() => CFFI.Subdiv2D_GetEdgeList(ref, pv, psize)); + return List.generate(psize.value, (i) { + final v = pv[i]; + return Vec4f(v.ref.val1, v.ref.val2, v.ref.val3, v.ref.val4); + }); + }); + } + + /// Returns a list of the leading edge ID connected to each triangle. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a2d02a1d66ef7f8f267beb549cb2823f1 + VecInt getLeadingEdgeList() { + return using((arena) { + final pv = VecInt(); + cvRun(() => CFFI.Subdiv2D_GetLeadingEdgeList(ref, pv.ptr)); + return pv; + }); + } + + /// Returns a list of all triangles. + /// + /// The function gives each triangle as a 6 numbers vector, where each two are one of the triangle vertices. + /// i.e. p1_x = v[0], p1_y = v[1], p2_x = v[2], p2_y = v[3], p3_x = v[4], p3_y = v[5]. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a26bfe32209bc8ae9ecc53e93da01e466 + List getTriangleList() { + return using>((arena) { + final pv = arena>(); + final psize = arena(); + cvRun(() => CFFI.Subdiv2D_GetTriangleList(ref, pv, psize)); + return List.generate(psize.value, (i) { + final v = pv[i]; + return Vec6f(v.ref.val1, v.ref.val2, v.ref.val3, v.ref.val4, v.ref.val5, v.ref.val6); + }); + }); + } + + /// Returns vertex location from vertex ID. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a5297daca30f90d1e6d0cc5a75ba76351 + (Point2f rval, int firstEdge) getVertex(int vertex) { + return using<(Point2f, int)>((arena) { + final pp = calloc(); + final p = arena(); + cvRun(() => CFFI.Subdiv2D_GetVertex(ref, vertex, p, pp)); + return (Point2f.fromPointer(pp), p.value); + }); + } + + /// Returns a list of all Voronoi facets. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a3a9e080423475be056a79da4c04741ea + (VecVecPoint2f facetList, VecPoint2f facetCenters) getVoronoiFacetList(VecInt idx) { + return using<(VecVecPoint2f, VecPoint2f)>((arena) { + final pf = VecVecPoint2f.fromList([]); + final pfc = VecPoint2f(); + cvRun(() => CFFI.Subdiv2D_GetVoronoiFacetList(ref, idx.ref, pf.ptr, pfc.ptr)); + return (pf, pfc); + }); + } + + /// Creates a new empty Delaunay subdivision. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#ae4a3d65e798c46fd6ce64370f24b0287 + void initDelaunay(Rect rect) { + return using((arena) { + cvRun(() => CFFI.Subdiv2D_InitDelaunay(ref, rect.ref)); + }); + } + + /// Insert multiple points into a Delaunay triangulation. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a37223a499032ef57364f1372ad0c9c2e + int insert(Point2f pt) { + return using((arena) { + final p = arena(); + cvRun(() => CFFI.Subdiv2D_Insert(ref, pt.ref, p)); + return p.value; + }); + } + + /// Insert a single point into a Delaunay triangulation. + /// + /// The function locates the input point within the subdivision and gives one of the triangle edges or vertices. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a18a6c9999210d769538297d843c613f2 + void insertVec(VecPoint2f pv) { + return using((arena) { + cvRun(() => CFFI.Subdiv2D_InsertVec(ref, pv.ref)); + }); + } + + /// Returns the location of a point within a Delaunay triangulation. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#aec8f1fd5a802f62faa97520b465897d7 + (int rval, int edge, int vertex) locate(Point2f pt) { + return using<(int, int, int)>((arena) { + final edge = arena(); + final vertex = arena(); + final rval = arena(); + cvRun(() => CFFI.Subdiv2D_Locate(ref, pt.ref, edge, vertex, rval)); + return (rval.value, edge.value, vertex.value); + }); + } + + /// Returns next edge around the edge origin. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a36ebf478e2546615c2db457106393acb + int nextEdge(int edge) { + return using((arena) { + final p = arena(); + cvRun(() => CFFI.Subdiv2D_NextEdge(ref, edge, p)); + return p.value; + }); + } + + /// Returns another edge of the same quad-edge. + /// + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#aa1179507f651b67c22e06517fbc6a145 + int rotateEdge(int edge, int rotate) { + return using((arena) { + final p = arena(); + cvRun(() => CFFI.Subdiv2D_RotateEdge(ref, edge, rotate, p)); + return p.value; + }); + } + + /// https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#aabbb10b8d5b0311b7e22040fc0db56b4 + int symEdge(int edge) { + return using((arena) { + final p = arena(); + cvRun(() => CFFI.Subdiv2D_SymEdge(ref, edge, p)); + return p.value; + }); + } + + @override + List get props => [ptr.address]; + + @override + cvg.Subdiv2D get ref => ptr.ref; +} + +const int NEXT_AROUND_ORG = 0x00; +const int NEXT_AROUND_DST = 0x22; +const int PREV_AROUND_ORG = 0x11; +const int PREV_AROUND_DST = 0x33; +const int NEXT_AROUND_LEFT = 0x13; +const int NEXT_AROUND_RIGHT = 0x31; +const int PREV_AROUND_LEFT = 0x20; +const int PREV_AROUND_RIGHT = 0x02; diff --git a/lib/src/opencv.dart b/lib/src/opencv.dart index cef281ad..51d094bf 100644 --- a/lib/src/opencv.dart +++ b/lib/src/opencv.dart @@ -32,7 +32,11 @@ export 'dnn/dnn.dart'; export 'features2d/features2d.dart'; export 'highgui/highgui.dart'; export 'imgcodecs/imgcodecs.dart'; + export 'imgproc/imgproc.dart'; +export 'imgproc/clahe.dart'; +export 'imgproc/subdiv2d.dart'; + export 'objdetect/objdetect.dart'; export 'photo/photo.dart'; export 'svd/svd.dart'; diff --git a/lib/src/opencv.g.dart b/lib/src/opencv.g.dart index 2a991ff7..994b1c1e 100644 --- a/lib/src/opencv.g.dart +++ b/lib/src/opencv.g.dart @@ -4406,26 +4406,6 @@ class CvNative { late final _GetTickFrequency = _GetTickFrequencyPtr.asFunction< CvStatus Function(ffi.Pointer)>(); - CvStatus GetTriangles( - VecPoint points, - ffi.Pointer> rval, - ffi.Pointer size, - ) { - return _GetTriangles( - points, - rval, - size, - ); - } - - late final _GetTrianglesPtr = _lookup< - ffi.NativeFunction< - CvStatus Function(VecPoint, ffi.Pointer>, - ffi.Pointer)>>('GetTriangles'); - late final _GetTriangles = _GetTrianglesPtr.asFunction< - CvStatus Function( - VecPoint, ffi.Pointer>, ffi.Pointer)>(); - CvStatus GoodFeaturesToTrack( Mat img, VecPoint2f corners, @@ -13399,6 +13379,373 @@ class CvNative { late final _Stylization = _StylizationPtr.asFunction(); + void Subdiv2D_Close( + ffi.Pointer self, + ) { + return _Subdiv2D_Close( + self, + ); + } + + late final _Subdiv2D_ClosePtr = + _lookup)>>( + 'Subdiv2D_Close'); + late final _Subdiv2D_Close = + _Subdiv2D_ClosePtr.asFunction)>(); + + CvStatus Subdiv2D_EdgeDst( + Subdiv2D self, + int edge, + ffi.Pointer dstpt, + ffi.Pointer rval, + ) { + return _Subdiv2D_EdgeDst( + self, + edge, + dstpt, + rval, + ); + } + + late final _Subdiv2D_EdgeDstPtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, ffi.Int, ffi.Pointer, + ffi.Pointer)>>('Subdiv2D_EdgeDst'); + late final _Subdiv2D_EdgeDst = _Subdiv2D_EdgeDstPtr.asFunction< + CvStatus Function( + Subdiv2D, int, ffi.Pointer, ffi.Pointer)>(); + + CvStatus Subdiv2D_EdgeOrg( + Subdiv2D self, + int edge, + ffi.Pointer orgpt, + ffi.Pointer rval, + ) { + return _Subdiv2D_EdgeOrg( + self, + edge, + orgpt, + rval, + ); + } + + late final _Subdiv2D_EdgeOrgPtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, ffi.Int, ffi.Pointer, + ffi.Pointer)>>('Subdiv2D_EdgeOrg'); + late final _Subdiv2D_EdgeOrg = _Subdiv2D_EdgeOrgPtr.asFunction< + CvStatus Function( + Subdiv2D, int, ffi.Pointer, ffi.Pointer)>(); + + CvStatus Subdiv2D_FindNearest( + Subdiv2D self, + Point2f pt, + ffi.Pointer nearestPt, + ffi.Pointer rval, + ) { + return _Subdiv2D_FindNearest( + self, + pt, + nearestPt, + rval, + ); + } + + late final _Subdiv2D_FindNearestPtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, Point2f, ffi.Pointer, + ffi.Pointer)>>('Subdiv2D_FindNearest'); + late final _Subdiv2D_FindNearest = _Subdiv2D_FindNearestPtr.asFunction< + CvStatus Function( + Subdiv2D, Point2f, ffi.Pointer, ffi.Pointer)>(); + + CvStatus Subdiv2D_GetEdge( + Subdiv2D self, + int edge, + int nextEdgeType, + ffi.Pointer rval, + ) { + return _Subdiv2D_GetEdge( + self, + edge, + nextEdgeType, + rval, + ); + } + + late final _Subdiv2D_GetEdgePtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, ffi.Int, ffi.Int, + ffi.Pointer)>>('Subdiv2D_GetEdge'); + late final _Subdiv2D_GetEdge = _Subdiv2D_GetEdgePtr.asFunction< + CvStatus Function(Subdiv2D, int, int, ffi.Pointer)>(); + + CvStatus Subdiv2D_GetEdgeList( + Subdiv2D self, + ffi.Pointer> rval, + ffi.Pointer size, + ) { + return _Subdiv2D_GetEdgeList( + self, + rval, + size, + ); + } + + late final _Subdiv2D_GetEdgeListPtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, ffi.Pointer>, + ffi.Pointer)>>('Subdiv2D_GetEdgeList'); + late final _Subdiv2D_GetEdgeList = _Subdiv2D_GetEdgeListPtr.asFunction< + CvStatus Function( + Subdiv2D, ffi.Pointer>, ffi.Pointer)>(); + + CvStatus Subdiv2D_GetLeadingEdgeList( + Subdiv2D self, + ffi.Pointer leadingEdgeList, + ) { + return _Subdiv2D_GetLeadingEdgeList( + self, + leadingEdgeList, + ); + } + + late final _Subdiv2D_GetLeadingEdgeListPtr = _lookup< + ffi.NativeFunction)>>( + 'Subdiv2D_GetLeadingEdgeList'); + late final _Subdiv2D_GetLeadingEdgeList = _Subdiv2D_GetLeadingEdgeListPtr + .asFunction)>(); + + CvStatus Subdiv2D_GetTriangleList( + Subdiv2D self, + ffi.Pointer> rval, + ffi.Pointer size, + ) { + return _Subdiv2D_GetTriangleList( + self, + rval, + size, + ); + } + + late final _Subdiv2D_GetTriangleListPtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, ffi.Pointer>, + ffi.Pointer)>>('Subdiv2D_GetTriangleList'); + late final _Subdiv2D_GetTriangleList = + _Subdiv2D_GetTriangleListPtr.asFunction< + CvStatus Function(Subdiv2D, ffi.Pointer>, + ffi.Pointer)>(); + + CvStatus Subdiv2D_GetVertex( + Subdiv2D self, + int vertex, + ffi.Pointer firstEdge, + ffi.Pointer rval, + ) { + return _Subdiv2D_GetVertex( + self, + vertex, + firstEdge, + rval, + ); + } + + late final _Subdiv2D_GetVertexPtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, ffi.Int, ffi.Pointer, + ffi.Pointer)>>('Subdiv2D_GetVertex'); + late final _Subdiv2D_GetVertex = _Subdiv2D_GetVertexPtr.asFunction< + CvStatus Function( + Subdiv2D, int, ffi.Pointer, ffi.Pointer)>(); + + CvStatus Subdiv2D_GetVoronoiFacetList( + Subdiv2D self, + VecInt idx, + ffi.Pointer facetList, + ffi.Pointer facetCenters, + ) { + return _Subdiv2D_GetVoronoiFacetList( + self, + idx, + facetList, + facetCenters, + ); + } + + late final _Subdiv2D_GetVoronoiFacetListPtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, VecInt, ffi.Pointer, + ffi.Pointer)>>('Subdiv2D_GetVoronoiFacetList'); + late final _Subdiv2D_GetVoronoiFacetList = + _Subdiv2D_GetVoronoiFacetListPtr.asFunction< + CvStatus Function(Subdiv2D, VecInt, ffi.Pointer, + ffi.Pointer)>(); + + CvStatus Subdiv2D_InitDelaunay( + Subdiv2D self, + Rect rect, + ) { + return _Subdiv2D_InitDelaunay( + self, + rect, + ); + } + + late final _Subdiv2D_InitDelaunayPtr = + _lookup>( + 'Subdiv2D_InitDelaunay'); + late final _Subdiv2D_InitDelaunay = + _Subdiv2D_InitDelaunayPtr.asFunction(); + + CvStatus Subdiv2D_Insert( + Subdiv2D self, + Point2f pt, + ffi.Pointer rval, + ) { + return _Subdiv2D_Insert( + self, + pt, + rval, + ); + } + + late final _Subdiv2D_InsertPtr = _lookup< + ffi.NativeFunction< + CvStatus Function( + Subdiv2D, Point2f, ffi.Pointer)>>('Subdiv2D_Insert'); + late final _Subdiv2D_Insert = _Subdiv2D_InsertPtr.asFunction< + CvStatus Function(Subdiv2D, Point2f, ffi.Pointer)>(); + + CvStatus Subdiv2D_InsertVec( + Subdiv2D self, + VecPoint2f ptvec, + ) { + return _Subdiv2D_InsertVec( + self, + ptvec, + ); + } + + late final _Subdiv2D_InsertVecPtr = + _lookup>( + 'Subdiv2D_InsertVec'); + late final _Subdiv2D_InsertVec = _Subdiv2D_InsertVecPtr.asFunction< + CvStatus Function(Subdiv2D, VecPoint2f)>(); + + CvStatus Subdiv2D_Locate( + Subdiv2D self, + Point2f pt, + ffi.Pointer edge, + ffi.Pointer vertex, + ffi.Pointer rval, + ) { + return _Subdiv2D_Locate( + self, + pt, + edge, + vertex, + rval, + ); + } + + late final _Subdiv2D_LocatePtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, Point2f, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('Subdiv2D_Locate'); + late final _Subdiv2D_Locate = _Subdiv2D_LocatePtr.asFunction< + CvStatus Function(Subdiv2D, Point2f, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + CvStatus Subdiv2D_NewEmpty( + ffi.Pointer rval, + ) { + return _Subdiv2D_NewEmpty( + rval, + ); + } + + late final _Subdiv2D_NewEmptyPtr = + _lookup)>>( + 'Subdiv2D_NewEmpty'); + late final _Subdiv2D_NewEmpty = _Subdiv2D_NewEmptyPtr.asFunction< + CvStatus Function(ffi.Pointer)>(); + + CvStatus Subdiv2D_NewWithRect( + Rect rect, + ffi.Pointer rval, + ) { + return _Subdiv2D_NewWithRect( + rect, + rval, + ); + } + + late final _Subdiv2D_NewWithRectPtr = _lookup< + ffi.NativeFunction)>>( + 'Subdiv2D_NewWithRect'); + late final _Subdiv2D_NewWithRect = _Subdiv2D_NewWithRectPtr.asFunction< + CvStatus Function(Rect, ffi.Pointer)>(); + + CvStatus Subdiv2D_NextEdge( + Subdiv2D self, + int edge, + ffi.Pointer rval, + ) { + return _Subdiv2D_NextEdge( + self, + edge, + rval, + ); + } + + late final _Subdiv2D_NextEdgePtr = _lookup< + ffi.NativeFunction< + CvStatus Function( + Subdiv2D, ffi.Int, ffi.Pointer)>>('Subdiv2D_NextEdge'); + late final _Subdiv2D_NextEdge = _Subdiv2D_NextEdgePtr.asFunction< + CvStatus Function(Subdiv2D, int, ffi.Pointer)>(); + + CvStatus Subdiv2D_RotateEdge( + Subdiv2D self, + int edge, + int rotate, + ffi.Pointer rval, + ) { + return _Subdiv2D_RotateEdge( + self, + edge, + rotate, + rval, + ); + } + + late final _Subdiv2D_RotateEdgePtr = _lookup< + ffi.NativeFunction< + CvStatus Function(Subdiv2D, ffi.Int, ffi.Int, + ffi.Pointer)>>('Subdiv2D_RotateEdge'); + late final _Subdiv2D_RotateEdge = _Subdiv2D_RotateEdgePtr.asFunction< + CvStatus Function(Subdiv2D, int, int, ffi.Pointer)>(); + + CvStatus Subdiv2D_SymEdge( + Subdiv2D self, + int edge, + ffi.Pointer rval, + ) { + return _Subdiv2D_SymEdge( + self, + edge, + rval, + ); + } + + late final _Subdiv2D_SymEdgePtr = _lookup< + ffi.NativeFunction< + CvStatus Function( + Subdiv2D, ffi.Int, ffi.Pointer)>>('Subdiv2D_SymEdge'); + late final _Subdiv2D_SymEdge = _Subdiv2D_SymEdgePtr.asFunction< + CvStatus Function(Subdiv2D, int, ffi.Pointer)>(); + void TermCriteria_Close( ffi.Pointer tc, ) { @@ -17080,6 +17427,8 @@ class _SymbolAddresses { get SimpleBlobDetector_Close => _library._SimpleBlobDetector_ClosePtr; ffi.Pointer)>> get Stitcher_Close => _library._Stitcher_ClosePtr; + ffi.Pointer)>> + get Subdiv2D_Close => _library._Subdiv2D_ClosePtr; ffi.Pointer)>> get TermCriteria_Close => _library._TermCriteria_ClosePtr; ffi.Pointer)>> @@ -17655,6 +18004,13 @@ final class NO_USE_StitcherPtr extends ffi.Struct { external ffi.Pointer p; } +/// \ +/// Dart ffigen will not generate typedefs if not referred \ +/// so here we confirm they are included \ +final class NO_USE_Subdiv2DPtr extends ffi.Struct { + external ffi.Pointer p; +} + /// \ /// Dart ffigen will not generate typedefs if not referred \ /// so here we confirm they are included \ @@ -18036,6 +18392,12 @@ final class Stitcher extends ffi.Struct { typedef StitcherPtr = ffi.Pointer; +final class Subdiv2D extends ffi.Struct { + external ffi.Pointer ptr; +} + +typedef Subdiv2DPtr = ffi.Pointer; + final class TermCriteria extends ffi.Struct { external ffi.Pointer ptr; } diff --git a/src/core/core.h b/src/core/core.h index 334d078e..6056061a 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -13,7 +13,6 @@ #include #include #include -#include #ifdef __cplusplus #include diff --git a/src/imgproc/imgproc.cpp b/src/imgproc/imgproc.cpp index 20bf8b27..7b2624c4 100644 --- a/src/imgproc/imgproc.cpp +++ b/src/imgproc/imgproc.cpp @@ -10,43 +10,6 @@ #include #include -Vec6f convertToVec6f(const cv::Vec6f& cvVec) { - Vec6f vec; - vec.val1 = cvVec[0]; - vec.val2 = cvVec[1]; - vec.val3 = cvVec[2]; - vec.val4 = cvVec[3]; - vec.val5 = cvVec[4]; - vec.val6 = cvVec[5]; - return vec; -} - -CvStatus GetTriangles(VecPoint points, Vec6f **rval, int *size) -{ - BEGIN_WRAP - // get convex hull from potins - // cv::convexHull(*points.ptr, *hull.ptr, clockwise, returnPoints); - cv::Mat convexHull; - cv::convexHull(*points.ptr, convexHull); - // cv::Rect r = cv::boundingRect(*pts.ptr); - cv::Rect r = cv::boundingRect(convexHull); - cv::Subdiv2D subdiv = cv::Subdiv2D(r); - for (int i = 0; i < points.ptr->size(); i++) { - // points.ptr->at(i); - cv::Point2f pt = cv::Point2f(points.ptr->at(i).x, points.ptr->at(i).y); - subdiv.insert(pt); - } - std::vector triangleVec; - subdiv.getTriangleList(triangleVec); - - *size = triangleVec.size(); - // rval에 triangleVec 할당 - *rval = new Vec6f[triangleVec.size()]; - for (size_t i = 0; i < triangleVec.size(); i++) { - (*rval)[i] = convertToVec6f(triangleVec[i]); - } - END_WRAP -} CvStatus ArcLength(VecPoint curve, bool is_closed, double *rval) { BEGIN_WRAP @@ -785,6 +748,145 @@ CvStatus CLAHE_SetTilesGridSize(CLAHE c, Size size) END_WRAP } +CvStatus Subdiv2D_NewEmpty(Subdiv2D *rval) +{ + BEGIN_WRAP + *rval = {new cv::Subdiv2D()}; + END_WRAP +} +CvStatus Subdiv2D_NewWithRect(Rect rect, Subdiv2D *rval) +{ + BEGIN_WRAP + *rval = {new cv::Subdiv2D(cv::Rect(rect.x, rect.y, rect.width, rect.height))}; + END_WRAP +} +void Subdiv2D_Close(Subdiv2D *self){CVD_FREE(self)} + +CvStatus Subdiv2D_EdgeDst(Subdiv2D self, int edge, Point2f *dstpt, int *rval) +{ + BEGIN_WRAP + auto p = cv::Point2f(); + *rval = self.ptr->edgeDst(edge, &p); + *dstpt = {p.x, p.y}; + END_WRAP +} +CvStatus Subdiv2D_EdgeOrg(Subdiv2D self, int edge, Point2f *orgpt, int *rval) +{ + BEGIN_WRAP + auto p = cv::Point2f(); + *rval = self.ptr->edgeOrg(edge, &p); + *orgpt = {p.x, p.y}; + END_WRAP +} +CvStatus Subdiv2D_FindNearest(Subdiv2D self, Point2f pt, Point2f *nearestPt, int *rval) +{ + BEGIN_WRAP + auto p = cv::Point2f(); + *rval = self.ptr->findNearest(cv::Point2f(pt.x, pt.y), &p); + *nearestPt = {p.x, p.y}; + END_WRAP +} +CvStatus Subdiv2D_GetEdge(Subdiv2D self, int edge, int nextEdgeType, int *rval) +{ + BEGIN_WRAP + *rval = self.ptr->getEdge(edge, nextEdgeType); + END_WRAP +} +CvStatus Subdiv2D_GetEdgeList(Subdiv2D self, Vec4f **rval, int *size) +{ + BEGIN_WRAP + auto v = std::vector(); + self.ptr->getEdgeList(v); + *size = v.size(); + auto rv = new Vec4f[v.size()]; + for (int i = 0; i < v.size(); i++) { + rv[i] = {v[i].val[0], v[i].val[1], v[i].val[2], v[i].val[3]}; + } + *rval = rv; + END_WRAP +} +CvStatus Subdiv2D_GetLeadingEdgeList(Subdiv2D self, VecInt *leadingEdgeList) +{ + BEGIN_WRAP + auto v = new std::vector(); + self.ptr->getLeadingEdgeList(*v); + *leadingEdgeList = {v}; + END_WRAP +} +CvStatus Subdiv2D_GetTriangleList(Subdiv2D self, Vec6f **rval, int *size) +{ + BEGIN_WRAP + auto v = std::vector(); + self.ptr->getTriangleList(v); + *size = v.size(); + auto rv = new Vec6f[v.size()]; + for (int i = 0; i < v.size(); i++) { + rv[i] = {v[i].val[0], v[i].val[1], v[i].val[2], v[i].val[3], v[i].val[4], v[i].val[5]}; + } + *rval = rv; + END_WRAP +} +CvStatus Subdiv2D_GetVertex(Subdiv2D self, int vertex, int *firstEdge, Point2f *rval) +{ + BEGIN_WRAP + auto p = self.ptr->getVertex(vertex, firstEdge); + *rval = {p.x, p.y}; + END_WRAP +} +CvStatus Subdiv2D_GetVoronoiFacetList(Subdiv2D self, VecInt idx, VecVecPoint2f *facetList, + VecPoint2f *facetCenters) +{ + BEGIN_WRAP + auto vf = std::vector>(); + auto vfc = std::vector(); + self.ptr->getVoronoiFacetList(*idx.ptr, vf, vfc); + *facetList = {new std::vector>(vf)}; + *facetCenters = {new std::vector(vfc)}; + END_WRAP; +} +CvStatus Subdiv2D_InitDelaunay(Subdiv2D self, Rect rect) +{ + BEGIN_WRAP + self.ptr->initDelaunay(cv::Rect(rect.x, rect.y, rect.width, rect.height)); + END_WRAP +} +CvStatus Subdiv2D_Insert(Subdiv2D self, Point2f pt, int *rval) +{ + BEGIN_WRAP + *rval = self.ptr->insert(cv::Point2f(pt.x, pt.y)); + END_WRAP +} +CvStatus Subdiv2D_InsertVec(Subdiv2D self, VecPoint2f ptvec) +{ + BEGIN_WRAP + self.ptr->insert(*ptvec.ptr); + END_WRAP +} +CvStatus Subdiv2D_Locate(Subdiv2D self, Point2f pt, int *edge, int *vertex, int *rval) +{ + BEGIN_WRAP + *rval = self.ptr->locate(cv::Point2f(pt.x, pt.y), *edge, *vertex); + END_WRAP +} +CvStatus Subdiv2D_NextEdge(Subdiv2D self, int edge, int *rval) +{ + BEGIN_WRAP + *rval = self.ptr->nextEdge(edge); + END_WRAP +} +CvStatus Subdiv2D_RotateEdge(Subdiv2D self, int edge, int rotate, int *rval) +{ + BEGIN_WRAP + *rval = self.ptr->rotateEdge(edge, rotate); + END_WRAP +} +CvStatus Subdiv2D_SymEdge(Subdiv2D self, int edge, int *rval) +{ + BEGIN_WRAP + *rval = self.ptr->symEdge(edge); + END_WRAP +} + CvStatus InvertAffineTransform(Mat src, Mat dst) { BEGIN_WRAP diff --git a/src/imgproc/imgproc.h b/src/imgproc/imgproc.h index 3424b23f..46880d01 100644 --- a/src/imgproc/imgproc.h +++ b/src/imgproc/imgproc.h @@ -19,19 +19,22 @@ extern "C" { #ifdef __cplusplus CVD_TYPEDEF(cv::Ptr, CLAHE) +CVD_TYPEDEF(cv::Subdiv2D, Subdiv2D) #else CVD_TYPEDEF(void, CLAHE) +CVD_TYPEDEF(void, Subdiv2D) #endif CVD_TYPEDEF_PTR(CLAHE) +CVD_TYPEDEF_PTR(Subdiv2D) -CvStatus GetTriangles(VecPoint points, Vec6f **rval, int *size); CvStatus ArcLength(VecPoint curve, bool is_closed, CVD_OUT double *rval); CvStatus ApproxPolyDP(VecPoint curve, double epsilon, bool closed, CVD_OUT VecPoint *rval); CvStatus CvtColor(Mat src, CVD_OUT Mat dst, int code); CvStatus EqualizeHist(Mat src, CVD_OUT Mat dst); CvStatus CalcHist(VecMat mats, VecInt chans, Mat mask, CVD_OUT Mat hist, VecInt sz, VecFloat rng, bool acc); -CvStatus CalcBackProject(VecMat mats, VecInt chans, CVD_OUT Mat hist, Mat backProject, VecFloat rng, bool uniform); +CvStatus CalcBackProject(VecMat mats, VecInt chans, CVD_OUT Mat hist, Mat backProject, VecFloat rng, + bool uniform); CvStatus CompareHist(Mat hist1, Mat hist2, int method, CVD_OUT double *rval); CvStatus ConvexHull(VecPoint points, CVD_OUT Mat hull, bool clockwise, bool returnPoints); CvStatus ConvexityDefects(VecPoint points, Mat hull, Mat result); @@ -40,10 +43,12 @@ CvStatus Blur(Mat src, Mat dst, Size ps); CvStatus BoxFilter(Mat src, Mat dst, int ddepth, Size ps); CvStatus SqBoxFilter(Mat src, Mat dst, int ddepth, Size ps); CvStatus Dilate(Mat src, Mat dst, Mat kernel); -CvStatus DilateWithParams(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue); +CvStatus DilateWithParams(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, + Scalar borderValue); CvStatus DistanceTransform(Mat src, Mat dst, Mat labels, int distanceType, int maskSize, int labelType); CvStatus Erode(Mat src, Mat dst, Mat kernel); -CvStatus ErodeWithParams(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue); +CvStatus ErodeWithParams(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, + Scalar borderValue); CvStatus MatchTemplate(Mat image, Mat templ, Mat result, int method, Mat mask); CvStatus Moments(Mat src, bool binaryImage, Moment *rval); CvStatus PyrDown(Mat src, Mat dst, Size dstsize, int borderType); @@ -57,7 +62,8 @@ CvStatus MinEnclosingCircle(VecPoint pts, Point2f *center, float *radius); CvStatus FindContours(Mat src, Mat hierarchy, int mode, int method, VecVecPoint *rval); CvStatus PointPolygonTest(VecPoint pts, Point2f pt, bool measureDist, double *rval); CvStatus ConnectedComponents(Mat src, Mat dst, int connectivity, int ltype, int ccltype, int *rval); -CvStatus ConnectedComponentsWithStats(Mat src, Mat labels, Mat stats, Mat centroids, int connectivity, int ltype, int ccltype, int *rval); +CvStatus ConnectedComponentsWithStats(Mat src, Mat labels, Mat stats, Mat centroids, int connectivity, + int ltype, int ccltype, int *rval); CvStatus GaussianBlur(Mat src, Mat dst, Size ps, double sX, double sY, int bt); CvStatus GetGaussianKernel(int ksize, double sigma, int ktype, Mat *rval); @@ -66,45 +72,64 @@ CvStatus Scharr(Mat src, Mat dst, int dDepth, int dx, int dy, double scale, doub CvStatus GetStructuringElement(int shape, Size ksize, Mat *rval); CvStatus MorphologyDefaultBorderValue(Scalar *rval); CvStatus MorphologyEx(Mat src, Mat dst, int op, Mat kernel); -CvStatus MorphologyExWithParams(Mat src, Mat dst, int op, Mat kernel, Point pt, int iterations, int borderType, Scalar borderValue); +CvStatus MorphologyExWithParams(Mat src, Mat dst, int op, Mat kernel, Point pt, int iterations, + int borderType, Scalar borderValue); CvStatus MedianBlur(Mat src, Mat dst, int ksize); CvStatus Canny(Mat src, Mat edges, double t1, double t2, int apertureSize, bool l2gradient); CvStatus CornerSubPix(Mat img, VecPoint2f corners, Size winSize, Size zeroZone, TermCriteria criteria); -CvStatus GoodFeaturesToTrack(Mat img, VecPoint2f corners, int maxCorners, double quality, double minDist, Mat mask, int blockSize, bool useHarrisDetector, double k); -CvStatus GoodFeaturesToTrackWithGradient(Mat img, VecPoint2f corners, int maxCorners, double quality, double minDist, Mat mask, int blockSize, int gradientSize, bool useHarrisDetector, double k); +CvStatus GoodFeaturesToTrack(Mat img, VecPoint2f corners, int maxCorners, double quality, double minDist, + Mat mask, int blockSize, bool useHarrisDetector, double k); +CvStatus GoodFeaturesToTrackWithGradient(Mat img, VecPoint2f corners, int maxCorners, double quality, + double minDist, Mat mask, int blockSize, int gradientSize, + bool useHarrisDetector, double k); CvStatus GrabCut(Mat img, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int iterCount, int mode); CvStatus HoughCircles(Mat src, Mat circles, int method, double dp, double minDist); -CvStatus HoughCirclesWithParams(Mat src, Mat circles, int method, double dp, double minDist, double param1, double param2, int minRadius, int maxRadius); -CvStatus HoughLines(Mat src, Mat lines, double rho, double theta, int threshold, double srn, double stn, double min_theta, double max_theta); +CvStatus HoughCirclesWithParams(Mat src, Mat circles, int method, double dp, double minDist, double param1, + double param2, int minRadius, int maxRadius); +CvStatus HoughLines(Mat src, Mat lines, double rho, double theta, int threshold, double srn, double stn, + double min_theta, double max_theta); CvStatus HoughLinesP(Mat src, Mat lines, double rho, double theta, int threshold); -CvStatus HoughLinesPWithParams(Mat src, Mat lines, double rho, double theta, int threshold, double minLineLength, double maxLineGap); -CvStatus HoughLinesPointSet(Mat points, Mat lines, int lines_max, int threshold, double min_rho, double max_rho, double rho_step, double min_theta, double max_theta, double theta_step); +CvStatus HoughLinesPWithParams(Mat src, Mat lines, double rho, double theta, int threshold, + double minLineLength, double maxLineGap); +CvStatus HoughLinesPointSet(Mat points, Mat lines, int lines_max, int threshold, double min_rho, + double max_rho, double rho_step, double min_theta, double max_theta, + double theta_step); CvStatus Integral(Mat src, Mat sum, Mat sqsum, Mat tilted, int sdepth, int sqdepth); CvStatus Threshold(Mat src, Mat dst, double thresh, double maxvalue, int typ, double *rval); -CvStatus AdaptiveThreshold(Mat src, Mat dst, double maxValue, int adaptiveTyp, int typ, int blockSize, double c); +CvStatus AdaptiveThreshold(Mat src, Mat dst, double maxValue, int adaptiveTyp, int typ, int blockSize, + double c); -CvStatus ArrowedLine(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int line_type, int shift, double tipLength); +CvStatus ArrowedLine(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int line_type, int shift, + double tipLength); CvStatus Circle(Mat img, Point center, int radius, Scalar color, int thickness); -CvStatus CircleWithParams(Mat img, Point center, int radius, Scalar color, int thickness, int lineType, int shift); -CvStatus Ellipse(Mat img, Point center, Point axes, double angle, double startAngle, double endAngle, Scalar color, int thickness); -CvStatus EllipseWithParams(Mat img, Point center, Point axes, double angle, double startAngle, double endAngle, Scalar color, int thickness, int lineType, int shift); +CvStatus CircleWithParams(Mat img, Point center, int radius, Scalar color, int thickness, int lineType, + int shift); +CvStatus Ellipse(Mat img, Point center, Point axes, double angle, double startAngle, double endAngle, + Scalar color, int thickness); +CvStatus EllipseWithParams(Mat img, Point center, Point axes, double angle, double startAngle, + double endAngle, Scalar color, int thickness, int lineType, int shift); CvStatus Line(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int lineType, int shift); CvStatus Rectangle(Mat img, Rect rect, Scalar color, int thickness); CvStatus RectangleWithParams(Mat img, Rect rect, Scalar color, int thickness, int lineType, int shift); CvStatus FillPoly(Mat img, VecVecPoint points, Scalar color); CvStatus FillPolyWithParams(Mat img, VecVecPoint points, Scalar color, int lineType, int shift, Point offset); CvStatus Polylines(Mat img, VecVecPoint points, bool isClosed, Scalar color, int thickness); -CvStatus GetTextSizeWithBaseline(const char *text, int fontFace, double fontScale, int thickness, int *baseline, Size *rval); -CvStatus PutText(Mat img, const char *text, Point org, int fontFace, double fontScale, Scalar color, int thickness); -CvStatus PutTextWithParams(Mat img, const char *text, Point org, int fontFace, double fontScale, Scalar color, int thickness, int lineType, bool bottomLeftOrigin); +CvStatus GetTextSizeWithBaseline(const char *text, int fontFace, double fontScale, int thickness, + int *baseline, Size *rval); +CvStatus PutText(Mat img, const char *text, Point org, int fontFace, double fontScale, Scalar color, + int thickness); +CvStatus PutTextWithParams(Mat img, const char *text, Point org, int fontFace, double fontScale, Scalar color, + int thickness, int lineType, bool bottomLeftOrigin); CvStatus Resize(Mat src, Mat dst, Size sz, double fx, double fy, int interp); CvStatus GetRectSubPix(Mat src, Size patchSize, Point2f center, Mat dst); CvStatus GetRotationMatrix2D(Point2f center, double angle, double scale, Mat *rval); CvStatus WarpAffine(Mat src, Mat dst, Mat rot_mat, Size dsize); -CvStatus WarpAffineWithParams(Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, Scalar borderValue); +CvStatus WarpAffineWithParams(Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, + Scalar borderValue); CvStatus WarpPerspective(Mat src, Mat dst, Mat m, Size dsize); -CvStatus WarpPerspectiveWithParams(Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, Scalar borderValue); +CvStatus WarpPerspectiveWithParams(Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, + Scalar borderValue); CvStatus Watershed(Mat image, Mat markers); CvStatus ApplyColorMap(Mat src, Mat dst, int colormap); CvStatus ApplyCustomColorMap(Mat src, Mat dst, Mat colormap); @@ -112,14 +137,18 @@ CvStatus GetPerspectiveTransform(VecPoint src, VecPoint dst, Mat *rval, int solv CvStatus GetPerspectiveTransform2f(VecPoint2f src, VecPoint2f dst, Mat *rval, int solveMethod); CvStatus GetAffineTransform(VecPoint src, VecPoint dst, Mat *rval); CvStatus GetAffineTransform2f(VecPoint2f src, VecPoint2f dst, Mat *rval); -CvStatus FindHomography(Mat src, Mat dst, int method, double ransacReprojThreshold, Mat mask, const int maxIters, const double confidence, Mat *rval); +CvStatus FindHomography(Mat src, Mat dst, int method, double ransacReprojThreshold, Mat mask, + const int maxIters, const double confidence, Mat *rval); CvStatus DrawContours(Mat src, VecVecPoint contours, int contourIdx, Scalar color, int thickness); -CvStatus DrawContoursWithParams(Mat src, VecVecPoint contours, int contourIdx, Scalar color, int thickness, int lineType, Mat hierarchy, int maxLevel, Point offset); -CvStatus Sobel(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType); +CvStatus DrawContoursWithParams(Mat src, VecVecPoint contours, int contourIdx, Scalar color, int thickness, + int lineType, Mat hierarchy, int maxLevel, Point offset); +CvStatus Sobel(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, + int borderType); CvStatus SpatialGradient(Mat src, Mat dx, Mat dy, int ksize, int borderType); CvStatus Remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation, int borderMode, Scalar borderValue); CvStatus Filter2D(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta, int borderType); -CvStatus SepFilter2D(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor, double delta, int borderType); +CvStatus SepFilter2D(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor, double delta, + int borderType); CvStatus LogPolar(Mat src, Mat dst, Point2f center, double m, int flags); CvStatus FitLine(VecPoint pts, Mat line, int distType, double param, double reps, double aeps); CvStatus LinearPolar(Mat src, Mat dst, Point2f center, double maxRadius, int flags); @@ -136,6 +165,27 @@ CvStatus CLAHE_SetClipLimit(CLAHE c, double clipLimit); CvStatus CLAHE_GetTilesGridSize(CLAHE c, Size *rval); CvStatus CLAHE_SetTilesGridSize(CLAHE c, Size size); +CvStatus Subdiv2D_NewEmpty(Subdiv2D *rval); +CvStatus Subdiv2D_NewWithRect(Rect rect, Subdiv2D *rval); +void Subdiv2D_Close(Subdiv2D *self); +CvStatus Subdiv2D_EdgeDst(Subdiv2D self, int edge, Point2f *dstpt, int *rval); +CvStatus Subdiv2D_EdgeOrg(Subdiv2D self, int edge, Point2f *orgpt, int *rval); +CvStatus Subdiv2D_FindNearest(Subdiv2D self, Point2f pt, Point2f *nearestPt, int *rval); +CvStatus Subdiv2D_GetEdge(Subdiv2D self, int edge, int nextEdgeType, int *rval); +CvStatus Subdiv2D_GetEdgeList(Subdiv2D self, Vec4f **rval, int *size); +CvStatus Subdiv2D_GetLeadingEdgeList(Subdiv2D self, VecInt *leadingEdgeList); +CvStatus Subdiv2D_GetTriangleList(Subdiv2D self, Vec6f **rval, int *size); +CvStatus Subdiv2D_GetVertex(Subdiv2D self, int vertex, int *firstEdge, Point2f *rval); +CvStatus Subdiv2D_GetVoronoiFacetList(Subdiv2D self, VecInt idx, VecVecPoint2f *facetList, + VecPoint2f *facetCenters); +CvStatus Subdiv2D_InitDelaunay(Subdiv2D self, Rect rect); +CvStatus Subdiv2D_Insert(Subdiv2D self, Point2f pt, int *rval); +CvStatus Subdiv2D_InsertVec(Subdiv2D self, VecPoint2f ptvec); +CvStatus Subdiv2D_Locate(Subdiv2D self, Point2f pt, int *edge, int *vertex, int *rval); +CvStatus Subdiv2D_NextEdge(Subdiv2D self, int edge, int *rval); +CvStatus Subdiv2D_RotateEdge(Subdiv2D self, int edge, int rotate, int *rval); +CvStatus Subdiv2D_SymEdge(Subdiv2D self, int edge, int *rval); + CvStatus InvertAffineTransform(Mat src, Mat dst); CvStatus PhaseCorrelate(Mat src1, Mat src2, Mat window, double *response, Point2f *rval); diff --git a/test/imgproc/clahe_test.dart b/test/imgproc/clahe_test.dart new file mode 100644 index 00000000..67170ba9 --- /dev/null +++ b/test/imgproc/clahe_test.dart @@ -0,0 +1,12 @@ +import 'package:test/test.dart'; + +import 'package:opencv_dart/opencv_dart.dart' as cv; + +void main() { + test("cv.CLAHE", () { + final mat = cv.imread("test/images/circles.jpg", flags: cv.IMREAD_GRAYSCALE); + final clahe = cv.CLAHE(); + final dst = clahe.apply(mat); + expect(dst.isEmpty, false); + }); +} diff --git a/test/imgproc_test.dart b/test/imgproc/imgproc_test.dart similarity index 100% rename from test/imgproc_test.dart rename to test/imgproc/imgproc_test.dart