diff --git a/src/OpenCvSharp/Cv2/Cv2_geometry.cs b/src/OpenCvSharp/Cv2/Cv2_geometry.cs
index b9132b70e..f4dfffa46 100644
--- a/src/OpenCvSharp/Cv2/Cv2_geometry.cs
+++ b/src/OpenCvSharp/Cv2/Cv2_geometry.cs
@@ -2065,4 +2065,1523 @@ public static Vec2d EstimateTranslation2D(
GC.KeepAlive(inliers.Source);
return ret;
}
+
+ ///
+ /// Approximates a polygon with a convex hull with a specified accuracy and number of sides.
+ ///
+ /// Input vector of a 2D points stored in std::vector or Mat, points must be float or integer.
+ /// Result of the approximation. The type is vector of a 2D point (Point2f or Point) in std::vector or Mat.
+ /// The parameter defines the number of sides of the result polygon.
+ /// Defines the percentage of the maximum of additional area. If it equals -1, it is not used.
+ /// Otherwise the algorithm stops if the additional area is greater than contourArea(curve) * percentage. If the additional
+ /// area exceeds the limit, the algorithm returns as many vertices as there were at the moment the limit was exceeded.
+ /// If true, the algorithm creates a convex hull of the input contour. Otherwise the input vector should already be convex.
+ public static void ApproxPolyN(
+ InputArray curve, OutputArray approxCurve, int nsides, float epsilonPercentage = -1.0f, bool ensureConvex = true)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_approxPolyN(curve.Proxy, approxCurve.Proxy, nsides, epsilonPercentage, ensureConvex ? 1 : 0));
+
+ GC.KeepAlive(curve.Source);
+ GC.KeepAlive(approxCurve.Source);
+ }
+
+ ///
+ /// Finds a convex polygon of minimum area enclosing a 2D point set and returns its area.
+ ///
+ /// Input vector of 2D points, stored in std::vector or Mat.
+ /// Output vector of 2D points defining the vertices of the enclosing polygon.
+ /// Number of vertices of the output polygon.
+ /// The area of the minimal enclosing polygon.
+ public static double MinEnclosingConvexPolygon(InputArray points, OutputArray polygon, int k)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minEnclosingConvexPolygon(points.Proxy, polygon.Proxy, k, out var ret));
+
+ GC.KeepAlive(points.Source);
+ GC.KeepAlive(polygon.Source);
+ return ret;
+ }
+
+ ///
+ /// Computes for each 2D point the nearest 2D point located on a given ellipse.
+ ///
+ /// Ellipse parameters.
+ /// Input 2D points.
+ /// For each 2D point, its corresponding closest 2D point located on the ellipse.
+ public static void GetClosestEllipsePoints(RotatedRect ellipseParams, InputArray points, OutputArray closestPts)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_getClosestEllipsePoints(ellipseParams, points.Proxy, closestPts.Proxy));
+
+ GC.KeepAlive(points.Source);
+ GC.KeepAlive(closestPts.Source);
+ }
+
+ ///
+ /// Builds a Minimum Spanning Tree (MST) using the specified algorithm.
+ ///
+ /// Supports graphs with negative edge weights. Self-loop edges (edges where source and target are the
+ /// same) are ignored. If multiple edges exist between the same pair of nodes, only the one with the
+ /// lowest weight is considered. If the graph is disconnected or input is invalid, the function
+ /// returns false.
+ ///
+ /// Number of nodes in the graph (must be greater than 0).
+ /// Input array of edges representing the graph.
+ /// Specifies which algorithm to use to compute the MST.
+ /// Starting node for the MST algorithm (only used for certain algorithms).
+ /// The edges of the resulting MST, or null if a valid MST could not be built.
+ public static MSTEdge[]? BuildMST(int numNodes, MSTEdge[] inputEdges, MSTAlgorithm algorithm, int root = 0)
+ {
+ if (inputEdges is null)
+ throw new ArgumentNullException(nameof(inputEdges));
+ if (numNodes <= 0)
+ throw new ArgumentOutOfRangeException(nameof(numNodes));
+
+ var resultingEdges = new MSTEdge[numNodes - 1];
+ NativeMethods.HandleException(
+ NativeMethods.geometry_buildMST(
+ numNodes, inputEdges, inputEdges.Length, (int)algorithm, root,
+ resultingEdges, out var resultingEdgesCount, out var ret));
+
+ if (ret == 0)
+ return null;
+ if (resultingEdgesCount != resultingEdges.Length)
+ Array.Resize(ref resultingEdges, resultingEdgesCount);
+ return resultingEdges;
+ }
+
+ ///
+ /// Point cloud sampling by Voxel Grid filter downsampling.
+ ///
+ /// Creates a 3D voxel grid (a set of tiny 3D boxes in space) over the input point cloud data.
+ /// In each voxel, all the points present are approximated (downsampled) with the point closest to their centroid.
+ ///
+ /// Output flags of the sampled points. sampledPointFlags[i] is 1 if the i-th point is selected, 0 otherwise.
+ /// Original point cloud, Mat of size Nx3/3xN.
+ /// Grid length.
+ /// Grid width.
+ /// Grid height.
+ /// The number of points actually sampled.
+ public static int VoxelGridSampling(OutputArray sampledPointFlags, InputArray inputPts, float length, float width, float height)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_voxelGridSampling(sampledPointFlags.Proxy, inputPts.Proxy, length, width, height, out var ret));
+
+ GC.KeepAlive(sampledPointFlags.Source);
+ GC.KeepAlive(inputPts.Source);
+ return ret;
+ }
+
+ ///
+ /// Point cloud sampling by randomly selecting points.
+ ///
+ /// Point cloud after sampling.
+ /// Original point cloud, Mat of size Nx3/3xN.
+ /// The desired point cloud size after sampling.
+ public static void RandomSampling(OutputArray sampledPts, InputArray inputPts, int sampledPtsSize)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_randomSampling_Size(sampledPts.Proxy, inputPts.Proxy, sampledPtsSize));
+
+ GC.KeepAlive(sampledPts.Source);
+ GC.KeepAlive(inputPts.Source);
+ }
+
+ ///
+ /// Point cloud sampling by randomly selecting points.
+ ///
+ /// Point cloud after sampling.
+ /// Original point cloud, Mat of size Nx3/3xN.
+ /// Range (0, 1); the percentage of the sampled point cloud relative to the original size.
+ public static void RandomSampling(OutputArray sampledPts, InputArray inputPts, float sampledScale)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_randomSampling_Scale(sampledPts.Proxy, inputPts.Proxy, sampledScale));
+
+ GC.KeepAlive(sampledPts.Source);
+ GC.KeepAlive(inputPts.Source);
+ }
+
+ ///
+ /// Point cloud sampling by Farthest Point Sampling (FPS).
+ ///
+ /// Output flags of the sampled points. sampledPointFlags[i] is 1 if the i-th point is selected, 0 otherwise.
+ /// Original point cloud, Mat of size Nx3/3xN.
+ /// The desired point cloud size after sampling.
+ /// Sampling is terminated early if the distance from the farthest point to the sampled set is less than this value.
+ /// The number of points actually sampled.
+ public static int FarthestPointSampling(OutputArray sampledPointFlags, InputArray inputPts, int sampledPtsSize, float distLowerLimit = 0)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_farthestPointSampling_Size(
+ sampledPointFlags.Proxy, inputPts.Proxy, sampledPtsSize, distLowerLimit, out var ret));
+
+ GC.KeepAlive(sampledPointFlags.Source);
+ GC.KeepAlive(inputPts.Source);
+ return ret;
+ }
+
+ ///
+ /// Point cloud sampling by Farthest Point Sampling (FPS).
+ ///
+ /// Output flags of the sampled points. sampledPointFlags[i] is 1 if the i-th point is selected, 0 otherwise.
+ /// Original point cloud, Mat of size Nx3/3xN.
+ /// Range (0, 1); the percentage of the sampled point cloud relative to the original size.
+ /// Sampling is terminated early if the distance from the farthest point to the sampled set is less than this value.
+ /// The number of points actually sampled.
+ public static int FarthestPointSampling(OutputArray sampledPointFlags, InputArray inputPts, float sampledScale, float distLowerLimit = 0)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_farthestPointSampling_Scale(
+ sampledPointFlags.Proxy, inputPts.Proxy, sampledScale, distLowerLimit, out var ret));
+
+ GC.KeepAlive(sampledPointFlags.Source);
+ GC.KeepAlive(inputPts.Source);
+ return ret;
+ }
+
+ ///
+ /// Estimates the normal and curvature of each point in a point cloud from nearest-neighbor results.
+ ///
+ /// Output normal of each point, Mat of size Nx3.
+ /// Output curvature of each point.
+ /// Original point cloud, Mat of size Nx3/3xN.
+ /// Index information of the nearest neighbors of all points, Mat of size NxK. The first nearest
+ /// neighbor of each point is itself.
+ /// The maximum number of neighbors to use, including the point itself. A non-positive
+ /// number (the default) uses the information from .
+ public static void NormalEstimate(OutputArray normals, OutputArray curvatures, InputArray inputPts, InputArray nnIdx, int maxNeighborNum = 0)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_normalEstimate(normals.Proxy, curvatures.Proxy, inputPts.Proxy, nnIdx.Proxy, maxNeighborNum));
+
+ GC.KeepAlive(normals.Source);
+ GC.KeepAlive(curvatures.Source);
+ GC.KeepAlive(inputPts.Source);
+ GC.KeepAlive(nnIdx.Source);
+ }
+
+ ///
+ /// Calculates an affine matrix of 2D rotation.
+ ///
+ /// Center of the rotation in the source image.
+ /// Rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner).
+ /// Isotropic scale factor.
+ ///
+ public static Mat GetRotationMatrix2D(Point2f center, double angle, double scale)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_getRotationMatrix2D(center, angle, scale, out var retMat));
+ return new Mat(retMat);
+ }
+
+
+ ///
+ /// Inverts an affine transformation.
+ ///
+ /// Original affine transformation.
+ /// Output reverse affine transformation.
+ public static void InvertAffineTransform(InputArray m, OutputArray im)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_invertAffineTransform(m.Proxy, im.Proxy));
+ GC.KeepAlive(m.Source);
+ GC.KeepAlive(im.Source);
+ }
+
+
+ ///
+ /// Calculates a perspective transform from four pairs of the corresponding points.
+ /// The function calculates the 3×3 matrix of a perspective transform.
+ ///
+ /// Coordinates of quadrangle vertices in the source image.
+ /// Coordinates of the corresponding quadrangle vertices in the destination image.
+ ///
+ public static Mat GetPerspectiveTransform(IEnumerable src, IEnumerable dst)
+ {
+ if (src is null)
+ throw new ArgumentNullException(nameof(src));
+ if (dst is null)
+ throw new ArgumentNullException(nameof(dst));
+
+ var srcArray = src.ToArray();
+ var dstArray = dst.ToArray();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_getPerspectiveTransform1(srcArray, dstArray, out var retMat));
+ return new Mat(retMat);
+ }
+
+
+ ///
+ /// Calculates a perspective transform from four pairs of the corresponding points.
+ /// The function calculates the 3×3 matrix of a perspective transform.
+ ///
+ /// Coordinates of quadrangle vertices in the source image.
+ /// Coordinates of the corresponding quadrangle vertices in the destination image.
+ ///
+ public static Mat GetPerspectiveTransform(InputArray src, InputArray dst)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_getPerspectiveTransform2(src.Proxy, dst.Proxy, out var retMat));
+ GC.KeepAlive(src.Source);
+ GC.KeepAlive(dst.Source);
+ return new Mat(retMat);
+ }
+
+
+ ///
+ /// Calculates an affine transform from three pairs of the corresponding points.
+ /// The function calculates the 2×3 matrix of an affine transform.
+ ///
+ /// Coordinates of triangle vertices in the source image.
+ /// Coordinates of the corresponding triangle vertices in the destination image.
+ ///
+ public static Mat GetAffineTransform(IEnumerable src, IEnumerable dst)
+ {
+ if (src is null)
+ throw new ArgumentNullException(nameof(src));
+ if (dst is null)
+ throw new ArgumentNullException(nameof(dst));
+
+ var srcArray = src.ToArray();
+ var dstArray = dst.ToArray();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_getAffineTransform1(srcArray, dstArray, out var retMat));
+ return new Mat(retMat);
+ }
+
+
+ ///
+ /// Calculates an affine transform from three pairs of the corresponding points.
+ /// The function calculates the 2×3 matrix of an affine transform.
+ ///
+ /// Coordinates of triangle vertices in the source image.
+ /// Coordinates of the corresponding triangle vertices in the destination image.
+ ///
+ public static Mat GetAffineTransform(InputArray src, InputArray dst)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_getAffineTransform2(src.Proxy, dst.Proxy, out var retMat));
+
+ GC.KeepAlive(src.Source);
+ GC.KeepAlive(dst.Source);
+ return new Mat(retMat);
+ }
+
+
+ ///
+ /// Approximates contour or a curve using Douglas-Peucker algorithm
+ ///
+ /// The polygon or curve to approximate.
+ /// Must be 1 x N or N x 1 matrix of type CV_32SC2 or CV_32FC2.
+ /// The result of the approximation;
+ /// The type should match the type of the input curve
+ /// Specifies the approximation accuracy.
+ /// This is the maximum distance between the original curve and its approximation.
+ /// The result of the approximation;
+ /// The type should match the type of the input curve
+ public static void ApproxPolyDP(InputArray curve, OutputArray approxCurve, double epsilon, bool closed)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_approxPolyDP_InputArray(curve.Proxy, approxCurve.Proxy, epsilon, closed ? 1 : 0));
+
+ GC.KeepAlive(curve.Source);
+ GC.KeepAlive(approxCurve.Source);
+ }
+
+
+ ///
+ /// Approximates contour or a curve using Douglas-Peucker algorithm
+ ///
+ /// The polygon or curve to approximate.
+ /// Specifies the approximation accuracy.
+ /// This is the maximum distance between the original curve and its approximation.
+ /// The result of the approximation;
+ /// The type should match the type of the input curve
+ /// The result of the approximation;
+ /// The type should match the type of the input curve
+ [SuppressMessage("Maintainability", "CA1508: Avoid dead conditional code")]
+ public static Point[] ApproxPolyDP(IEnumerable curve, double epsilon, bool closed)
+ {
+ if(curve is null)
+ throw new ArgumentNullException(nameof(curve));
+ var curveArray = curve as Point[] ?? curve.ToArray();
+ using var approxCurveVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_approxPolyDP_Point(
+ curveArray, curveArray.Length, approxCurveVec.CvPtr, epsilon, closed ? 1 : 0));
+ return approxCurveVec.ToArray();
+ }
+
+
+ ///
+ /// Approximates contour or a curve using Douglas-Peucker algorithm
+ ///
+ /// The polygon or curve to approximate.
+ /// Specifies the approximation accuracy.
+ /// This is the maximum distance between the original curve and its approximation.
+ /// If true, the approximated curve is closed
+ /// (i.e. its first and last vertices are connected), otherwise it’s not
+ /// The result of the approximation;
+ /// The type should match the type of the input curve
+ [SuppressMessage("Maintainability", "CA1508: Avoid dead conditional code")]
+ public static Point2f[] ApproxPolyDP(IEnumerable curve, double epsilon, bool closed)
+ {
+ if (curve is null)
+ throw new ArgumentNullException(nameof(curve));
+ var curveArray = curve as Point2f[] ?? curve.ToArray();
+ using var approxCurveVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_approxPolyDP_Point2f(
+ curveArray, curveArray.Length, approxCurveVec.CvPtr, epsilon, closed ? 1 : 0));
+ return approxCurveVec.ToArray();
+ }
+
+
+ ///
+ /// Calculates a contour perimeter or a curve length.
+ ///
+ /// The input vector of 2D points, represented by CV_32SC2 or CV_32FC2 matrix.
+ /// Indicates, whether the curve is closed or not.
+ ///
+ public static double ArcLength(InputArray curve, bool closed)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_arcLength_InputArray(curve.Proxy, closed ? 1 : 0, out var ret));
+ GC.KeepAlive(curve.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Calculates a contour perimeter or a curve length.
+ ///
+ /// The input vector of 2D points.
+ /// Indicates, whether the curve is closed or not.
+ ///
+ public static double ArcLength(IEnumerable curve, bool closed)
+ {
+ if (curve is null)
+ throw new ArgumentNullException(nameof(curve));
+ var curveArray = curve.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_arcLength_Point(curveArray, curveArray.Length, closed ? 1 : 0, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Calculates a contour perimeter or a curve length.
+ ///
+ /// The input vector of 2D points.
+ /// Indicates, whether the curve is closed or not.
+ ///
+ public static double ArcLength(IEnumerable curve, bool closed)
+ {
+ if (curve is null)
+ throw new ArgumentNullException(nameof(curve));
+ var curveArray = curve.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_arcLength_Point2f(curveArray, curveArray.Length, closed ? 1 : 0, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Calculates the up-right bounding rectangle of a point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ /// Minimal up-right bounding rectangle for the specified point set.
+ public static Rect BoundingRect(InputArray curve)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_boundingRect_InputArray(curve.Proxy, out var ret));
+ GC.KeepAlive(curve.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Calculates the up-right bounding rectangle of a point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ /// Minimal up-right bounding rectangle for the specified point set.
+ public static Rect BoundingRect(IEnumerable curve)
+ {
+ if (curve is null)
+ throw new ArgumentNullException(nameof(curve));
+ var curveArray = curve.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_boundingRect_Point(curveArray, curveArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Calculates the up-right bounding rectangle of a point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ /// Minimal up-right bounding rectangle for the specified point set.
+ public static Rect BoundingRect(IEnumerable curve)
+ {
+ if (curve is null)
+ throw new ArgumentNullException(nameof(curve));
+ var curveArray = curve.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_boundingRect_Point2f(curveArray, curveArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Calculates the contour area
+ ///
+ /// The contour vertices, represented by CV_32SC2 or CV_32FC2 matrix
+ ///
+ ///
+ public static double ContourArea(InputArray contour, bool oriented = false)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_contourArea_InputArray(contour.Proxy, oriented ? 1 : 0, out var ret));
+ GC.KeepAlive(contour.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Calculates the contour area
+ ///
+ /// The contour vertices, represented by CV_32SC2 or CV_32FC2 matrix
+ ///
+ ///
+ public static double ContourArea(IEnumerable contour, bool oriented = false)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ var contourArray = contour.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_contourArea_Point(contourArray, contourArray.Length, oriented ? 1 : 0, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Calculates the contour area
+ ///
+ /// The contour vertices, represented by CV_32SC2 or CV_32FC2 matrix
+ ///
+ ///
+ public static double ContourArea(IEnumerable contour, bool oriented = false)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ var contourArray = contour.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_contourArea_Point2f(contourArray, contourArray.Length, oriented ? 1 : 0, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Finds the minimum area rotated rectangle enclosing a 2D point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ ///
+ public static RotatedRect MinAreaRect(InputArray points)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minAreaRect_InputArray(points.Proxy, out var ret));
+ GC.KeepAlive(points.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Finds the minimum area rotated rectangle enclosing a 2D point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ ///
+ public static RotatedRect MinAreaRect(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minAreaRect_Point(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Finds the minimum area rotated rectangle enclosing a 2D point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ ///
+ public static RotatedRect MinAreaRect(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minAreaRect_Point2f(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.
+ ///
+ /// The function finds the four vertices of a rotated rectangle.This function is useful to draw the
+ /// rectangle.In C++, instead of using this function, you can directly use RotatedRect::points method. Please
+ /// visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information.
+ ///
+ /// The input rotated rectangle. It may be the output of
+ /// The output array of four vertices of rectangles.
+ ///
+ public static void BoxPoints(RotatedRect box, OutputArray points)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_boxPoints_OutputArray(box, points.Proxy));
+
+ GC.KeepAlive(points.Source);
+ }
+
+
+ ///
+ /// Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.
+ ///
+ /// The function finds the four vertices of a rotated rectangle.This function is useful to draw the
+ /// rectangle.In C++, instead of using this function, you can directly use RotatedRect::points method. Please
+ /// visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information.
+ ///
+ /// The input rotated rectangle. It may be the output of
+ /// The output array of four vertices of rectangles.
+ public static Point2f[] BoxPoints(RotatedRect box)
+ {
+ var points = new Point2f[4];
+ NativeMethods.HandleException(
+ NativeMethods.geometry_boxPoints_Point2f(box, points));
+ return points;
+ }
+
+
+ ///
+ /// Finds the minimum area circle enclosing a 2D point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ /// The output center of the circle
+ /// The output radius of the circle
+ public static void MinEnclosingCircle(InputArray points, out Point2f center, out float radius)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minEnclosingCircle_InputArray(points.Proxy, out center, out radius));
+ GC.KeepAlive(points.Source);
+ }
+
+
+ ///
+ /// Finds the minimum area circle enclosing a 2D point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ /// The output center of the circle
+ /// The output radius of the circle
+ public static void MinEnclosingCircle(IEnumerable points, out Point2f center, out float radius)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minEnclosingCircle_Point(pointsArray, pointsArray.Length, out center, out radius));
+ }
+
+
+ ///
+ /// Finds the minimum area circle enclosing a 2D point set.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
+ /// The output center of the circle
+ /// The output radius of the circle
+ public static void MinEnclosingCircle(IEnumerable points, out Point2f center, out float radius)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minEnclosingCircle_Point2f(pointsArray, pointsArray.Length, out center, out radius));
+ }
+
+
+ ///
+ /// Finds a triangle of minimum area enclosing a 2D point set and returns its area.
+ ///
+ /// Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector or Mat
+ /// Output vector of three 2D points defining the vertices of the triangle. The depth
+ /// Triangle area
+ public static double MinEnclosingTriangle(InputArray points, OutputArray triangle)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minEnclosingTriangle_InputOutputArray(points.Proxy, triangle.Proxy, out var ret));
+
+ GC.KeepAlive(points.Source);
+ GC.KeepAlive(triangle.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Finds a triangle of minimum area enclosing a 2D point set and returns its area.
+ ///
+ /// Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector or Mat
+ /// Output vector of three 2D points defining the vertices of the triangle. The depth
+ /// Triangle area
+ public static double MinEnclosingTriangle(IEnumerable points, out Point2f[] triangle)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+
+ var pointsArray = points.ToArray();
+ using var triangleVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minEnclosingTriangle_Point(
+ pointsArray, pointsArray.Length, triangleVec.CvPtr, out var ret));
+
+ GC.KeepAlive(pointsArray);
+ triangle = triangleVec.ToArray();
+ return ret;
+ }
+
+
+ ///
+ /// Finds a triangle of minimum area enclosing a 2D point set and returns its area.
+ ///
+ /// Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector or Mat
+ /// Output vector of three 2D points defining the vertices of the triangle. The depth
+ /// Triangle area
+ public static double MinEnclosingTriangle(IEnumerable points, out Point2f[] triangle)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+
+ var pointsArray = points.ToArray();
+ using var triangleVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_minEnclosingTriangle_Point2f(
+ pointsArray, pointsArray.Length, triangleVec.CvPtr, out var ret));
+
+ GC.KeepAlive(pointsArray);
+ triangle = triangleVec.ToArray();
+ return ret;
+ }
+
+
+ ///
+ /// Compares two shapes.
+ ///
+ /// First contour or grayscale image.
+ /// Second contour or grayscale image.
+ /// Comparison method
+ /// Method-specific parameter (not supported now)
+ ///
+ public static double MatchShapes(InputArray contour1, InputArray contour2, ShapeMatchModes method, double parameter = 0)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_matchShapes_InputArray(contour1.Proxy, contour2.Proxy, (int)method, parameter, out var ret));
+
+ GC.KeepAlive(contour1.Source);
+ GC.KeepAlive(contour2.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Compares two shapes.
+ ///
+ /// First contour or grayscale image.
+ /// Second contour or grayscale image.
+ /// Comparison method
+ /// Method-specific parameter (not supported now)
+ ///
+ public static double MatchShapes(IEnumerable contour1, IEnumerable contour2,
+ ShapeMatchModes method, double parameter = 0)
+ {
+ if (contour1 is null)
+ throw new ArgumentNullException(nameof(contour1));
+ if (contour2 is null)
+ throw new ArgumentNullException(nameof(contour2));
+ var contour1Array = contour1.ToArray();
+ var contour2Array = contour2.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_matchShapes_Point(
+ contour1Array, contour1Array.Length,
+ contour2Array, contour2Array.Length,
+ (int) method, parameter, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Computes convex hull for a set of 2D points.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
+ /// The output convex hull. It is either a vector of points that form the
+ /// hull (must have the same type as the input points), or a vector of 0-based point
+ /// indices of the hull points in the original array (since the set of convex hull
+ /// points is a subset of the original point set).
+ /// If true, the output convex hull will be oriented clockwise,
+ /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
+ /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
+ /// and y axis is oriented downwards.
+ ///
+ public static void ConvexHull(InputArray points, OutputArray hull, bool clockwise = false, bool returnPoints = true)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexHull_InputArray(points.Proxy, hull.Proxy, clockwise ? 1 : 0, returnPoints ? 1 : 0));
+
+ GC.KeepAlive(points.Source);
+ GC.KeepAlive(hull.Source);
+ }
+
+
+ ///
+ /// Computes convex hull for a set of 2D points.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
+ /// If true, the output convex hull will be oriented clockwise,
+ /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
+ /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
+ /// and y axis is oriented downwards.
+ /// The output convex hull. It is a vector of points that form
+ /// the hull (must have the same type as the input points).
+ public static Point[] ConvexHull(IEnumerable points, bool clockwise = false)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ using var hullVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexHull_Point_ReturnsPoints(
+ pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
+
+ return hullVec.ToArray();
+ }
+
+
+ ///
+ /// Computes convex hull for a set of 2D points.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
+ /// If true, the output convex hull will be oriented clockwise,
+ /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
+ /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
+ /// and y axis is oriented downwards.
+ /// The output convex hull. It is a vector of points that form
+ /// the hull (must have the same type as the input points).
+ public static Point2f[] ConvexHull(IEnumerable points, bool clockwise = false)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ using var hullVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexHull_Point2f_ReturnsPoints(
+ pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
+ return hullVec.ToArray();
+ }
+
+
+ ///
+ /// Computes convex hull for a set of 2D points.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
+ /// If true, the output convex hull will be oriented clockwise,
+ /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
+ /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
+ /// and y axis is oriented downwards.
+ /// The output convex hull. It is a vector of 0-based point indices of the
+ /// hull points in the original array (since the set of convex hull points is a subset of the original point set).
+ public static int[] ConvexHullIndices(IEnumerable points, bool clockwise = false)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ using var hullVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexHull_Point_ReturnsIndices(
+ pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
+ return hullVec.ToArray();
+ }
+
+
+ ///
+ /// Computes convex hull for a set of 2D points.
+ ///
+ /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
+ /// If true, the output convex hull will be oriented clockwise,
+ /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
+ /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
+ /// and y axis is oriented downwards.
+ /// The output convex hull. It is a vector of 0-based point indices of the
+ /// hull points in the original array (since the set of convex hull points is a subset of the original point set).
+ public static int[] ConvexHullIndices(IEnumerable points, bool clockwise = false)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ using var hullVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexHull_Point2f_ReturnsIndices(
+ pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
+ return hullVec.ToArray();
+ }
+
+
+ ///
+ /// Computes the contour convexity defects
+ ///
+ /// Input contour.
+ /// Convex hull obtained using convexHull() that
+ /// should contain indices of the contour points that make the hull.
+ ///
+ /// The output vector of convexity defects.
+ /// Each convexity defect is represented as 4-element integer vector
+ /// (a.k.a. cv::Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth),
+ /// where indices are 0-based indices in the original contour of the convexity defect beginning,
+ /// end and the farthest point, and fixpt_depth is fixed-point approximation
+ /// (with 8 fractional bits) of the distance between the farthest contour point and the hull.
+ /// That is, to get the floating-point value of the depth will be fixpt_depth/256.0.
+ ///
+ public static void ConvexityDefects(InputArray contour, InputArray convexHull, OutputArray convexityDefects)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexityDefects_InputArray(contour.Proxy, convexHull.Proxy, convexityDefects.Proxy));
+
+ GC.KeepAlive(contour.Source);
+ GC.KeepAlive(convexHull.Source);
+ GC.KeepAlive(convexityDefects.Source);
+ }
+
+
+ ///
+ /// Computes the contour convexity defects
+ ///
+ /// Input contour.
+ /// Convex hull obtained using convexHull() that
+ /// should contain indices of the contour points that make the hull.
+ /// The output vector of convexity defects.
+ /// Each convexity defect is represented as 4-element integer vector
+ /// (a.k.a. cv::Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth),
+ /// where indices are 0-based indices in the original contour of the convexity defect beginning,
+ /// end and the farthest point, and fixpt_depth is fixed-point approximation
+ /// (with 8 fractional bits) of the distance between the farthest contour point and the hull.
+ /// That is, to get the floating-point value of the depth will be fixpt_depth/256.0.
+ public static Vec4i[] ConvexityDefects(IEnumerable contour, IEnumerable convexHull)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ if (convexHull is null)
+ throw new ArgumentNullException(nameof(convexHull));
+
+ var contourArray = contour.ToArray();
+ var convexHullArray = convexHull.ToArray();
+ using var convexityDefectsVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexityDefects_Point(
+ contourArray, contourArray.Length,
+ convexHullArray, convexHullArray.Length, convexityDefectsVec.CvPtr));
+
+ return convexityDefectsVec.ToArray();
+ }
+
+
+ ///
+ /// Computes the contour convexity defects
+ ///
+ /// Input contour.
+ /// Convex hull obtained using convexHull() that
+ /// should contain indices of the contour points that make the hull.
+ /// The output vector of convexity defects.
+ /// Each convexity defect is represented as 4-element integer vector
+ /// (a.k.a. cv::Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth),
+ /// where indices are 0-based indices in the original contour of the convexity defect beginning,
+ /// end and the farthest point, and fixpt_depth is fixed-point approximation
+ /// (with 8 fractional bits) of the distance between the farthest contour point and the hull.
+ /// That is, to get the floating-point value of the depth will be fixpt_depth/256.0.
+ public static Vec4i[] ConvexityDefects(IEnumerable contour, IEnumerable convexHull)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ if (convexHull is null)
+ throw new ArgumentNullException(nameof(convexHull));
+
+ var contourArray = contour.ToArray();
+ var convexHullArray = convexHull.ToArray();
+ using var convexityDefectsVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_convexityDefects_Point2f(
+ contourArray, contourArray.Length,
+ convexHullArray, convexHullArray.Length, convexityDefectsVec.CvPtr));
+ return convexityDefectsVec.ToArray();
+ }
+
+
+ ///
+ /// returns true if the contour is convex.
+ /// Does not support contours with self-intersection
+ ///
+ /// Input vector of 2D points
+ ///
+ public static bool IsContourConvex(InputArray contour)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_isContourConvex_InputArray(contour.Proxy, out var ret));
+
+ GC.KeepAlive(contour.Source);
+ return ret != 0;
+ }
+
+
+ ///
+ /// returns true if the contour is convex.
+ /// Does not support contours with self-intersection
+ ///
+ /// Input vector of 2D points
+ ///
+ public static bool IsContourConvex(IEnumerable contour)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ var contourArray = contour.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_isContourConvex_Point(contourArray, contourArray.Length, out var ret));
+ return ret != 0;
+ }
+
+
+ ///
+ /// returns true if the contour is convex. D
+ /// oes not support contours with self-intersection
+ ///
+ /// Input vector of 2D points
+ ///
+ public static bool IsContourConvex(IEnumerable contour)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ var contourArray = contour.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_isContourConvex_Point2f(contourArray, contourArray.Length, out var ret));
+ return ret != 0;
+ }
+
+
+ ///
+ /// finds intersection of two convex polygons
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static float IntersectConvexConvex(InputArray p1, InputArray p2, OutputArray p12, bool handleNested = true)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_intersectConvexConvex_InputArray(
+ p1.Proxy, p2.Proxy, p12.Proxy, handleNested ? 1 : 0, out var ret));
+
+ GC.KeepAlive(p1.Source);
+ GC.KeepAlive(p2.Source);
+ GC.KeepAlive(p12.Source);
+ return ret;
+ }
+
+
+ ///
+ /// finds intersection of two convex polygons
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static float IntersectConvexConvex(IEnumerable p1, IEnumerable p2,
+ out Point[] p12, bool handleNested = true)
+ {
+ if (p1 is null)
+ throw new ArgumentNullException(nameof(p1));
+ if (p2 is null)
+ throw new ArgumentNullException(nameof(p2));
+ var p1Array = p1.ToArray();
+ var p2Array = p2.ToArray();
+
+ using var p12Vec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_intersectConvexConvex_Point(
+ p1Array, p1Array.Length, p2Array, p2Array.Length, p12Vec.CvPtr, handleNested ? 1 : 0, out var ret));
+
+ p12 = p12Vec.ToArray();
+
+ return ret;
+ }
+
+
+ ///
+ /// finds intersection of two convex polygons
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static float IntersectConvexConvex(IEnumerable p1, IEnumerable p2,
+ out Point2f[] p12, bool handleNested = true)
+ {
+ if (p1 is null)
+ throw new ArgumentNullException(nameof(p1));
+ if (p2 is null)
+ throw new ArgumentNullException(nameof(p2));
+ var p1Array = p1.ToArray();
+ var p2Array = p2.ToArray();
+
+ using var p12Vec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_intersectConvexConvex_Point2f(
+ p1Array, p1Array.Length, p2Array, p2Array.Length,
+ p12Vec.CvPtr, handleNested ? 1 : 0, out var ret));
+
+ p12 = p12Vec.ToArray();
+
+ return ret;
+ }
+
+
+ ///
+ /// Fits ellipse to the set of 2D points.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipse(InputArray points)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipse_InputArray(points.Proxy, out var ret));
+
+ GC.KeepAlive(points.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Fits ellipse to the set of 2D points.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipse(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipse_Point(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Fits ellipse to the set of 2D points.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipse(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipse_Point2f(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Fits an ellipse around a set of 2D points.
+ ///
+ /// The function calculates the ellipse that fits a set of 2D points.
+ /// It returns the rotated rectangle in which the ellipse is inscribed.
+ /// The Approximate Mean Square(AMS) proposed by @cite Taubin1991 is used.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipseAMS(InputArray points)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipseAMS_InputArray(points.Proxy, out var ret));
+
+ GC.KeepAlive(points.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Fits an ellipse around a set of 2D points.
+ ///
+ /// The function calculates the ellipse that fits a set of 2D points.
+ /// It returns the rotated rectangle in which the ellipse is inscribed.
+ /// The Approximate Mean Square(AMS) proposed by @cite Taubin1991 is used.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipseAMS(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipseAMS_Point(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Fits an ellipse around a set of 2D points.
+ ///
+ /// The function calculates the ellipse that fits a set of 2D points.
+ /// It returns the rotated rectangle in which the ellipse is inscribed.
+ /// The Approximate Mean Square(AMS) proposed by @cite Taubin1991 is used.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipseAMS(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipseAMS_Point2f(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Fits an ellipse around a set of 2D points.
+ ///
+ /// The function calculates the ellipse that fits a set of 2D points.
+ /// It returns the rotated rectangle in which the ellipse is inscribed.
+ /// The Direct least square(Direct) method by @cite Fitzgibbon1999 is used.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipseDirect(InputArray points)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipseDirect_InputArray(points.Proxy, out var ret));
+
+ GC.KeepAlive(points.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Fits an ellipse around a set of 2D points.
+ ///
+ /// The function calculates the ellipse that fits a set of 2D points.
+ /// It returns the rotated rectangle in which the ellipse is inscribed.
+ /// The Direct least square(Direct) method by @cite Fitzgibbon1999 is used.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipseDirect(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipseDirect_Point(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Fits an ellipse around a set of 2D points.
+ ///
+ /// The function calculates the ellipse that fits a set of 2D points.
+ /// It returns the rotated rectangle in which the ellipse is inscribed.
+ /// The Direct least square(Direct) method by @cite Fitzgibbon1999 is used.
+ ///
+ /// Input 2D point set
+ ///
+ public static RotatedRect FitEllipseDirect(IEnumerable points)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitEllipseDirect_Point2f(pointsArray, pointsArray.Length, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Fits line to the set of 2D points using M-estimator algorithm
+ ///
+ /// Input vector of 2D or 3D points
+ /// Output line parameters.
+ /// In case of 2D fitting, it should be a vector of 4 elements
+ /// (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector
+ /// collinear to the line and (x0, y0) is a point on the line.
+ /// In case of 3D fitting, it should be a vector of 6 elements
+ /// (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a
+ /// normalized vector collinear to the line and (x0, y0, z0) is a point on the line.
+ /// Distance used by the M-estimator
+ /// Numerical parameter ( C ) for some types of distances.
+ /// If it is 0, an optimal value is chosen.
+ /// Sufficient accuracy for the radius
+ /// (distance between the coordinate origin and the line).
+ /// Sufficient accuracy for the angle.
+ /// 0.01 would be a good default value for reps and aeps.
+ public static void FitLine(InputArray points, OutputArray line, DistanceTypes distType,
+ double param, double reps, double aeps)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitLine_InputArray(
+ points.Proxy, line.Proxy, (int) distType, param, reps, aeps));
+
+ GC.KeepAlive(points.Source);
+ GC.KeepAlive(line.Source);
+ }
+
+
+ ///
+ /// Fits line to the set of 2D points using M-estimator algorithm
+ ///
+ /// Input vector of 2D or 3D points
+ /// Distance used by the M-estimator
+ /// Numerical parameter ( C ) for some types of distances.
+ /// If it is 0, an optimal value is chosen.
+ /// Sufficient accuracy for the radius
+ /// (distance between the coordinate origin and the line).
+ /// Sufficient accuracy for the angle.
+ /// 0.01 would be a good default value for reps and aeps.
+ /// Output line parameters.
+ public static Line2D FitLine(IEnumerable points, DistanceTypes distType,
+ double param, double reps, double aeps)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+ var line = new float[4];
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitLine_Point(
+ pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
+ return new Line2D(line);
+ }
+
+
+ ///
+ /// Fits line to the set of 2D points using M-estimator algorithm
+ ///
+ /// Input vector of 2D or 3D points
+ /// Distance used by the M-estimator
+ /// Numerical parameter ( C ) for some types of distances.
+ /// If it is 0, an optimal value is chosen.
+ /// Sufficient accuracy for the radius
+ /// (distance between the coordinate origin and the line).
+ /// Sufficient accuracy for the angle.
+ /// 0.01 would be a good default value for reps and aeps.
+ /// Output line parameters.
+ public static Line2D FitLine(IEnumerable points, DistanceTypes distType,
+ double param, double reps, double aeps)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+ var line = new float[4];
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitLine_Point2f(
+ pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
+ return new Line2D(line);
+ }
+
+
+ ///
+ /// Fits line to the set of 3D points using M-estimator algorithm
+ ///
+ /// Input vector of 2D or 3D points
+ /// Distance used by the M-estimator
+ /// Numerical parameter ( C ) for some types of distances.
+ /// If it is 0, an optimal value is chosen.
+ /// Sufficient accuracy for the radius
+ /// (distance between the coordinate origin and the line).
+ /// Sufficient accuracy for the angle.
+ /// 0.01 would be a good default value for reps and aeps.
+ /// Output line parameters.
+ public static Line3D FitLine(IEnumerable points, DistanceTypes distType,
+ double param, double reps, double aeps)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+ var line = new float[6];
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitLine_Point3i(
+ pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
+ return new Line3D(line);
+ }
+
+
+ ///
+ /// Fits line to the set of 3D points using M-estimator algorithm
+ ///
+ /// Input vector of 2D or 3D points
+ /// Distance used by the M-estimator
+ /// Numerical parameter ( C ) for some types of distances.
+ /// If it is 0, an optimal value is chosen.
+ /// Sufficient accuracy for the radius
+ /// (distance between the coordinate origin and the line).
+ /// Sufficient accuracy for the angle.
+ /// 0.01 would be a good default value for reps and aeps.
+ /// Output line parameters.
+ public static Line3D FitLine(IEnumerable points, DistanceTypes distType,
+ double param, double reps, double aeps)
+ {
+ if (points is null)
+ throw new ArgumentNullException(nameof(points));
+ var pointsArray = points.ToArray();
+ var line = new float[6];
+ NativeMethods.HandleException(
+ NativeMethods.geometry_fitLine_Point3f(
+ pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
+ return new Line3D(line);
+ }
+
+
+ ///
+ /// Checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static double PointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_pointPolygonTest_InputArray(
+ contour.Proxy, pt, measureDist ? 1 : 0, out var ret));
+ GC.KeepAlive(contour.Source);
+ return ret;
+ }
+
+
+ ///
+ /// Checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static double PointPolygonTest(IEnumerable contour, Point2f pt, bool measureDist)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ var contourArray = contour.ToArray();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_pointPolygonTest_Point(
+ contourArray, contourArray.Length, pt, measureDist ? 1 : 0, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Checks if the point is inside the contour.
+ /// Optionally computes the signed distance from the point to the contour boundary.
+ ///
+ /// Input contour.
+ /// Point tested against the contour.
+ /// If true, the function estimates the signed distance
+ /// from the point to the nearest contour edge. Otherwise, the function only checks
+ /// if the point is inside a contour or not.
+ /// Positive (inside), negative (outside), or zero (on an edge) value.
+ public static double PointPolygonTest(IEnumerable contour, Point2f pt, bool measureDist)
+ {
+ if (contour is null)
+ throw new ArgumentNullException(nameof(contour));
+ var contourArray = contour.ToArray();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_pointPolygonTest_Point2f(
+ contourArray, contourArray.Length, pt, measureDist ? 1 : 0, out var ret));
+ return ret;
+ }
+
+
+ ///
+ /// Finds out if there is any intersection between two rotated rectangles.
+ /// If there is then the vertices of the interesecting region are returned as well.
+ /// Below are some examples of intersection configurations.
+ /// The hatched pattern indicates the intersecting region and the red
+ /// vertices are returned by the function.
+ ///
+ /// First rectangle
+ /// Second rectangle
+ ///
+ /// The output array of the verticies of the intersecting region.
+ /// It returns at most 8 vertices.
+ /// Stored as std::vector<cv::Point2f> or cv::Mat as Mx1 of type CV_32FC2.
+ ///
+ public static RectanglesIntersectTypes RotatedRectangleIntersection(
+ RotatedRect rect1, RotatedRect rect2, OutputArray intersectingRegion)
+ {
+ NativeMethods.HandleException(
+ NativeMethods.geometry_rotatedRectangleIntersection_OutputArray(
+ rect1, rect2, intersectingRegion.Proxy, out var ret));
+
+ GC.KeepAlive(intersectingRegion.Source);
+
+ return (RectanglesIntersectTypes)ret;
+ }
+
+
+ ///
+ /// Finds out if there is any intersection between two rotated rectangles.
+ /// If there is then the vertices of the interesecting region are returned as well.
+ /// Below are some examples of intersection configurations.
+ /// The hatched pattern indicates the intersecting region and the red
+ /// vertices are returned by the function.
+ ///
+ /// First rectangle
+ /// Second rectangle
+ ///
+ /// The output array of the verticies of the intersecting region.
+ /// It returns at most 8 vertices.
+ ///
+ public static RectanglesIntersectTypes RotatedRectangleIntersection(
+ RotatedRect rect1, RotatedRect rect2, out Point2f[] intersectingRegion)
+ {
+ using var intersectingRegionVec = new StdVector();
+ NativeMethods.HandleException(
+ NativeMethods.geometry_rotatedRectangleIntersection_vector(
+ rect1, rect2, intersectingRegionVec.CvPtr, out var ret));
+
+ intersectingRegion = intersectingRegionVec.ToArray();
+ return (RectanglesIntersectTypes) ret;
+ }
}
diff --git a/src/OpenCvSharp/Cv2/Cv2_imgproc.cs b/src/OpenCvSharp/Cv2/Cv2_imgproc.cs
index c95f2b6c8..a53d120a6 100644
--- a/src/OpenCvSharp/Cv2/Cv2_imgproc.cs
+++ b/src/OpenCvSharp/Cv2/Cv2_imgproc.cs
@@ -945,108 +945,6 @@ public static void ConvertMaps(InputArray map1, InputArray map2, OutputArray dst
GC.KeepAlive(dstmap2.Source);
}
- ///
- /// Calculates an affine matrix of 2D rotation.
- ///
- /// Center of the rotation in the source image.
- /// Rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner).
- /// Isotropic scale factor.
- ///
- public static Mat GetRotationMatrix2D(Point2f center, double angle, double scale)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_getRotationMatrix2D(center, angle, scale, out var retMat));
- return new Mat(retMat);
- }
-
- ///
- /// Inverts an affine transformation.
- ///
- /// Original affine transformation.
- /// Output reverse affine transformation.
- public static void InvertAffineTransform(InputArray m, OutputArray im)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_invertAffineTransform(m.Proxy, im.Proxy));
- GC.KeepAlive(m.Source);
- GC.KeepAlive(im.Source);
- }
-
- ///
- /// Calculates a perspective transform from four pairs of the corresponding points.
- /// The function calculates the 3×3 matrix of a perspective transform.
- ///
- /// Coordinates of quadrangle vertices in the source image.
- /// Coordinates of the corresponding quadrangle vertices in the destination image.
- ///
- public static Mat GetPerspectiveTransform(IEnumerable src, IEnumerable dst)
- {
- if (src is null)
- throw new ArgumentNullException(nameof(src));
- if (dst is null)
- throw new ArgumentNullException(nameof(dst));
-
- var srcArray = src.ToArray();
- var dstArray = dst.ToArray();
- NativeMethods.HandleException(
- NativeMethods.imgproc_getPerspectiveTransform1(srcArray, dstArray, out var retMat));
- return new Mat(retMat);
- }
-
- ///
- /// Calculates a perspective transform from four pairs of the corresponding points.
- /// The function calculates the 3×3 matrix of a perspective transform.
- ///
- /// Coordinates of quadrangle vertices in the source image.
- /// Coordinates of the corresponding quadrangle vertices in the destination image.
- ///
- public static Mat GetPerspectiveTransform(InputArray src, InputArray dst)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_getPerspectiveTransform2(src.Proxy, dst.Proxy, out var retMat));
- GC.KeepAlive(src.Source);
- GC.KeepAlive(dst.Source);
- return new Mat(retMat);
- }
-
- ///
- /// Calculates an affine transform from three pairs of the corresponding points.
- /// The function calculates the 2×3 matrix of an affine transform.
- ///
- /// Coordinates of triangle vertices in the source image.
- /// Coordinates of the corresponding triangle vertices in the destination image.
- ///
- public static Mat GetAffineTransform(IEnumerable src, IEnumerable dst)
- {
- if (src is null)
- throw new ArgumentNullException(nameof(src));
- if (dst is null)
- throw new ArgumentNullException(nameof(dst));
-
- var srcArray = src.ToArray();
- var dstArray = dst.ToArray();
- NativeMethods.HandleException(
- NativeMethods.imgproc_getAffineTransform1(srcArray, dstArray, out var retMat));
- return new Mat(retMat);
- }
-
- ///
- /// Calculates an affine transform from three pairs of the corresponding points.
- /// The function calculates the 2×3 matrix of an affine transform.
- ///
- /// Coordinates of triangle vertices in the source image.
- /// Coordinates of the corresponding triangle vertices in the destination image.
- ///
- public static Mat GetAffineTransform(InputArray src, InputArray dst)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_getAffineTransform2(src.Proxy, dst.Proxy, out var retMat));
-
- GC.KeepAlive(src.Source);
- GC.KeepAlive(dst.Source);
- return new Mat(retMat);
- }
-
///
/// Retrieves a pixel rectangle from an image with sub-pixel accuracy.
///
@@ -2404,1161 +2302,6 @@ public static Mat[] FindContoursAsMat(InputArray image,
return contoursVec.ToArray>();
}
- ///
- /// Approximates contour or a curve using Douglas-Peucker algorithm
- ///
- /// The polygon or curve to approximate.
- /// Must be 1 x N or N x 1 matrix of type CV_32SC2 or CV_32FC2.
- /// The result of the approximation;
- /// The type should match the type of the input curve
- /// Specifies the approximation accuracy.
- /// This is the maximum distance between the original curve and its approximation.
- /// The result of the approximation;
- /// The type should match the type of the input curve
- public static void ApproxPolyDP(InputArray curve, OutputArray approxCurve, double epsilon, bool closed)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_approxPolyDP_InputArray(curve.Proxy, approxCurve.Proxy, epsilon, closed ? 1 : 0));
-
- GC.KeepAlive(curve.Source);
- GC.KeepAlive(approxCurve.Source);
- }
-
- ///
- /// Approximates contour or a curve using Douglas-Peucker algorithm
- ///
- /// The polygon or curve to approximate.
- /// Specifies the approximation accuracy.
- /// This is the maximum distance between the original curve and its approximation.
- /// The result of the approximation;
- /// The type should match the type of the input curve
- /// The result of the approximation;
- /// The type should match the type of the input curve
- [SuppressMessage("Maintainability", "CA1508: Avoid dead conditional code")]
- public static Point[] ApproxPolyDP(IEnumerable curve, double epsilon, bool closed)
- {
- if(curve is null)
- throw new ArgumentNullException(nameof(curve));
- var curveArray = curve as Point[] ?? curve.ToArray();
- using var approxCurveVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_approxPolyDP_Point(
- curveArray, curveArray.Length, approxCurveVec.CvPtr, epsilon, closed ? 1 : 0));
- return approxCurveVec.ToArray();
- }
-
- ///
- /// Approximates contour or a curve using Douglas-Peucker algorithm
- ///
- /// The polygon or curve to approximate.
- /// Specifies the approximation accuracy.
- /// This is the maximum distance between the original curve and its approximation.
- /// If true, the approximated curve is closed
- /// (i.e. its first and last vertices are connected), otherwise it’s not
- /// The result of the approximation;
- /// The type should match the type of the input curve
- [SuppressMessage("Maintainability", "CA1508: Avoid dead conditional code")]
- public static Point2f[] ApproxPolyDP(IEnumerable curve, double epsilon, bool closed)
- {
- if (curve is null)
- throw new ArgumentNullException(nameof(curve));
- var curveArray = curve as Point2f[] ?? curve.ToArray();
- using var approxCurveVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_approxPolyDP_Point2f(
- curveArray, curveArray.Length, approxCurveVec.CvPtr, epsilon, closed ? 1 : 0));
- return approxCurveVec.ToArray();
- }
-
- ///
- /// Calculates a contour perimeter or a curve length.
- ///
- /// The input vector of 2D points, represented by CV_32SC2 or CV_32FC2 matrix.
- /// Indicates, whether the curve is closed or not.
- ///
- public static double ArcLength(InputArray curve, bool closed)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_arcLength_InputArray(curve.Proxy, closed ? 1 : 0, out var ret));
- GC.KeepAlive(curve.Source);
- return ret;
- }
-
- ///
- /// Calculates a contour perimeter or a curve length.
- ///
- /// The input vector of 2D points.
- /// Indicates, whether the curve is closed or not.
- ///
- public static double ArcLength(IEnumerable curve, bool closed)
- {
- if (curve is null)
- throw new ArgumentNullException(nameof(curve));
- var curveArray = curve.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_arcLength_Point(curveArray, curveArray.Length, closed ? 1 : 0, out var ret));
- return ret;
- }
-
- ///
- /// Calculates a contour perimeter or a curve length.
- ///
- /// The input vector of 2D points.
- /// Indicates, whether the curve is closed or not.
- ///
- public static double ArcLength(IEnumerable curve, bool closed)
- {
- if (curve is null)
- throw new ArgumentNullException(nameof(curve));
- var curveArray = curve.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_arcLength_Point2f(curveArray, curveArray.Length, closed ? 1 : 0, out var ret));
- return ret;
- }
-
- ///
- /// Calculates the up-right bounding rectangle of a point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- /// Minimal up-right bounding rectangle for the specified point set.
- public static Rect BoundingRect(InputArray curve)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_boundingRect_InputArray(curve.Proxy, out var ret));
- GC.KeepAlive(curve.Source);
- return ret;
- }
-
- ///
- /// Calculates the up-right bounding rectangle of a point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- /// Minimal up-right bounding rectangle for the specified point set.
- public static Rect BoundingRect(IEnumerable curve)
- {
- if (curve is null)
- throw new ArgumentNullException(nameof(curve));
- var curveArray = curve.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_boundingRect_Point(curveArray, curveArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Calculates the up-right bounding rectangle of a point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- /// Minimal up-right bounding rectangle for the specified point set.
- public static Rect BoundingRect(IEnumerable curve)
- {
- if (curve is null)
- throw new ArgumentNullException(nameof(curve));
- var curveArray = curve.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_boundingRect_Point2f(curveArray, curveArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Calculates the contour area
- ///
- /// The contour vertices, represented by CV_32SC2 or CV_32FC2 matrix
- ///
- ///
- public static double ContourArea(InputArray contour, bool oriented = false)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_contourArea_InputArray(contour.Proxy, oriented ? 1 : 0, out var ret));
- GC.KeepAlive(contour.Source);
- return ret;
- }
-
- ///
- /// Calculates the contour area
- ///
- /// The contour vertices, represented by CV_32SC2 or CV_32FC2 matrix
- ///
- ///
- public static double ContourArea(IEnumerable contour, bool oriented = false)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- var contourArray = contour.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_contourArea_Point(contourArray, contourArray.Length, oriented ? 1 : 0, out var ret));
- return ret;
- }
-
- ///
- /// Calculates the contour area
- ///
- /// The contour vertices, represented by CV_32SC2 or CV_32FC2 matrix
- ///
- ///
- public static double ContourArea(IEnumerable contour, bool oriented = false)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- var contourArray = contour.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_contourArea_Point2f(contourArray, contourArray.Length, oriented ? 1 : 0, out var ret));
- return ret;
- }
-
- ///
- /// Finds the minimum area rotated rectangle enclosing a 2D point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- ///
- public static RotatedRect MinAreaRect(InputArray points)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_minAreaRect_InputArray(points.Proxy, out var ret));
- GC.KeepAlive(points.Source);
- return ret;
- }
-
- ///
- /// Finds the minimum area rotated rectangle enclosing a 2D point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- ///
- public static RotatedRect MinAreaRect(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_minAreaRect_Point(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Finds the minimum area rotated rectangle enclosing a 2D point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- ///
- public static RotatedRect MinAreaRect(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_minAreaRect_Point2f(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.
- ///
- /// The function finds the four vertices of a rotated rectangle.This function is useful to draw the
- /// rectangle.In C++, instead of using this function, you can directly use RotatedRect::points method. Please
- /// visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information.
- ///
- /// The input rotated rectangle. It may be the output of
- /// The output array of four vertices of rectangles.
- ///
- public static void BoxPoints(RotatedRect box, OutputArray points)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_boxPoints_OutputArray(box, points.Proxy));
- }
-
- ///
- /// Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.
- ///
- /// The function finds the four vertices of a rotated rectangle.This function is useful to draw the
- /// rectangle.In C++, instead of using this function, you can directly use RotatedRect::points method. Please
- /// visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information.
- ///
- /// The input rotated rectangle. It may be the output of
- /// The output array of four vertices of rectangles.
- public static Point2f[] BoxPoints(RotatedRect box)
- {
- var points = new Point2f[4];
- NativeMethods.HandleException(
- NativeMethods.imgproc_boxPoints_Point2f(box, points));
- return points;
- }
-
- ///
- /// Finds the minimum area circle enclosing a 2D point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- /// The output center of the circle
- /// The output radius of the circle
- public static void MinEnclosingCircle(InputArray points, out Point2f center, out float radius)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_minEnclosingCircle_InputArray(points.Proxy, out center, out radius));
- GC.KeepAlive(points.Source);
- }
-
- ///
- /// Finds the minimum area circle enclosing a 2D point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- /// The output center of the circle
- /// The output radius of the circle
- public static void MinEnclosingCircle(IEnumerable points, out Point2f center, out float radius)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
- NativeMethods.HandleException(
- NativeMethods.imgproc_minEnclosingCircle_Point(pointsArray, pointsArray.Length, out center, out radius));
- }
-
- ///
- /// Finds the minimum area circle enclosing a 2D point set.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
- /// The output center of the circle
- /// The output radius of the circle
- public static void MinEnclosingCircle(IEnumerable points, out Point2f center, out float radius)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
- NativeMethods.HandleException(
- NativeMethods.imgproc_minEnclosingCircle_Point2f(pointsArray, pointsArray.Length, out center, out radius));
- }
-
- ///
- /// Finds a triangle of minimum area enclosing a 2D point set and returns its area.
- ///
- /// Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector or Mat
- /// Output vector of three 2D points defining the vertices of the triangle. The depth
- /// Triangle area
- public static double MinEnclosingTriangle(InputArray points, OutputArray triangle)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_minEnclosingTriangle_InputOutputArray(points.Proxy, triangle.Proxy, out var ret));
-
- GC.KeepAlive(points.Source);
- return ret;
- }
-
- ///
- /// Finds a triangle of minimum area enclosing a 2D point set and returns its area.
- ///
- /// Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector or Mat
- /// Output vector of three 2D points defining the vertices of the triangle. The depth
- /// Triangle area
- public static double MinEnclosingTriangle(IEnumerable points, out Point2f[] triangle)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
-
- var pointsArray = points.ToArray();
- using var triangleVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_minEnclosingTriangle_Point(
- pointsArray, pointsArray.Length, triangleVec.CvPtr, out var ret));
-
- GC.KeepAlive(pointsArray);
- triangle = triangleVec.ToArray();
- return ret;
- }
-
- ///
- /// Finds a triangle of minimum area enclosing a 2D point set and returns its area.
- ///
- /// Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector or Mat
- /// Output vector of three 2D points defining the vertices of the triangle. The depth
- /// Triangle area
- public static double MinEnclosingTriangle(IEnumerable points, out Point2f[] triangle)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
-
- var pointsArray = points.ToArray();
- using var triangleVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_minEnclosingTriangle_Point2f(
- pointsArray, pointsArray.Length, triangleVec.CvPtr, out var ret));
-
- GC.KeepAlive(pointsArray);
- triangle = triangleVec.ToArray();
- return ret;
- }
-
- ///
- /// Compares two shapes.
- ///
- /// First contour or grayscale image.
- /// Second contour or grayscale image.
- /// Comparison method
- /// Method-specific parameter (not supported now)
- ///
- public static double MatchShapes(InputArray contour1, InputArray contour2, ShapeMatchModes method, double parameter = 0)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_matchShapes_InputArray(contour1.Proxy, contour2.Proxy, (int)method, parameter, out var ret));
-
- GC.KeepAlive(contour1.Source);
- GC.KeepAlive(contour2.Source);
- return ret;
- }
-
- ///
- /// Compares two shapes.
- ///
- /// First contour or grayscale image.
- /// Second contour or grayscale image.
- /// Comparison method
- /// Method-specific parameter (not supported now)
- ///
- public static double MatchShapes(IEnumerable contour1, IEnumerable contour2,
- ShapeMatchModes method, double parameter = 0)
- {
- if (contour1 is null)
- throw new ArgumentNullException(nameof(contour1));
- if (contour2 is null)
- throw new ArgumentNullException(nameof(contour2));
- var contour1Array = contour1.ToArray();
- var contour2Array = contour2.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_matchShapes_Point(
- contour1Array, contour1Array.Length,
- contour2Array, contour2Array.Length,
- (int) method, parameter, out var ret));
- return ret;
- }
-
- ///
- /// Computes convex hull for a set of 2D points.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
- /// The output convex hull. It is either a vector of points that form the
- /// hull (must have the same type as the input points), or a vector of 0-based point
- /// indices of the hull points in the original array (since the set of convex hull
- /// points is a subset of the original point set).
- /// If true, the output convex hull will be oriented clockwise,
- /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
- /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
- /// and y axis is oriented downwards.
- ///
- public static void ConvexHull(InputArray points, OutputArray hull, bool clockwise = false, bool returnPoints = true)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexHull_InputArray(points.Proxy, hull.Proxy, clockwise ? 1 : 0, returnPoints ? 1 : 0));
-
- GC.KeepAlive(points.Source);
- GC.KeepAlive(hull.Source);
- }
-
- ///
- /// Computes convex hull for a set of 2D points.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
- /// If true, the output convex hull will be oriented clockwise,
- /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
- /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
- /// and y axis is oriented downwards.
- /// The output convex hull. It is a vector of points that form
- /// the hull (must have the same type as the input points).
- public static Point[] ConvexHull(IEnumerable points, bool clockwise = false)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- using var hullVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexHull_Point_ReturnsPoints(
- pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
-
- return hullVec.ToArray();
- }
-
- ///
- /// Computes convex hull for a set of 2D points.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
- /// If true, the output convex hull will be oriented clockwise,
- /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
- /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
- /// and y axis is oriented downwards.
- /// The output convex hull. It is a vector of points that form
- /// the hull (must have the same type as the input points).
- public static Point2f[] ConvexHull(IEnumerable points, bool clockwise = false)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- using var hullVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexHull_Point2f_ReturnsPoints(
- pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
- return hullVec.ToArray();
- }
-
- ///
- /// Computes convex hull for a set of 2D points.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
- /// If true, the output convex hull will be oriented clockwise,
- /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
- /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
- /// and y axis is oriented downwards.
- /// The output convex hull. It is a vector of 0-based point indices of the
- /// hull points in the original array (since the set of convex hull points is a subset of the original point set).
- public static int[] ConvexHullIndices(IEnumerable points, bool clockwise = false)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- using var hullVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexHull_Point_ReturnsIndices(
- pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
- return hullVec.ToArray();
- }
-
- ///
- /// Computes convex hull for a set of 2D points.
- ///
- /// The input 2D point set, represented by CV_32SC2 or CV_32FC2 matrix
- /// If true, the output convex hull will be oriented clockwise,
- /// otherwise it will be oriented counter-clockwise. Here, the usual screen coordinate
- /// system is assumed - the origin is at the top-left corner, x axis is oriented to the right,
- /// and y axis is oriented downwards.
- /// The output convex hull. It is a vector of 0-based point indices of the
- /// hull points in the original array (since the set of convex hull points is a subset of the original point set).
- public static int[] ConvexHullIndices(IEnumerable points, bool clockwise = false)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- using var hullVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexHull_Point2f_ReturnsIndices(
- pointsArray, pointsArray.Length, hullVec.CvPtr, clockwise ? 1 : 0));
- return hullVec.ToArray();
- }
-
- ///
- /// Computes the contour convexity defects
- ///
- /// Input contour.
- /// Convex hull obtained using convexHull() that
- /// should contain indices of the contour points that make the hull.
- ///
- /// The output vector of convexity defects.
- /// Each convexity defect is represented as 4-element integer vector
- /// (a.k.a. cv::Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth),
- /// where indices are 0-based indices in the original contour of the convexity defect beginning,
- /// end and the farthest point, and fixpt_depth is fixed-point approximation
- /// (with 8 fractional bits) of the distance between the farthest contour point and the hull.
- /// That is, to get the floating-point value of the depth will be fixpt_depth/256.0.
- ///
- public static void ConvexityDefects(InputArray contour, InputArray convexHull, OutputArray convexityDefects)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexityDefects_InputArray(contour.Proxy, convexHull.Proxy, convexityDefects.Proxy));
-
- GC.KeepAlive(contour.Source);
- GC.KeepAlive(convexHull.Source);
- GC.KeepAlive(convexityDefects.Source);
- }
-
- ///
- /// Computes the contour convexity defects
- ///
- /// Input contour.
- /// Convex hull obtained using convexHull() that
- /// should contain indices of the contour points that make the hull.
- /// The output vector of convexity defects.
- /// Each convexity defect is represented as 4-element integer vector
- /// (a.k.a. cv::Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth),
- /// where indices are 0-based indices in the original contour of the convexity defect beginning,
- /// end and the farthest point, and fixpt_depth is fixed-point approximation
- /// (with 8 fractional bits) of the distance between the farthest contour point and the hull.
- /// That is, to get the floating-point value of the depth will be fixpt_depth/256.0.
- public static Vec4i[] ConvexityDefects(IEnumerable contour, IEnumerable convexHull)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- if (convexHull is null)
- throw new ArgumentNullException(nameof(convexHull));
-
- var contourArray = contour.ToArray();
- var convexHullArray = convexHull.ToArray();
- using var convexityDefectsVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexityDefects_Point(
- contourArray, contourArray.Length,
- convexHullArray, convexHullArray.Length, convexityDefectsVec.CvPtr));
-
- return convexityDefectsVec.ToArray();
- }
-
- ///
- /// Computes the contour convexity defects
- ///
- /// Input contour.
- /// Convex hull obtained using convexHull() that
- /// should contain indices of the contour points that make the hull.
- /// The output vector of convexity defects.
- /// Each convexity defect is represented as 4-element integer vector
- /// (a.k.a. cv::Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth),
- /// where indices are 0-based indices in the original contour of the convexity defect beginning,
- /// end and the farthest point, and fixpt_depth is fixed-point approximation
- /// (with 8 fractional bits) of the distance between the farthest contour point and the hull.
- /// That is, to get the floating-point value of the depth will be fixpt_depth/256.0.
- public static Vec4i[] ConvexityDefects(IEnumerable contour, IEnumerable convexHull)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- if (convexHull is null)
- throw new ArgumentNullException(nameof(convexHull));
-
- var contourArray = contour.ToArray();
- var convexHullArray = convexHull.ToArray();
- using var convexityDefectsVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_convexityDefects_Point2f(
- contourArray, contourArray.Length,
- convexHullArray, convexHullArray.Length, convexityDefectsVec.CvPtr));
- return convexityDefectsVec.ToArray();
- }
-
- ///
- /// returns true if the contour is convex.
- /// Does not support contours with self-intersection
- ///
- /// Input vector of 2D points
- ///
- public static bool IsContourConvex(InputArray contour)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_isContourConvex_InputArray(contour.Proxy, out var ret));
-
- GC.KeepAlive(contour.Source);
- return ret != 0;
- }
-
- ///
- /// returns true if the contour is convex.
- /// Does not support contours with self-intersection
- ///
- /// Input vector of 2D points
- ///
- public static bool IsContourConvex(IEnumerable contour)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- var contourArray = contour.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_isContourConvex_Point(contourArray, contourArray.Length, out var ret));
- return ret != 0;
- }
-
- ///
- /// returns true if the contour is convex. D
- /// oes not support contours with self-intersection
- ///
- /// Input vector of 2D points
- ///
- public static bool IsContourConvex(IEnumerable contour)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- var contourArray = contour.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_isContourConvex_Point2f(contourArray, contourArray.Length, out var ret));
- return ret != 0;
- }
-
- ///
- /// finds intersection of two convex polygons
- ///
- ///
- ///
- ///
- ///
- ///
- public static float IntersectConvexConvex(InputArray p1, InputArray p2, OutputArray p12, bool handleNested = true)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_intersectConvexConvex_InputArray(
- p1.Proxy, p2.Proxy, p12.Proxy, handleNested ? 1 : 0, out var ret));
-
- GC.KeepAlive(p1.Source);
- GC.KeepAlive(p2.Source);
- GC.KeepAlive(p12.Source);
- return ret;
- }
-
- ///
- /// finds intersection of two convex polygons
- ///
- ///
- ///
- ///
- ///
- ///
- public static float IntersectConvexConvex(IEnumerable p1, IEnumerable p2,
- out Point[] p12, bool handleNested = true)
- {
- if (p1 is null)
- throw new ArgumentNullException(nameof(p1));
- if (p2 is null)
- throw new ArgumentNullException(nameof(p2));
- var p1Array = p1.ToArray();
- var p2Array = p2.ToArray();
-
- using var p12Vec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_intersectConvexConvex_Point(
- p1Array, p1Array.Length, p2Array, p2Array.Length, p12Vec.CvPtr, handleNested ? 1 : 0, out var ret));
-
- p12 = p12Vec.ToArray();
-
- return ret;
- }
-
- ///
- /// finds intersection of two convex polygons
- ///
- ///
- ///
- ///
- ///
- ///
- public static float IntersectConvexConvex(IEnumerable p1, IEnumerable p2,
- out Point2f[] p12, bool handleNested = true)
- {
- if (p1 is null)
- throw new ArgumentNullException(nameof(p1));
- if (p2 is null)
- throw new ArgumentNullException(nameof(p2));
- var p1Array = p1.ToArray();
- var p2Array = p2.ToArray();
-
- using var p12Vec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_intersectConvexConvex_Point2f(
- p1Array, p1Array.Length, p2Array, p2Array.Length,
- p12Vec.CvPtr, handleNested ? 1 : 0, out var ret));
-
- p12 = p12Vec.ToArray();
-
- return ret;
- }
-
- ///
- /// Fits ellipse to the set of 2D points.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipse(InputArray points)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipse_InputArray(points.Proxy, out var ret));
-
- GC.KeepAlive(points.Source);
- return ret;
- }
-
- ///
- /// Fits ellipse to the set of 2D points.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipse(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipse_Point(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Fits ellipse to the set of 2D points.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipse(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipse_Point2f(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Fits an ellipse around a set of 2D points.
- ///
- /// The function calculates the ellipse that fits a set of 2D points.
- /// It returns the rotated rectangle in which the ellipse is inscribed.
- /// The Approximate Mean Square(AMS) proposed by @cite Taubin1991 is used.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipseAMS(InputArray points)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipseAMS_InputArray(points.Proxy, out var ret));
-
- GC.KeepAlive(points.Source);
- return ret;
- }
-
- ///
- /// Fits an ellipse around a set of 2D points.
- ///
- /// The function calculates the ellipse that fits a set of 2D points.
- /// It returns the rotated rectangle in which the ellipse is inscribed.
- /// The Approximate Mean Square(AMS) proposed by @cite Taubin1991 is used.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipseAMS(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipseAMS_Point(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Fits an ellipse around a set of 2D points.
- ///
- /// The function calculates the ellipse that fits a set of 2D points.
- /// It returns the rotated rectangle in which the ellipse is inscribed.
- /// The Approximate Mean Square(AMS) proposed by @cite Taubin1991 is used.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipseAMS(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipseAMS_Point2f(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Fits an ellipse around a set of 2D points.
- ///
- /// The function calculates the ellipse that fits a set of 2D points.
- /// It returns the rotated rectangle in which the ellipse is inscribed.
- /// The Direct least square(Direct) method by @cite Fitzgibbon1999 is used.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipseDirect(InputArray points)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipseDirect_InputArray(points.Proxy, out var ret));
-
- GC.KeepAlive(points.Source);
- return ret;
- }
-
- ///
- /// Fits an ellipse around a set of 2D points.
- ///
- /// The function calculates the ellipse that fits a set of 2D points.
- /// It returns the rotated rectangle in which the ellipse is inscribed.
- /// The Direct least square(Direct) method by @cite Fitzgibbon1999 is used.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipseDirect(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipseDirect_Point(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Fits an ellipse around a set of 2D points.
- ///
- /// The function calculates the ellipse that fits a set of 2D points.
- /// It returns the rotated rectangle in which the ellipse is inscribed.
- /// The Direct least square(Direct) method by @cite Fitzgibbon1999 is used.
- ///
- /// Input 2D point set
- ///
- public static RotatedRect FitEllipseDirect(IEnumerable points)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
-
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitEllipseDirect_Point2f(pointsArray, pointsArray.Length, out var ret));
- return ret;
- }
-
- ///
- /// Fits line to the set of 2D points using M-estimator algorithm
- ///
- /// Input vector of 2D or 3D points
- /// Output line parameters.
- /// In case of 2D fitting, it should be a vector of 4 elements
- /// (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector
- /// collinear to the line and (x0, y0) is a point on the line.
- /// In case of 3D fitting, it should be a vector of 6 elements
- /// (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a
- /// normalized vector collinear to the line and (x0, y0, z0) is a point on the line.
- /// Distance used by the M-estimator
- /// Numerical parameter ( C ) for some types of distances.
- /// If it is 0, an optimal value is chosen.
- /// Sufficient accuracy for the radius
- /// (distance between the coordinate origin and the line).
- /// Sufficient accuracy for the angle.
- /// 0.01 would be a good default value for reps and aeps.
- public static void FitLine(InputArray points, OutputArray line, DistanceTypes distType,
- double param, double reps, double aeps)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitLine_InputArray(
- points.Proxy, line.Proxy, (int) distType, param, reps, aeps));
-
- GC.KeepAlive(points.Source);
- GC.KeepAlive(line.Source);
- }
-
- ///
- /// Fits line to the set of 2D points using M-estimator algorithm
- ///
- /// Input vector of 2D or 3D points
- /// Distance used by the M-estimator
- /// Numerical parameter ( C ) for some types of distances.
- /// If it is 0, an optimal value is chosen.
- /// Sufficient accuracy for the radius
- /// (distance between the coordinate origin and the line).
- /// Sufficient accuracy for the angle.
- /// 0.01 would be a good default value for reps and aeps.
- /// Output line parameters.
- public static Line2D FitLine(IEnumerable points, DistanceTypes distType,
- double param, double reps, double aeps)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
- var line = new float[4];
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitLine_Point(
- pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
- return new Line2D(line);
- }
-
- ///
- /// Fits line to the set of 2D points using M-estimator algorithm
- ///
- /// Input vector of 2D or 3D points
- /// Distance used by the M-estimator
- /// Numerical parameter ( C ) for some types of distances.
- /// If it is 0, an optimal value is chosen.
- /// Sufficient accuracy for the radius
- /// (distance between the coordinate origin and the line).
- /// Sufficient accuracy for the angle.
- /// 0.01 would be a good default value for reps and aeps.
- /// Output line parameters.
- public static Line2D FitLine(IEnumerable points, DistanceTypes distType,
- double param, double reps, double aeps)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
- var line = new float[4];
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitLine_Point2f(
- pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
- return new Line2D(line);
- }
-
- ///
- /// Fits line to the set of 3D points using M-estimator algorithm
- ///
- /// Input vector of 2D or 3D points
- /// Distance used by the M-estimator
- /// Numerical parameter ( C ) for some types of distances.
- /// If it is 0, an optimal value is chosen.
- /// Sufficient accuracy for the radius
- /// (distance between the coordinate origin and the line).
- /// Sufficient accuracy for the angle.
- /// 0.01 would be a good default value for reps and aeps.
- /// Output line parameters.
- public static Line3D FitLine(IEnumerable points, DistanceTypes distType,
- double param, double reps, double aeps)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
- var line = new float[6];
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitLine_Point3i(
- pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
- return new Line3D(line);
- }
-
- ///
- /// Fits line to the set of 3D points using M-estimator algorithm
- ///
- /// Input vector of 2D or 3D points
- /// Distance used by the M-estimator
- /// Numerical parameter ( C ) for some types of distances.
- /// If it is 0, an optimal value is chosen.
- /// Sufficient accuracy for the radius
- /// (distance between the coordinate origin and the line).
- /// Sufficient accuracy for the angle.
- /// 0.01 would be a good default value for reps and aeps.
- /// Output line parameters.
- public static Line3D FitLine(IEnumerable points, DistanceTypes distType,
- double param, double reps, double aeps)
- {
- if (points is null)
- throw new ArgumentNullException(nameof(points));
- var pointsArray = points.ToArray();
- var line = new float[6];
- NativeMethods.HandleException(
- NativeMethods.imgproc_fitLine_Point3f(
- pointsArray, pointsArray.Length, line, (int) distType, param, reps, aeps));
- return new Line3D(line);
- }
-
- ///
- /// Checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
- ///
- ///
- ///
- ///
- ///
- public static double PointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_pointPolygonTest_InputArray(
- contour.Proxy, pt, measureDist ? 1 : 0, out var ret));
- GC.KeepAlive(contour.Source);
- return ret;
- }
-
- ///
- /// Checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
- ///
- ///
- ///
- ///
- ///
- public static double PointPolygonTest(IEnumerable contour, Point2f pt, bool measureDist)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- var contourArray = contour.ToArray();
- NativeMethods.HandleException(
- NativeMethods.imgproc_pointPolygonTest_Point(
- contourArray, contourArray.Length, pt, measureDist ? 1 : 0, out var ret));
- return ret;
- }
-
- ///
- /// Checks if the point is inside the contour.
- /// Optionally computes the signed distance from the point to the contour boundary.
- ///
- /// Input contour.
- /// Point tested against the contour.
- /// If true, the function estimates the signed distance
- /// from the point to the nearest contour edge. Otherwise, the function only checks
- /// if the point is inside a contour or not.
- /// Positive (inside), negative (outside), or zero (on an edge) value.
- public static double PointPolygonTest(IEnumerable contour, Point2f pt, bool measureDist)
- {
- if (contour is null)
- throw new ArgumentNullException(nameof(contour));
- var contourArray = contour.ToArray();
- NativeMethods.HandleException(
- NativeMethods.imgproc_pointPolygonTest_Point2f(
- contourArray, contourArray.Length, pt, measureDist ? 1 : 0, out var ret));
- return ret;
- }
-
- ///
- /// Finds out if there is any intersection between two rotated rectangles.
- /// If there is then the vertices of the interesecting region are returned as well.
- /// Below are some examples of intersection configurations.
- /// The hatched pattern indicates the intersecting region and the red
- /// vertices are returned by the function.
- ///
- /// First rectangle
- /// Second rectangle
- ///
- /// The output array of the verticies of the intersecting region.
- /// It returns at most 8 vertices.
- /// Stored as std::vector<cv::Point2f> or cv::Mat as Mx1 of type CV_32FC2.
- ///
- public static RectanglesIntersectTypes RotatedRectangleIntersection(
- RotatedRect rect1, RotatedRect rect2, OutputArray intersectingRegion)
- {
- NativeMethods.HandleException(
- NativeMethods.imgproc_rotatedRectangleIntersection_OutputArray(
- rect1, rect2, intersectingRegion.Proxy, out var ret));
-
- GC.KeepAlive(intersectingRegion.Source);
-
- return (RectanglesIntersectTypes)ret;
- }
-
- ///
- /// Finds out if there is any intersection between two rotated rectangles.
- /// If there is then the vertices of the interesecting region are returned as well.
- /// Below are some examples of intersection configurations.
- /// The hatched pattern indicates the intersecting region and the red
- /// vertices are returned by the function.
- ///
- /// First rectangle
- /// Second rectangle
- ///
- /// The output array of the verticies of the intersecting region.
- /// It returns at most 8 vertices.
- ///
- public static RectanglesIntersectTypes RotatedRectangleIntersection(
- RotatedRect rect1, RotatedRect rect2, out Point2f[] intersectingRegion)
- {
- using var intersectingRegionVec = new StdVector();
- NativeMethods.HandleException(
- NativeMethods.imgproc_rotatedRectangleIntersection_vector(
- rect1, rect2, intersectingRegionVec.CvPtr, out var ret));
-
- intersectingRegion = intersectingRegionVec.ToArray();
- return (RectanglesIntersectTypes) ret;
- }
-
///
/// Applies a GNU Octave/MATLAB equivalent colormap on a given image.
///
diff --git a/src/OpenCvSharp/Internal/PInvoke/NativeMethods/geometry/NativeMethods_geometry.cs b/src/OpenCvSharp/Internal/PInvoke/NativeMethods/geometry/NativeMethods_geometry.cs
index fa614d9d9..7e4610110 100644
--- a/src/OpenCvSharp/Internal/PInvoke/NativeMethods/geometry/NativeMethods_geometry.cs
+++ b/src/OpenCvSharp/Internal/PInvoke/NativeMethods/geometry/NativeMethods_geometry.cs
@@ -338,4 +338,282 @@ internal static partial ExceptionStatus geometry_estimateTranslation2D(
in InputArrayProxy from, in InputArrayProxy to, in OutputArrayProxy inliers,
int method, double ransacReprojThreshold, ulong maxIters, double confidence, ulong refineIters,
out Vec2d returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_approxPolyN(
+ in InputArrayProxy curve, in OutputArrayProxy approxCurve, int nsides, float epsilonPercentage, int ensureConvex);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_minEnclosingConvexPolygon(
+ in InputArrayProxy points, in OutputArrayProxy polygon, int k, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_getClosestEllipsePoints(
+ RotatedRect ellipseParams, in InputArrayProxy points, in OutputArrayProxy closestPts);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_buildMST(
+ int numNodes,
+ [MarshalAs(UnmanagedType.LPArray), In] MSTEdge[] inputEdges, int inputEdgesLength,
+ int algorithm, int root,
+ [MarshalAs(UnmanagedType.LPArray), Out] MSTEdge[] resultingEdges, out int resultingEdgesCount,
+ out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_voxelGridSampling(
+ in OutputArrayProxy sampledPointFlags, in InputArrayProxy inputPts,
+ float length, float width, float height, out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_randomSampling_Size(
+ in OutputArrayProxy sampledPts, in InputArrayProxy inputPts, int sampledPtsSize);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_randomSampling_Scale(
+ in OutputArrayProxy sampledPts, in InputArrayProxy inputPts, float sampledScale);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_farthestPointSampling_Size(
+ in OutputArrayProxy sampledPointFlags, in InputArrayProxy inputPts,
+ int sampledPtsSize, float distLowerLimit, out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_farthestPointSampling_Scale(
+ in OutputArrayProxy sampledPointFlags, in InputArrayProxy inputPts,
+ float sampledScale, float distLowerLimit, out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_normalEstimate(
+ in OutputArrayProxy normals, in OutputArrayProxy curvatures,
+ in InputArrayProxy inputPts, in InputArrayProxy nnIdx, int maxNeighborNum);
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_getRotationMatrix2D(Point2f center, double angle, double scale, out IntPtr returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_invertAffineTransform(in InputArrayProxy m, in OutputArrayProxy im);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_getPerspectiveTransform1(Point2f[] src, Point2f[] dst, out IntPtr returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_getPerspectiveTransform2(in InputArrayProxy src, in InputArrayProxy dst, out IntPtr returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_getAffineTransform1(Point2f[] src, Point2f[] dst, out IntPtr returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_getAffineTransform2(in InputArrayProxy src, in InputArrayProxy dst, out IntPtr returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_moments(in InputArrayProxy arr, int binaryImage, out Moments.NativeStruct returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_approxPolyDP_InputArray(in InputArrayProxy curve, in OutputArrayProxy approxCurve,
+ double epsilon, int closed);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_approxPolyDP_Point(Point[] curve, int curveLength,
+ IntPtr approxCurve, double epsilon, int closed);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_approxPolyDP_Point2f(Point2f[] curve, int curveLength,
+ IntPtr approxCurve, double epsilon, int closed);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_arcLength_InputArray(in InputArrayProxy curve, int closed, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_arcLength_Point(Point[] curve, int curveLength, int closed, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_arcLength_Point2f(Point2f[] curve, int curveLength, int closed, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_boundingRect_InputArray(in InputArrayProxy curve, out Rect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_boundingRect_Point(Point[] curve, int curveLength, out Rect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_boundingRect_Point2f(Point2f[] curve, int curveLength, out Rect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_contourArea_InputArray(in InputArrayProxy contour, int oriented, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_contourArea_Point(
+ [MarshalAs(UnmanagedType.LPArray)] Point[] contour, int contourLength, int oriented, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_contourArea_Point2f(
+ [MarshalAs(UnmanagedType.LPArray)] Point2f[] contour, int contourLength, int oriented, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_minAreaRect_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_minAreaRect_Point(
+ [MarshalAs(UnmanagedType.LPArray)] Point[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_minAreaRect_Point2f(
+ [MarshalAs(UnmanagedType.LPArray)] Point2f[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_boxPoints_OutputArray(RotatedRect box, in OutputArrayProxy points);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_boxPoints_Point2f(RotatedRect box, [MarshalAs(UnmanagedType.LPArray), Out] Point2f[] points);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_minEnclosingCircle_InputArray(in InputArrayProxy points, out Point2f center,
+ out float radius);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_minEnclosingCircle_Point(Point[] points, int pointsLength,
+ out Point2f center, out float radius);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_minEnclosingCircle_Point2f(Point2f[] points, int pointsLength,
+ out Point2f center, out float radius);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_minEnclosingTriangle_InputOutputArray(in InputArrayProxy points, in OutputArrayProxy triangle, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_minEnclosingTriangle_Point(
+ [MarshalAs(UnmanagedType.LPArray), In] Point[] points, int pointsLength, IntPtr triangle, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_minEnclosingTriangle_Point2f(
+ [MarshalAs(UnmanagedType.LPArray), In] Point2f[] points, int pointsLength, IntPtr triangle, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_matchShapes_InputArray(
+ in InputArrayProxy contour1, in InputArrayProxy contour2, int method, double parameter, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_matchShapes_Point(
+ Point[] contour1, int contour1Length, Point[] contour2, int contour2Length, int method, double parameter, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_convexHull_InputArray(in InputArrayProxy points, in OutputArrayProxy hull,
+ int clockwise, int returnPoints);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_convexHull_Point_ReturnsPoints(Point[] points, int pointsLength,
+ IntPtr hull, int clockwise);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_convexHull_Point2f_ReturnsPoints(Point2f[] points, int pointsLength,
+ IntPtr hull, int clockwise);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_convexHull_Point_ReturnsIndices(Point[] points, int pointsLength,
+ IntPtr hull, int clockwise);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_convexHull_Point2f_ReturnsIndices(Point2f[] points, int pointsLength,
+ IntPtr hull, int clockwise);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_convexityDefects_InputArray(in InputArrayProxy contour, in InputArrayProxy convexHull,
+ in OutputArrayProxy convexityDefects);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_convexityDefects_Point(Point[] contour, int contourLength, int[] convexHull,
+ int convexHullLength, IntPtr convexityDefects);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_convexityDefects_Point2f(Point2f[] contour, int contourLength,
+ int[] convexHull, int convexHullLength, IntPtr convexityDefects);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_isContourConvex_InputArray(in InputArrayProxy contour, out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_isContourConvex_Point(Point[] contour, int contourLength, out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_isContourConvex_Point2f(Point2f[] contour, int contourLength, out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_intersectConvexConvex_InputArray(in InputArrayProxy p1, in InputArrayProxy p2,
+ in OutputArrayProxy p12, int handleNested, out float returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_intersectConvexConvex_Point(Point[] p1, int p1Length, Point[] p2,
+ int p2Length, IntPtr p12, int handleNested, out float returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_intersectConvexConvex_Point2f(Point2f[] p1, int p1Length, Point2f[] p2,
+ int p2Length, IntPtr p12, int handleNested, out float returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_fitEllipse_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitEllipse_Point(Point[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitEllipse_Point2f(Point2f[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_fitEllipseAMS_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitEllipseAMS_Point(Point[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitEllipseAMS_Point2f(Point2f[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_fitEllipseDirect_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitEllipseDirect_Point(Point[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitEllipseDirect_Point2f(Point2f[] points, int pointsLength, out RotatedRect returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_fitLine_InputArray(in InputArrayProxy points, in OutputArrayProxy line,
+ int distType, double param, double reps, double aeps);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitLine_Point(Point[] points, int pointsLength, [In, Out] float[] line,
+ int distType,
+ double param, double reps, double aeps);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitLine_Point2f(Point2f[] points, int pointsLength, [In, Out] float[] line,
+ int distType, double param, double reps, double aeps);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitLine_Point3i(Point3i[] points, int pointsLength, [In, Out] float[] line,
+ int distType, double param, double reps, double aeps);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_fitLine_Point3f(Point3f[] points, int pointsLength, [In, Out] float[] line,
+ int distType, double param, double reps, double aeps);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_pointPolygonTest_InputArray(
+ in InputArrayProxy contour, Point2f pt, int measureDist, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_pointPolygonTest_Point(Point[] contour, int contourLength, Point2f pt,
+ int measureDist, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_pointPolygonTest_Point2f(Point2f[] contour, int contourLength,
+ Point2f pt, int measureDist, out double returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ internal static partial ExceptionStatus geometry_rotatedRectangleIntersection_OutputArray(
+ RotatedRect rect1, RotatedRect rect2, in OutputArrayProxy intersectingRegion, out int returnValue);
+
+ [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
+ public static partial ExceptionStatus geometry_rotatedRectangleIntersection_vector(
+ RotatedRect rect1, RotatedRect rect2, IntPtr intersectingRegion, out int returnValue);
}
diff --git a/src/OpenCvSharp/Internal/PInvoke/NativeMethods/imgproc/NativeMethods_imgproc.cs b/src/OpenCvSharp/Internal/PInvoke/NativeMethods/imgproc/NativeMethods_imgproc.cs
index 75e111122..e8dcd2414 100644
--- a/src/OpenCvSharp/Internal/PInvoke/NativeMethods/imgproc/NativeMethods_imgproc.cs
+++ b/src/OpenCvSharp/Internal/PInvoke/NativeMethods/imgproc/NativeMethods_imgproc.cs
@@ -166,24 +166,6 @@ internal static partial ExceptionStatus imgproc_remap(in InputArrayProxy src, in
internal static partial ExceptionStatus imgproc_convertMaps(in InputArrayProxy map1, in InputArrayProxy map2, in OutputArrayProxy dstmap1, in OutputArrayProxy dstmap2,
MatType dstmap1Type, int nninterpolation);
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_getRotationMatrix2D(Point2f center, double angle, double scale, out IntPtr returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_invertAffineTransform(in InputArrayProxy m, in OutputArrayProxy im);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_getPerspectiveTransform1(Point2f[] src, Point2f[] dst, out IntPtr returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_getPerspectiveTransform2(in InputArrayProxy src, in InputArrayProxy dst, out IntPtr returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_getAffineTransform1(Point2f[] src, Point2f[] dst, out IntPtr returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_getAffineTransform2(in InputArrayProxy src, in InputArrayProxy dst, out IntPtr returnValue);
-
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus imgproc_getRectSubPix(in InputArrayProxy image, Size patchSize, Point2f center, in OutputArrayProxy patch,
int patchType);
@@ -298,9 +280,6 @@ internal static partial ExceptionStatus imgproc_blendLinear(
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus imgproc_demosaicing(in InputArrayProxy src, in OutputArrayProxy dst, int code, int dstCn);
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_moments(in InputArrayProxy arr, int binaryImage, out Moments.NativeStruct returnValue);
-
//[DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
//public static extern ExceptionStatus imgproc_HuMoments(ref Moments.NativeStruct moments, [MarshalAs(UnmanagedType.LPArray)] double[] hu);
@@ -346,217 +325,9 @@ internal static partial ExceptionStatus imgproc_findContours2_OutputArray(in Inp
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus imgproc_findContoursLinkRuns2(in InputArrayProxy image, IntPtr contours);
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_approxPolyDP_InputArray(in InputArrayProxy curve, in OutputArrayProxy approxCurve,
- double epsilon, int closed);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_approxPolyDP_Point(Point[] curve, int curveLength,
- IntPtr approxCurve, double epsilon, int closed);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_approxPolyDP_Point2f(Point2f[] curve, int curveLength,
- IntPtr approxCurve, double epsilon, int closed);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_arcLength_InputArray(in InputArrayProxy curve, int closed, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_arcLength_Point(Point[] curve, int curveLength, int closed, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_arcLength_Point2f(Point2f[] curve, int curveLength, int closed, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_boundingRect_InputArray(in InputArrayProxy curve, out Rect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_boundingRect_Point(Point[] curve, int curveLength, out Rect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_boundingRect_Point2f(Point2f[] curve, int curveLength, out Rect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_contourArea_InputArray(in InputArrayProxy contour, int oriented, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_contourArea_Point(
- [MarshalAs(UnmanagedType.LPArray)] Point[] contour, int contourLength, int oriented, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_contourArea_Point2f(
- [MarshalAs(UnmanagedType.LPArray)] Point2f[] contour, int contourLength, int oriented, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_minAreaRect_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_minAreaRect_Point(
- [MarshalAs(UnmanagedType.LPArray)] Point[] points, int pointsLength, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_minAreaRect_Point2f(
- [MarshalAs(UnmanagedType.LPArray)] Point2f[] points, int pointsLength, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_boxPoints_OutputArray(RotatedRect box, in OutputArrayProxy points);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_boxPoints_Point2f(RotatedRect box, [MarshalAs(UnmanagedType.LPArray), Out] Point2f[] points);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_minEnclosingCircle_InputArray(in InputArrayProxy points, out Point2f center,
- out float radius);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_minEnclosingCircle_Point(Point[] points, int pointsLength,
- out Point2f center, out float radius);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_minEnclosingCircle_Point2f(Point2f[] points, int pointsLength,
- out Point2f center, out float radius);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_minEnclosingTriangle_InputOutputArray(in InputArrayProxy points, in OutputArrayProxy triangle, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_minEnclosingTriangle_Point(
- [MarshalAs(UnmanagedType.LPArray), In] Point[] points, int pointsLength, IntPtr triangle, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_minEnclosingTriangle_Point2f(
- [MarshalAs(UnmanagedType.LPArray), In] Point2f[] points, int pointsLength, IntPtr triangle, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_matchShapes_InputArray(
- in InputArrayProxy contour1, in InputArrayProxy contour2, int method, double parameter, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_matchShapes_Point(
- Point[] contour1, int contour1Length, Point[] contour2, int contour2Length, int method, double parameter, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_convexHull_InputArray(in InputArrayProxy points, in OutputArrayProxy hull,
- int clockwise, int returnPoints);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_convexHull_Point_ReturnsPoints(Point[] points, int pointsLength,
- IntPtr hull, int clockwise);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_convexHull_Point2f_ReturnsPoints(Point2f[] points, int pointsLength,
- IntPtr hull, int clockwise);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_convexHull_Point_ReturnsIndices(Point[] points, int pointsLength,
- IntPtr hull, int clockwise);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_convexHull_Point2f_ReturnsIndices(Point2f[] points, int pointsLength,
- IntPtr hull, int clockwise);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_convexityDefects_InputArray(in InputArrayProxy contour, in InputArrayProxy convexHull,
- in OutputArrayProxy convexityDefects);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_convexityDefects_Point(Point[] contour, int contourLength, int[] convexHull,
- int convexHullLength, IntPtr convexityDefects);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_convexityDefects_Point2f(Point2f[] contour, int contourLength,
- int[] convexHull, int convexHullLength, IntPtr convexityDefects);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_isContourConvex_InputArray(in InputArrayProxy contour, out int returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_isContourConvex_Point(Point[] contour, int contourLength, out int returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_isContourConvex_Point2f(Point2f[] contour, int contourLength, out int returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_intersectConvexConvex_InputArray(in InputArrayProxy p1, in InputArrayProxy p2,
- in OutputArrayProxy p12, int handleNested, out float returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_intersectConvexConvex_Point(Point[] p1, int p1Length, Point[] p2,
- int p2Length, IntPtr p12, int handleNested, out float returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_intersectConvexConvex_Point2f(Point2f[] p1, int p1Length, Point2f[] p2,
- int p2Length, IntPtr p12, int handleNested, out float returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_fitEllipse_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitEllipse_Point(Point[] points, int pointsLength, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitEllipse_Point2f(Point2f[] points, int pointsLength, out RotatedRect returnValue);
-
// Not exported
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_fitEllipseAMS_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitEllipseAMS_Point(Point[] points, int pointsLength, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitEllipseAMS_Point2f(Point2f[] points, int pointsLength, out RotatedRect returnValue);
// Not exported
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_fitEllipseDirect_InputArray(in InputArrayProxy points, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitEllipseDirect_Point(Point[] points, int pointsLength, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitEllipseDirect_Point2f(Point2f[] points, int pointsLength, out RotatedRect returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_fitLine_InputArray(in InputArrayProxy points, in OutputArrayProxy line,
- int distType, double param, double reps, double aeps);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitLine_Point(Point[] points, int pointsLength, [In, Out] float[] line,
- int distType,
- double param, double reps, double aeps);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitLine_Point2f(Point2f[] points, int pointsLength, [In, Out] float[] line,
- int distType, double param, double reps, double aeps);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitLine_Point3i(Point3i[] points, int pointsLength, [In, Out] float[] line,
- int distType, double param, double reps, double aeps);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_fitLine_Point3f(Point3f[] points, int pointsLength, [In, Out] float[] line,
- int distType, double param, double reps, double aeps);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_pointPolygonTest_InputArray(
- in InputArrayProxy contour, Point2f pt, int measureDist, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_pointPolygonTest_Point(Point[] contour, int contourLength, Point2f pt,
- int measureDist, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_pointPolygonTest_Point2f(Point2f[] contour, int contourLength,
- Point2f pt, int measureDist, out double returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- internal static partial ExceptionStatus imgproc_rotatedRectangleIntersection_OutputArray(
- RotatedRect rect1, RotatedRect rect2, in OutputArrayProxy intersectingRegion, out int returnValue);
-
- [LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
- public static partial ExceptionStatus imgproc_rotatedRectangleIntersection_vector(
- RotatedRect rect1, RotatedRect rect2, IntPtr intersectingRegion, out int returnValue);
[LibraryImport(DllExtern), UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ExceptionStatus imgproc_applyColorMap1(in InputArrayProxy src, in OutputArrayProxy dst, int colormap);
diff --git a/src/OpenCvSharp/Modules/dnn/Cv2.Dnn.cs b/src/OpenCvSharp/Modules/dnn/Cv2.Dnn.cs
index 22162b051..db1bb3e5e 100644
--- a/src/OpenCvSharp/Modules/dnn/Cv2.Dnn.cs
+++ b/src/OpenCvSharp/Modules/dnn/Cv2.Dnn.cs
@@ -62,23 +62,20 @@ public static partial class Dnn
///
/// Read deep learning network represented in one of the supported formats.
- ///
- /// This function automatically detects an origin framework of trained model
- /// and calls an appropriate function such @ref readNetFromCaffe, @ref readNetFromTensorflow,
+ ///
+ /// This function automatically detects an origin framework of trained model
+ /// and calls an appropriate function such @ref readNetFromTensorflow, @ref readNetFromONNX,
+ /// or @ref readNetFromModelOptimizer. The Caffe, Darknet and Torch parsers were removed in OpenCV 5.
///
/// Binary file contains trained weights. The following file
/// * extensions are expected for models from different frameworks:
- /// * * `*.caffemodel` (Caffe, http://caffe.berkeleyvision.org/)
/// * * `*.pb` (TensorFlow, https://www.tensorflow.org/)
- /// * * `*.t7` | `*.net` (Torch, http://torch.ch/)
- /// * * `*.weights` (Darknet, https://pjreddie.com/darknet/)
- /// * * `*.bin` (DLDT, https://software.intel.com/openvino-toolkit)
+ /// * * `*.onnx` (ONNX, https://onnx.ai/)
+ /// * * `*.bin` (OpenVINO, https://software.intel.com/openvino-toolkit)
/// Text file contains network configuration. It could be a
/// * file with the following extensions:
- /// * * `*.prototxt` (Caffe, http://caffe.berkeleyvision.org/)
/// * * `*.pbtxt` (TensorFlow, https://www.tensorflow.org/)
- /// * * `*.cfg` (Darknet, https://pjreddie.com/darknet/)
- /// * * `*.xml` (DLDT, https://software.intel.com/openvino-toolkit)
+ /// * * `*.xml` (OpenVINO, https://software.intel.com/openvino-toolkit)
/// Explicit framework name tag to determine a format.
///
/// DNN engine to use. tries the new engine first and falls back to the classic one.
diff --git a/src/OpenCvSharp/Modules/dnn/Net.cs b/src/OpenCvSharp/Modules/dnn/Net.cs
index dd2905694..1a8e80c61 100644
--- a/src/OpenCvSharp/Modules/dnn/Net.cs
+++ b/src/OpenCvSharp/Modules/dnn/Net.cs
@@ -146,23 +146,20 @@ private void InitSafeHandle(IntPtr p, bool ownsHandle = true)
///
/// Read deep learning network represented in one of the supported formats.
- ///
- /// This function automatically detects an origin framework of trained model
- /// and calls an appropriate function such @ref readNetFromCaffe, @ref readNetFromTensorflow,
+ ///
+ /// This function automatically detects an origin framework of trained model
+ /// and calls an appropriate function such @ref readNetFromTensorflow, @ref readNetFromONNX,
+ /// or @ref readNetFromModelOptimizer. The Caffe, Darknet and Torch parsers were removed in OpenCV 5.
///
/// Binary file contains trained weights. The following file
/// * extensions are expected for models from different frameworks:
- /// * * `*.caffemodel` (Caffe, http://caffe.berkeleyvision.org/)
/// * * `*.pb` (TensorFlow, https://www.tensorflow.org/)
- /// * * `*.t7` | `*.net` (Torch, http://torch.ch/)
- /// * * `*.weights` (Darknet, https://pjreddie.com/darknet/)
- /// * * `*.bin` (DLDT, https://software.intel.com/openvino-toolkit)
+ /// * * `*.onnx` (ONNX, https://onnx.ai/)
+ /// * * `*.bin` (OpenVINO, https://software.intel.com/openvino-toolkit)
/// Text file contains network configuration. It could be a
/// * file with the following extensions:
- /// * * `*.prototxt` (Caffe, http://caffe.berkeleyvision.org/)
/// * * `*.pbtxt` (TensorFlow, https://www.tensorflow.org/)
- /// * * `*.cfg` (Darknet, https://pjreddie.com/darknet/)
- /// * * `*.xml` (DLDT, https://software.intel.com/openvino-toolkit)
+ /// * * `*.xml` (OpenVINO, https://software.intel.com/openvino-toolkit)
/// Explicit framework name tag to determine a format.
///
/// DNN engine to use. tries the new engine first and falls back to the classic one.
diff --git a/src/OpenCvSharp/Modules/geometry/Enum/MSTAlgorithm.cs b/src/OpenCvSharp/Modules/geometry/Enum/MSTAlgorithm.cs
new file mode 100644
index 000000000..6bf9269f2
--- /dev/null
+++ b/src/OpenCvSharp/Modules/geometry/Enum/MSTAlgorithm.cs
@@ -0,0 +1,18 @@
+namespace OpenCvSharp;
+
+// ReSharper disable InconsistentNaming
+///
+/// Algorithms available for building a Minimum Spanning Tree (MST). See .
+///
+public enum MSTAlgorithm
+{
+ ///
+ /// Prim's algorithm.
+ ///
+ Prim = 0,
+
+ ///
+ /// Kruskal's algorithm.
+ ///
+ Kruskal = 1
+}
diff --git a/src/OpenCvSharp/Modules/geometry/MSTEdge.cs b/src/OpenCvSharp/Modules/geometry/MSTEdge.cs
new file mode 100644
index 000000000..8dcfa74c7
--- /dev/null
+++ b/src/OpenCvSharp/Modules/geometry/MSTEdge.cs
@@ -0,0 +1,27 @@
+using System.Runtime.InteropServices;
+
+#pragma warning disable CA1051
+
+namespace OpenCvSharp;
+
+///
+/// Represents an edge in a graph for Minimum Spanning Tree (MST) computation. See .
+///
+[StructLayout(LayoutKind.Sequential)]
+public record struct MSTEdge(int Source, int Target, double Weight)
+{
+ ///
+ /// Source node index.
+ ///
+ public int Source = Source;
+
+ ///
+ /// Target node index.
+ ///
+ public int Target = Target;
+
+ ///
+ /// Edge weight.
+ ///
+ public double Weight = Weight;
+}
diff --git a/src/OpenCvSharp/Modules/imgproc/Moments.cs b/src/OpenCvSharp/Modules/imgproc/Moments.cs
index 4763d269d..22c6233ff 100644
--- a/src/OpenCvSharp/Modules/imgproc/Moments.cs
+++ b/src/OpenCvSharp/Modules/imgproc/Moments.cs
@@ -147,7 +147,7 @@ public Moments(IEnumerable array, bool binaryImage = false)
private void InitializeFromInputArray(InputArray array, bool binaryImage)
{
NativeMethods.HandleException(
- NativeMethods.imgproc_moments(array.Proxy, binaryImage ? 1 : 0, out var m));
+ NativeMethods.geometry_moments(array.Proxy, binaryImage ? 1 : 0, out var m));
GC.KeepAlive(array.Source);
Initialize(m.m00, m.m10, m.m01, m.m20, m.m11, m.m02, m.m30, m.m21, m.m12, m.m03);
}
diff --git a/src/OpenCvSharpExtern/geometry.h b/src/OpenCvSharpExtern/geometry.h
index 881d499e7..2d6550513 100644
--- a/src/OpenCvSharpExtern/geometry.h
+++ b/src/OpenCvSharpExtern/geometry.h
@@ -1028,4 +1028,892 @@ CVAPI(ExceptionStatus) geometry_estimateTranslation2D(
});
}
+CVAPI(ExceptionStatus) geometry_approxPolyN(
+ const interop::InputArrayProxy* curve,
+ const interop::OutputArrayProxy* approxCurve,
+ int nsides,
+ float epsilonPercentage,
+ int ensureConvex)
+{
+ return cvTry([&] {
+ cv::approxPolyN(InProxy(*curve), OutProxy(*approxCurve), nsides, epsilonPercentage, ensureConvex != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minEnclosingConvexPolygon(
+ const interop::InputArrayProxy* points,
+ const interop::OutputArrayProxy* polygon,
+ int k,
+ double *returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::minEnclosingConvexPolygon(InProxy(*points), OutProxy(*polygon), k);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_getClosestEllipsePoints(
+ interop::RotatedRect ellipseParams,
+ const interop::InputArrayProxy* points,
+ const interop::OutputArrayProxy* closestPts)
+{
+ return cvTry([&] {
+ cv::getClosestEllipsePoints(cpp(ellipseParams), InProxy(*points), OutProxy(*closestPts));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_buildMST(
+ int numNodes,
+ const interop::MSTEdge* inputEdges,
+ int inputEdgesLength,
+ int algorithm,
+ int root,
+ interop::MSTEdge* resultingEdges,
+ int* resultingEdgesCount,
+ int* returnValue)
+{
+ return cvTry([&] {
+ std::vector inVec(inputEdgesLength);
+ for (int i = 0; i < inputEdgesLength; i++)
+ inVec[i] = cpp(inputEdges[i]);
+
+ std::vector outVec;
+ const bool ok = cv::buildMST(numNodes, inVec, outVec, static_cast(algorithm), root);
+ *returnValue = ok ? 1 : 0;
+ *resultingEdgesCount = static_cast(outVec.size());
+ for (size_t i = 0; i < outVec.size(); i++)
+ resultingEdges[i] = c(outVec[i]);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_voxelGridSampling(
+ const interop::OutputArrayProxy* sampledPointFlags,
+ const interop::InputArrayProxy* inputPts,
+ float length,
+ float width,
+ float height,
+ int* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::voxelGridSampling(OutProxy(*sampledPointFlags), InProxy(*inputPts), length, width, height);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_randomSampling_Size(
+ const interop::OutputArrayProxy* sampledPts,
+ const interop::InputArrayProxy* inputPts,
+ int sampledPtsSize)
+{
+ return cvTry([&] {
+ cv::randomSampling(OutProxy(*sampledPts), InProxy(*inputPts), sampledPtsSize, nullptr);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_randomSampling_Scale(
+ const interop::OutputArrayProxy* sampledPts,
+ const interop::InputArrayProxy* inputPts,
+ float sampledScale)
+{
+ return cvTry([&] {
+ cv::randomSampling(OutProxy(*sampledPts), InProxy(*inputPts), sampledScale, nullptr);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_farthestPointSampling_Size(
+ const interop::OutputArrayProxy* sampledPointFlags,
+ const interop::InputArrayProxy* inputPts,
+ int sampledPtsSize,
+ float distLowerLimit,
+ int* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::farthestPointSampling(OutProxy(*sampledPointFlags), InProxy(*inputPts), sampledPtsSize, distLowerLimit, nullptr);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_farthestPointSampling_Scale(
+ const interop::OutputArrayProxy* sampledPointFlags,
+ const interop::InputArrayProxy* inputPts,
+ float sampledScale,
+ float distLowerLimit,
+ int* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::farthestPointSampling(OutProxy(*sampledPointFlags), InProxy(*inputPts), sampledScale, distLowerLimit, nullptr);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_normalEstimate(
+ const interop::OutputArrayProxy* normals,
+ const interop::OutputArrayProxy* curvatures,
+ const interop::InputArrayProxy* inputPts,
+ const interop::InputArrayProxy* nnIdx,
+ int maxNeighborNum)
+{
+ return cvTry([&] {
+ cv::normalEstimate(OutProxy(*normals), OutProxy(*curvatures), InProxy(*inputPts), InProxy(*nnIdx), maxNeighborNum);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_getRotationMatrix2D(
+ interop::Point2f center,
+ double angle,
+ double scale,
+ cv::Mat** returnValue)
+{
+ return cvTry([&] {
+ const auto ret = cv::getRotationMatrix2D(cpp(center), angle, scale);
+ *returnValue = new cv::Mat(ret);
+ });
+
+}
+
+CVAPI(ExceptionStatus) geometry_invertAffineTransform(const interop::InputArrayProxy* M, const interop::OutputArrayProxy* iM)
+{
+ return cvTry([&] {
+ cv::invertAffineTransform(InProxy(*M), OutProxy(*iM));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_getPerspectiveTransform1(
+ cv::Point2f *src,
+ cv::Point2f *dst,
+ cv::Mat** returnValue)
+{
+ return cvTry([&] {
+ const auto ret = cv::getPerspectiveTransform(src, dst);
+ *returnValue = new cv::Mat(ret);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_getPerspectiveTransform2(
+ const interop::InputArrayProxy* src,
+ const interop::InputArrayProxy* dst,
+ cv::Mat** returnValue)
+{
+ return cvTry([&] {
+ const auto ret = cv::getPerspectiveTransform(InProxy(*src), InProxy(*dst));
+ *returnValue = new cv::Mat(ret);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_getAffineTransform1(
+ cv::Point2f *src,
+ cv::Point2f *dst,
+ cv::Mat** returnValue)
+{
+ return cvTry([&] {
+ const auto ret = cv::getAffineTransform(src, dst);
+ *returnValue = new cv::Mat(ret);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_getAffineTransform2(
+ const interop::InputArrayProxy* src,
+ const interop::InputArrayProxy* dst,
+ cv::Mat** returnValue)
+{
+ return cvTry([&] {
+ const auto ret = cv::getAffineTransform(InProxy(*src), InProxy(*dst));
+ *returnValue = new cv::Mat(ret);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_moments(
+ const interop::InputArrayProxy* arr,
+ int binaryImage,
+ interop::Moments *returnValue)
+{
+ return cvTry([&] {
+ const auto m = cv::moments(InProxy(*arr), binaryImage != 0);
+ *returnValue = c(m);
+ });
+}
+/*
+
+CVAPI(ExceptionStatus) geometry_HuMoments(interop::Moments *moments, double hu[7])
+{
+ return cvTry([&] {
+ cv::HuMoments(cpp(*moments), hu);
+ });
+}
+*/
+
+CVAPI(ExceptionStatus) geometry_approxPolyDP_InputArray(
+ const interop::InputArrayProxy* curve,
+ const interop::OutputArrayProxy* approxCurve,
+ double epsilon,
+ int closed)
+{
+ return cvTry([&] {
+ cv::approxPolyDP(InProxy(*curve), OutProxy(*approxCurve), epsilon, closed != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_approxPolyDP_Point(
+ cv::Point *curve,
+ int curveLength,
+ std::vector *approxCurve,
+ double epsilon,
+ int closed)
+{
+ return cvTry([&] {
+ const cv::Mat_ curveMat(curveLength, 1, curve);
+ cv::approxPolyDP(curveMat, *approxCurve, epsilon, closed != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_approxPolyDP_Point2f(
+ cv::Point2f *curve,
+ int curveLength,
+ std::vector *approxCurve,
+ double epsilon,
+ int closed)
+{
+ return cvTry([&] {
+ const cv::Mat_ curveMat(curveLength, 1, curve);
+ cv::approxPolyDP(curveMat, *approxCurve, epsilon, closed != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_arcLength_InputArray(
+ const interop::InputArrayProxy* curve,
+ int closed,
+ double *returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::arcLength(InProxy(*curve), closed != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_arcLength_Point(
+ cv::Point *curve,
+ int curveLength,
+ int closed,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ curveMat(curveLength, 1, curve);
+ *returnValue = cv::arcLength(curveMat, closed != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_arcLength_Point2f(
+ cv::Point2f *curve,
+ int curveLength,
+ int closed,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ curveMat(curveLength, 1, curve);
+ *returnValue = cv::arcLength(curveMat, closed != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_boundingRect_InputArray(const interop::InputArrayProxy* curve, interop::Rect* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = c(cv::boundingRect(InProxy(*curve)));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_boundingRect_Point(
+ cv::Point *curve,
+ int curveLength,
+ interop::Rect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ curveMat(curveLength, 1, curve);
+ *returnValue = c(cv::boundingRect(curveMat));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_boundingRect_Point2f(
+ cv::Point2f *curve,
+ int curveLength,
+ interop::Rect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ curveMat(curveLength, 1, curve);
+ *returnValue = c(cv::boundingRect(curveMat));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_contourArea_InputArray(
+ const interop::InputArrayProxy* contour,
+ int oriented,
+ double* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::contourArea(InProxy(*contour), oriented != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_contourArea_Point(
+ cv::Point *contour,
+ int contourLength,
+ int oriented,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourMat(contourLength, 1, contour);
+ *returnValue = cv::contourArea(contourMat, oriented != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_contourArea_Point2f(
+ cv::Point2f *contour,
+ int contourLength,
+ int oriented,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourMat(contourLength, 1, contour);
+ *returnValue = cv::contourArea(contourMat, oriented != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minAreaRect_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = c(cv::minAreaRect(InProxy(*points)));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minAreaRect_Point(
+ cv::Point *points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ *returnValue = c(cv::minAreaRect(pointsMat));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minAreaRect_Point2f(
+ cv::Point2f *points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ *returnValue = c(cv::minAreaRect(pointsMat));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_boxPoints_OutputArray(interop::RotatedRect box, const interop::OutputArrayProxy* points)
+{
+ return cvTry([&] {
+ cv::boxPoints(cpp(box), OutProxy(*points));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_boxPoints_Point2f(interop::RotatedRect box, cv::Point2f points[4])
+{
+ return cvTry([&] {
+ cpp(box).points(points);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minEnclosingCircle_InputArray(
+ const interop::InputArrayProxy* points,
+ interop::Point2f *center,
+ float *radius)
+{
+ return cvTry([&] {
+ cv::Point2f center0;
+ float radius0;
+ cv::minEnclosingCircle(InProxy(*points), center0, radius0);
+ *center = c(center0);
+ *radius = radius0;
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minEnclosingCircle_Point(
+ cv::Point *points,
+ int pointsLength,
+ interop::Point2f*center,
+ float *radius)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ cv::Point2f center0;
+ float radius0;
+ cv::minEnclosingCircle(pointsMat, center0, radius0);
+ *center = c(center0);
+ *radius = radius0;
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minEnclosingCircle_Point2f(
+ cv::Point2f *points,
+ int pointsLength,
+ interop::Point2f*center,
+ float *radius)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ cv::Point2f center0;
+ float radius0;
+ cv::minEnclosingCircle(pointsMat, center0, radius0);
+ *center = c(center0);
+ *radius = radius0;
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minEnclosingTriangle_InputOutputArray(
+ const interop::InputArrayProxy* points,
+ const interop::OutputArrayProxy* triangle,
+ double *returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::minEnclosingTriangle(InProxy(*points), OutProxy(*triangle));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minEnclosingTriangle_Point(
+ cv::Point* points,
+ int pointsLength,
+ std::vector* triangle,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ *returnValue = cv::minEnclosingTriangle(pointsMat, *triangle);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_minEnclosingTriangle_Point2f(
+ cv::Point2f* points,
+ int pointsLength,
+ std::vector* triangle,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ *returnValue = cv::minEnclosingTriangle(pointsMat, *triangle);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_matchShapes_InputArray(
+ const interop::InputArrayProxy* contour1,
+ const interop::InputArrayProxy* contour2,
+ int method,
+ double parameter,
+ double* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::matchShapes(InProxy(*contour1), InProxy(*contour2), method, parameter);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_matchShapes_Point(
+ cv::Point *contour1,
+ int contour1Length,
+ cv::Point *contour2,
+ int contour2Length,
+ int method,
+ double parameter,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ contour1Mat(contour1Length, 1, contour1);
+ const cv::Mat_ contour2Mat(contour2Length, 1, contour2);
+ *returnValue = cv::matchShapes(contour1Mat, contour2Mat, method, parameter);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexHull_InputArray(
+ const interop::InputArrayProxy* points,
+ const interop::OutputArrayProxy* hull,
+ int clockwise,
+ int returnPoints)
+{
+ return cvTry([&] {
+ cv::convexHull(InProxy(*points), OutProxy(*hull), clockwise != 0, returnPoints != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexHull_Point_ReturnsPoints(
+ cv::Point *points,
+ int pointsLength,
+ std::vector *hull,
+ int clockwise)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ cv::convexHull(pointsMat, *hull, clockwise != 0, true);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexHull_Point2f_ReturnsPoints(
+ cv::Point2f *points,
+ int pointsLength,
+ std::vector *hull,
+ int clockwise)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ cv::convexHull(pointsMat, *hull, clockwise != 0, true);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexHull_Point_ReturnsIndices(
+ cv::Point *points,
+ int pointsLength,
+ std::vector *hull,
+ int clockwise)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ cv::convexHull(pointsMat, *hull, clockwise != 0, false);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexHull_Point2f_ReturnsIndices(
+ cv::Point2f *points,
+ int pointsLength,
+ std::vector *hull,
+ int clockwise)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsMat(pointsLength, 1, points);
+ cv::convexHull(pointsMat, *hull, clockwise != 0, false);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexityDefects_InputArray(
+ const interop::InputArrayProxy* contour,
+ const interop::InputArrayProxy* convexHull,
+ const interop::OutputArrayProxy* convexityDefects)
+{
+ return cvTry([&] {
+ cv::convexityDefects(InProxy(*contour), InProxy(*convexHull), OutProxy(*convexityDefects));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexityDefects_Point(
+ cv::Point *contour,
+ int contourLength,
+ int *convexHull,
+ int convexHullLength,
+ std::vector *convexityDefects)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourMat(contourLength, 1, contour);
+ const cv::Mat_ convexHullMat(convexHullLength, 1, convexHull);
+ cv::convexityDefects(contourMat, convexHullMat, *convexityDefects);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_convexityDefects_Point2f(
+ cv::Point2f *contour,
+ int contourLength,
+ int *convexHull,
+ int convexHullLength,
+ std::vector *convexityDefects)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourMat(contourLength, 1, contour);
+ const cv::Mat_ convexHullMat(convexHullLength, 1, convexHull);
+ cv::convexityDefects(contourMat, convexHullMat, *convexityDefects);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_isContourConvex_InputArray(const interop::InputArrayProxy* contour, int* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::isContourConvex(InProxy(*contour)) ? 1 : 0;
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_isContourConvex_Point(
+ cv::Point *contour,
+ int contourLength,
+ int* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourMat(contourLength, 1, contour);
+ *returnValue = cv::isContourConvex(contourMat) ? 1 : 0;
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_isContourConvex_Point2f(
+ cv::Point2f *contour,
+ int contourLength,
+ int* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourMat(contourLength, 1, contour);
+ *returnValue = cv::isContourConvex(contourMat) ? 1 : 0;
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_intersectConvexConvex_InputArray(
+ const interop::InputArrayProxy* p1,
+ const interop::InputArrayProxy* p2,
+ const interop::OutputArrayProxy* p12,
+ int handleNested,
+ float* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::intersectConvexConvex(InProxy(*p1), InProxy(*p2), OutProxy(*p12), handleNested != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_intersectConvexConvex_Point(
+ cv::Point *p1,
+ int p1Length,
+ cv::Point *p2,
+ int p2Length,
+ std::vector *p12,
+ int handleNested,
+ float* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ p1Vec(p1Length, 1, p1);
+ const cv::Mat_ p2Vec(p2Length, 1, p2);
+ *returnValue = cv::intersectConvexConvex(p1Vec, p2Vec, *p12, handleNested != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_intersectConvexConvex_Point2f(
+ cv::Point2f *p1,
+ int p1Length,
+ cv::Point2f *p2,
+ int p2Length,
+ std::vector *p12,
+ int handleNested,
+ float *returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ p1Vec(p1Length, 1, p1);
+ const cv::Mat_ p2Vec(p2Length, 1, p2);
+ *returnValue = cv::intersectConvexConvex(p1Vec, p2Vec, *p12, handleNested != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipse_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = c(cv::fitEllipse(InProxy(*points)));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipse_Point(
+ cv::Point *points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ *returnValue = c(cv::fitEllipse(pointsVec));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipse_Point2f(
+ cv::Point2f *points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ *returnValue = c(cv::fitEllipse(pointsVec));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipseAMS_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = c(cv::fitEllipseAMS(InProxy(*points)));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipseAMS_Point(
+ cv::Point* points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ *returnValue = c(cv::fitEllipseAMS(pointsVec));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipseAMS_Point2f(
+ cv::Point2f* points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ *returnValue = c(cv::fitEllipseAMS(pointsVec));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipseDirect_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = c(cv::fitEllipseDirect(InProxy(*points)));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipseDirect_Point(
+ cv::Point* points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ *returnValue = c(cv::fitEllipseDirect(pointsVec));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitEllipseDirect_Point2f(
+ cv::Point2f* points,
+ int pointsLength,
+ interop::RotatedRect* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ *returnValue = c(cv::fitEllipseDirect(pointsVec));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitLine_InputArray(
+ const interop::InputArrayProxy* points,
+ const interop::OutputArrayProxy* line,
+ int distType,
+ double param,
+ double reps,
+ double aeps)
+{
+ return cvTry([&] {
+ cv::fitLine(InProxy(*points), OutProxy(*line), distType, param, reps, aeps);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitLine_Point(
+ cv::Point *points,
+ int pointsLength,
+ float *line,
+ int distType,
+ double param,
+ double reps,
+ double aeps)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ cv::Mat_ lineVec(4, 1, line);
+ cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitLine_Point2f(
+ cv::Point2f *points,
+ int pointsLength,
+ float *line,
+ int distType,
+ double param,
+ double reps,
+ double aeps)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ cv::Mat_ lineVec(4, 1, line);
+ cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitLine_Point3i(
+ cv::Point3i *points,
+ int pointsLength,
+ float *line,
+ int distType,
+ double param,
+ double reps,
+ double aeps)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ cv::Mat_ lineVec(6, 1, line);
+ cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_fitLine_Point3f(
+ cv::Point3f *points,
+ int pointsLength,
+ float *line,
+ int distType,
+ double param,
+ double reps,
+ double aeps)
+{
+ return cvTry([&] {
+ const cv::Mat_ pointsVec(pointsLength, 1, points);
+ cv::Mat_ lineVec(6, 1, line);
+ cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_pointPolygonTest_InputArray(
+ const interop::InputArrayProxy* contour,
+ interop::Point2f pt,
+ int measureDist,
+ double *returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::pointPolygonTest(InProxy(*contour), cpp(pt), measureDist != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_pointPolygonTest_Point(
+ cv::Point *contour,
+ int contourLength,
+ interop::Point2f pt,
+ int measureDist,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourVec(contourLength, 1, contour);
+ *returnValue = cv::pointPolygonTest(contourVec, cpp(pt), measureDist != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_pointPolygonTest_Point2f(
+ cv::Point2f *contour,
+ int contourLength,
+ interop::Point2f pt,
+ int measureDist,
+ double* returnValue)
+{
+ return cvTry([&] {
+ const cv::Mat_ contourVec(contourLength, 1, contour);
+ *returnValue = cv::pointPolygonTest(contourVec, cpp(pt), measureDist != 0);
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_rotatedRectangleIntersection_OutputArray(
+ interop::RotatedRect rect1,
+ interop::RotatedRect rect2,
+ const interop::OutputArrayProxy* intersectingRegion,
+ int* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::rotatedRectangleIntersection(cpp(rect1), cpp(rect2), OutProxy(*intersectingRegion));
+ });
+}
+
+CVAPI(ExceptionStatus) geometry_rotatedRectangleIntersection_vector(
+ interop::RotatedRect rect1,
+ interop::RotatedRect rect2,
+ std::vector *intersectingRegion,
+ int* returnValue)
+{
+ return cvTry([&] {
+ *returnValue = cv::rotatedRectangleIntersection(cpp(rect1), cpp(rect2), *intersectingRegion);
+ });
+}
+
#endif // NO_GEOMETRY
diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h
index 55affa6e2..1ec922693 100644
--- a/src/OpenCvSharpExtern/imgproc.h
+++ b/src/OpenCvSharpExtern/imgproc.h
@@ -6,7 +6,6 @@
#include "include_opencv.h"
-
CVAPI(ExceptionStatus) imgproc_getGaussianKernel(
int ksize,
double sigma,
@@ -413,7 +412,6 @@ CVAPI(ExceptionStatus) imgproc_HoughCircles(
});
}
-
CVAPI(ExceptionStatus) imgproc_erode(
const interop::InputArrayProxy* src,
const interop::OutputArrayProxy* dst,
@@ -546,67 +544,6 @@ CVAPI(ExceptionStatus) imgproc_convertMaps(
});
}
-CVAPI(ExceptionStatus) imgproc_getRotationMatrix2D(
- interop::Point2f center,
- double angle,
- double scale,
- cv::Mat** returnValue)
-{
- return cvTry([&] {
- const auto ret = cv::getRotationMatrix2D(cpp(center), angle, scale);
- *returnValue = new cv::Mat(ret);
- });
-
-}
-CVAPI(ExceptionStatus) imgproc_invertAffineTransform(const interop::InputArrayProxy* M, const interop::OutputArrayProxy* iM)
-{
- return cvTry([&] {
- cv::invertAffineTransform(InProxy(*M), OutProxy(*iM));
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_getPerspectiveTransform1(
- cv::Point2f *src,
- cv::Point2f *dst,
- cv::Mat** returnValue)
-{
- return cvTry([&] {
- const auto ret = cv::getPerspectiveTransform(src, dst);
- *returnValue = new cv::Mat(ret);
- });
-}
-CVAPI(ExceptionStatus) imgproc_getPerspectiveTransform2(
- const interop::InputArrayProxy* src,
- const interop::InputArrayProxy* dst,
- cv::Mat** returnValue)
-{
- return cvTry([&] {
- const auto ret = cv::getPerspectiveTransform(InProxy(*src), InProxy(*dst));
- *returnValue = new cv::Mat(ret);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_getAffineTransform1(
- cv::Point2f *src,
- cv::Point2f *dst,
- cv::Mat** returnValue)
-{
- return cvTry([&] {
- const auto ret = cv::getAffineTransform(src, dst);
- *returnValue = new cv::Mat(ret);
- });
-}
-CVAPI(ExceptionStatus) imgproc_getAffineTransform2(
- const interop::InputArrayProxy* src,
- const interop::InputArrayProxy* dst,
- cv::Mat** returnValue)
-{
- return cvTry([&] {
- const auto ret = cv::getAffineTransform(InProxy(*src), InProxy(*dst));
- *returnValue = new cv::Mat(ret);
- });
-}
-
CVAPI(ExceptionStatus) imgproc_getRectSubPix(
const interop::InputArrayProxy* image,
interop::Size patchSize,
@@ -827,7 +764,6 @@ CVAPI(ExceptionStatus) imgproc_calcBackProject(
});
}
-
CVAPI(ExceptionStatus) imgproc_compareHist(
const interop::InputArrayProxy* h1,
const interop::InputArrayProxy* h2,
@@ -998,24 +934,6 @@ CVAPI(ExceptionStatus) imgproc_demosaicing(
});
}
-CVAPI(ExceptionStatus) imgproc_moments(
- const interop::InputArrayProxy* arr,
- int binaryImage,
- interop::Moments *returnValue)
-{
- return cvTry([&] {
- const auto m = cv::moments(InProxy(*arr), binaryImage != 0);
- *returnValue = c(m);
- });
-}
-/*
-CVAPI(ExceptionStatus) imgproc_HuMoments(interop::Moments *moments, double hu[7])
-{
- return cvTry([&] {
- cv::HuMoments(cpp(*moments), hu);
- });
-}
-*/
CVAPI(ExceptionStatus) imgproc_matchTemplate(
const interop::InputArrayProxy* image,
const interop::InputArrayProxy* templ,
@@ -1148,645 +1066,6 @@ CVAPI(ExceptionStatus) imgproc_findContoursLinkRuns2(const interop::InputArrayPr
});
}
-CVAPI(ExceptionStatus) imgproc_approxPolyDP_InputArray(
- const interop::InputArrayProxy* curve,
- const interop::OutputArrayProxy* approxCurve,
- double epsilon,
- int closed)
-{
- return cvTry([&] {
- cv::approxPolyDP(InProxy(*curve), OutProxy(*approxCurve), epsilon, closed != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_approxPolyDP_Point(
- cv::Point *curve,
- int curveLength,
- std::vector *approxCurve,
- double epsilon,
- int closed)
-{
- return cvTry([&] {
- const cv::Mat_ curveMat(curveLength, 1, curve);
- cv::approxPolyDP(curveMat, *approxCurve, epsilon, closed != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_approxPolyDP_Point2f(
- cv::Point2f *curve,
- int curveLength,
- std::vector *approxCurve,
- double epsilon,
- int closed)
-{
- return cvTry([&] {
- const cv::Mat_ curveMat(curveLength, 1, curve);
- cv::approxPolyDP(curveMat, *approxCurve, epsilon, closed != 0);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_arcLength_InputArray(
- const interop::InputArrayProxy* curve,
- int closed,
- double *returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::arcLength(InProxy(*curve), closed != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_arcLength_Point(
- cv::Point *curve,
- int curveLength,
- int closed,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ curveMat(curveLength, 1, curve);
- *returnValue = cv::arcLength(curveMat, closed != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_arcLength_Point2f(
- cv::Point2f *curve,
- int curveLength,
- int closed,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ curveMat(curveLength, 1, curve);
- *returnValue = cv::arcLength(curveMat, closed != 0);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_boundingRect_InputArray(const interop::InputArrayProxy* curve, interop::Rect* returnValue)
-{
- return cvTry([&] {
- *returnValue = c(cv::boundingRect(InProxy(*curve)));
- });
-}
-CVAPI(ExceptionStatus) imgproc_boundingRect_Point(
- cv::Point *curve,
- int curveLength,
- interop::Rect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ curveMat(curveLength, 1, curve);
- *returnValue = c(cv::boundingRect(curveMat));
- });
-}
-CVAPI(ExceptionStatus) imgproc_boundingRect_Point2f(
- cv::Point2f *curve,
- int curveLength,
- interop::Rect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ curveMat(curveLength, 1, curve);
- *returnValue = c(cv::boundingRect(curveMat));
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_contourArea_InputArray(
- const interop::InputArrayProxy* contour,
- int oriented,
- double* returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::contourArea(InProxy(*contour), oriented != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_contourArea_Point(
- cv::Point *contour,
- int contourLength,
- int oriented,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ contourMat(contourLength, 1, contour);
- *returnValue = cv::contourArea(contourMat, oriented != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_contourArea_Point2f(
- cv::Point2f *contour,
- int contourLength,
- int oriented,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ contourMat(contourLength, 1, contour);
- *returnValue = cv::contourArea(contourMat, oriented != 0);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_minAreaRect_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- *returnValue = c(cv::minAreaRect(InProxy(*points)));
- });
-}
-CVAPI(ExceptionStatus) imgproc_minAreaRect_Point(
- cv::Point *points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- *returnValue = c(cv::minAreaRect(pointsMat));
- });
-}
-CVAPI(ExceptionStatus) imgproc_minAreaRect_Point2f(
- cv::Point2f *points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- *returnValue = c(cv::minAreaRect(pointsMat));
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_boxPoints_OutputArray(interop::RotatedRect box, const interop::OutputArrayProxy* points)
-{
- return cvTry([&] {
- cv::boxPoints(cpp(box), OutProxy(*points));
- });
-}
-CVAPI(ExceptionStatus) imgproc_boxPoints_Point2f(interop::RotatedRect box, cv::Point2f points[4])
-{
- return cvTry([&] {
- cpp(box).points(points);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_minEnclosingCircle_InputArray(
- const interop::InputArrayProxy* points,
- interop::Point2f *center,
- float *radius)
-{
- return cvTry([&] {
- cv::Point2f center0;
- float radius0;
- cv::minEnclosingCircle(InProxy(*points), center0, radius0);
- *center = c(center0);
- *radius = radius0;
- });
-}
-CVAPI(ExceptionStatus) imgproc_minEnclosingCircle_Point(
- cv::Point *points,
- int pointsLength,
- interop::Point2f*center,
- float *radius)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- cv::Point2f center0;
- float radius0;
- cv::minEnclosingCircle(pointsMat, center0, radius0);
- *center = c(center0);
- *radius = radius0;
- });
-}
-CVAPI(ExceptionStatus) imgproc_minEnclosingCircle_Point2f(
- cv::Point2f *points,
- int pointsLength,
- interop::Point2f*center,
- float *radius)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- cv::Point2f center0;
- float radius0;
- cv::minEnclosingCircle(pointsMat, center0, radius0);
- *center = c(center0);
- *radius = radius0;
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_minEnclosingTriangle_InputOutputArray(
- const interop::InputArrayProxy* points,
- const interop::OutputArrayProxy* triangle,
- double *returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::minEnclosingTriangle(InProxy(*points), OutProxy(*triangle));
- });
-}
-CVAPI(ExceptionStatus) imgproc_minEnclosingTriangle_Point(
- cv::Point* points,
- int pointsLength,
- std::vector* triangle,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- *returnValue = cv::minEnclosingTriangle(pointsMat, *triangle);
- });
-}
-CVAPI(ExceptionStatus) imgproc_minEnclosingTriangle_Point2f(
- cv::Point2f* points,
- int pointsLength,
- std::vector* triangle,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- *returnValue = cv::minEnclosingTriangle(pointsMat, *triangle);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_matchShapes_InputArray(
- const interop::InputArrayProxy* contour1,
- const interop::InputArrayProxy* contour2,
- int method,
- double parameter,
- double* returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::matchShapes(InProxy(*contour1), InProxy(*contour2), method, parameter);
- });
-}
-CVAPI(ExceptionStatus) imgproc_matchShapes_Point(
- cv::Point *contour1,
- int contour1Length,
- cv::Point *contour2,
- int contour2Length,
- int method,
- double parameter,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ contour1Mat(contour1Length, 1, contour1);
- const cv::Mat_ contour2Mat(contour2Length, 1, contour2);
- *returnValue = cv::matchShapes(contour1Mat, contour2Mat, method, parameter);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_convexHull_InputArray(
- const interop::InputArrayProxy* points,
- const interop::OutputArrayProxy* hull,
- int clockwise,
- int returnPoints)
-{
- return cvTry([&] {
- cv::convexHull(InProxy(*points), OutProxy(*hull), clockwise != 0, returnPoints != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_convexHull_Point_ReturnsPoints(
- cv::Point *points,
- int pointsLength,
- std::vector *hull,
- int clockwise)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- cv::convexHull(pointsMat, *hull, clockwise != 0, true);
- });
-}
-CVAPI(ExceptionStatus) imgproc_convexHull_Point2f_ReturnsPoints(
- cv::Point2f *points,
- int pointsLength,
- std::vector *hull,
- int clockwise)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- cv::convexHull(pointsMat, *hull, clockwise != 0, true);
- });
-}
-CVAPI(ExceptionStatus) imgproc_convexHull_Point_ReturnsIndices(
- cv::Point *points,
- int pointsLength,
- std::vector *hull,
- int clockwise)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- cv::convexHull(pointsMat, *hull, clockwise != 0, false);
- });
-}
-CVAPI(ExceptionStatus) imgproc_convexHull_Point2f_ReturnsIndices(
- cv::Point2f *points,
- int pointsLength,
- std::vector *hull,
- int clockwise)
-{
- return cvTry([&] {
- const cv::Mat_ pointsMat(pointsLength, 1, points);
- cv::convexHull(pointsMat, *hull, clockwise != 0, false);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_convexityDefects_InputArray(
- const interop::InputArrayProxy* contour,
- const interop::InputArrayProxy* convexHull,
- const interop::OutputArrayProxy* convexityDefects)
-{
- return cvTry([&] {
- cv::convexityDefects(InProxy(*contour), InProxy(*convexHull), OutProxy(*convexityDefects));
- });
-}
-CVAPI(ExceptionStatus) imgproc_convexityDefects_Point(
- cv::Point *contour,
- int contourLength,
- int *convexHull,
- int convexHullLength,
- std::vector *convexityDefects)
-{
- return cvTry([&] {
- const cv::Mat_ contourMat(contourLength, 1, contour);
- const cv::Mat_ convexHullMat(convexHullLength, 1, convexHull);
- cv::convexityDefects(contourMat, convexHullMat, *convexityDefects);
- });
-}
-CVAPI(ExceptionStatus) imgproc_convexityDefects_Point2f(
- cv::Point2f *contour,
- int contourLength,
- int *convexHull,
- int convexHullLength,
- std::vector *convexityDefects)
-{
- return cvTry([&] {
- const cv::Mat_ contourMat(contourLength, 1, contour);
- const cv::Mat_ convexHullMat(convexHullLength, 1, convexHull);
- cv::convexityDefects(contourMat, convexHullMat, *convexityDefects);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_isContourConvex_InputArray(const interop::InputArrayProxy* contour, int* returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::isContourConvex(InProxy(*contour)) ? 1 : 0;
- });
-}
-CVAPI(ExceptionStatus) imgproc_isContourConvex_Point(
- cv::Point *contour,
- int contourLength,
- int* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ contourMat(contourLength, 1, contour);
- *returnValue = cv::isContourConvex(contourMat) ? 1 : 0;
- });
-}
-CVAPI(ExceptionStatus) imgproc_isContourConvex_Point2f(
- cv::Point2f *contour,
- int contourLength,
- int* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ contourMat(contourLength, 1, contour);
- *returnValue = cv::isContourConvex(contourMat) ? 1 : 0;
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_intersectConvexConvex_InputArray(
- const interop::InputArrayProxy* p1,
- const interop::InputArrayProxy* p2,
- const interop::OutputArrayProxy* p12,
- int handleNested,
- float* returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::intersectConvexConvex(InProxy(*p1), InProxy(*p2), OutProxy(*p12), handleNested != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_intersectConvexConvex_Point(
- cv::Point *p1,
- int p1Length,
- cv::Point *p2,
- int p2Length,
- std::vector *p12,
- int handleNested,
- float* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ p1Vec(p1Length, 1, p1);
- const cv::Mat_ p2Vec(p2Length, 1, p2);
- *returnValue = cv::intersectConvexConvex(p1Vec, p2Vec, *p12, handleNested != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_intersectConvexConvex_Point2f(
- cv::Point2f *p1,
- int p1Length,
- cv::Point2f *p2,
- int p2Length,
- std::vector *p12,
- int handleNested,
- float *returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ p1Vec(p1Length, 1, p1);
- const cv::Mat_ p2Vec(p2Length, 1, p2);
- *returnValue = cv::intersectConvexConvex(p1Vec, p2Vec, *p12, handleNested != 0);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_fitEllipse_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- *returnValue = c(cv::fitEllipse(InProxy(*points)));
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitEllipse_Point(
- cv::Point *points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- *returnValue = c(cv::fitEllipse(pointsVec));
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitEllipse_Point2f(
- cv::Point2f *points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- *returnValue = c(cv::fitEllipse(pointsVec));
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_fitEllipseAMS_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- *returnValue = c(cv::fitEllipseAMS(InProxy(*points)));
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitEllipseAMS_Point(
- cv::Point* points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- *returnValue = c(cv::fitEllipseAMS(pointsVec));
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitEllipseAMS_Point2f(
- cv::Point2f* points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- *returnValue = c(cv::fitEllipseAMS(pointsVec));
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_fitEllipseDirect_InputArray(const interop::InputArrayProxy* points, interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- *returnValue = c(cv::fitEllipseDirect(InProxy(*points)));
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitEllipseDirect_Point(
- cv::Point* points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- *returnValue = c(cv::fitEllipseDirect(pointsVec));
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitEllipseDirect_Point2f(
- cv::Point2f* points,
- int pointsLength,
- interop::RotatedRect* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- *returnValue = c(cv::fitEllipseDirect(pointsVec));
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_fitLine_InputArray(
- const interop::InputArrayProxy* points,
- const interop::OutputArrayProxy* line,
- int distType,
- double param,
- double reps,
- double aeps)
-{
- return cvTry([&] {
- cv::fitLine(InProxy(*points), OutProxy(*line), distType, param, reps, aeps);
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitLine_Point(
- cv::Point *points,
- int pointsLength,
- float *line,
- int distType,
- double param,
- double reps,
- double aeps)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- cv::Mat_ lineVec(4, 1, line);
- cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitLine_Point2f(
- cv::Point2f *points,
- int pointsLength,
- float *line,
- int distType,
- double param,
- double reps,
- double aeps)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- cv::Mat_ lineVec(4, 1, line);
- cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitLine_Point3i(
- cv::Point3i *points,
- int pointsLength,
- float *line,
- int distType,
- double param,
- double reps,
- double aeps)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- cv::Mat_ lineVec(6, 1, line);
- cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
- });
-}
-CVAPI(ExceptionStatus) imgproc_fitLine_Point3f(
- cv::Point3f *points,
- int pointsLength,
- float *line,
- int distType,
- double param,
- double reps,
- double aeps)
-{
- return cvTry([&] {
- const cv::Mat_ pointsVec(pointsLength, 1, points);
- cv::Mat_ lineVec(6, 1, line);
- cv::fitLine(pointsVec, lineVec, distType, param, reps, aeps);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_pointPolygonTest_InputArray(
- const interop::InputArrayProxy* contour,
- interop::Point2f pt,
- int measureDist,
- double *returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::pointPolygonTest(InProxy(*contour), cpp(pt), measureDist != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_pointPolygonTest_Point(
- cv::Point *contour,
- int contourLength,
- interop::Point2f pt,
- int measureDist,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ contourVec(contourLength, 1, contour);
- *returnValue = cv::pointPolygonTest(contourVec, cpp(pt), measureDist != 0);
- });
-}
-CVAPI(ExceptionStatus) imgproc_pointPolygonTest_Point2f(
- cv::Point2f *contour,
- int contourLength,
- interop::Point2f pt,
- int measureDist,
- double* returnValue)
-{
- return cvTry([&] {
- const cv::Mat_ contourVec(contourLength, 1, contour);
- *returnValue = cv::pointPolygonTest(contourVec, cpp(pt), measureDist != 0);
- });
-}
-
-CVAPI(ExceptionStatus) imgproc_rotatedRectangleIntersection_OutputArray(
- interop::RotatedRect rect1,
- interop::RotatedRect rect2,
- const interop::OutputArrayProxy* intersectingRegion,
- int* returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::rotatedRectangleIntersection(cpp(rect1), cpp(rect2), OutProxy(*intersectingRegion));
- });
-}
-CVAPI(ExceptionStatus) imgproc_rotatedRectangleIntersection_vector(
- interop::RotatedRect rect1,
- interop::RotatedRect rect2,
- std::vector *intersectingRegion,
- int* returnValue)
-{
- return cvTry([&] {
- *returnValue = cv::rotatedRectangleIntersection(cpp(rect1), cpp(rect2), *intersectingRegion);
- });
-}
-
CVAPI(ExceptionStatus) imgproc_applyColorMap1(
const interop::InputArrayProxy* src,
const interop::OutputArrayProxy* dst,
@@ -1838,7 +1117,6 @@ CVAPI(ExceptionStatus) imgproc_arrowedLine(
});
}
-
CVAPI(ExceptionStatus) imgproc_rectangle_InputOutputArray_Point(
const interop::InputOutputArrayProxy* img,
interop::Point pt1,
@@ -1890,7 +1168,6 @@ CVAPI(ExceptionStatus) imgproc_rectangle_Mat_Rect(
});
}
-
CVAPI(ExceptionStatus) imgproc_circle(
const interop::InputOutputArrayProxy* img,
interop::Point center,
diff --git a/src/OpenCvSharpExtern/include_opencv.h b/src/OpenCvSharpExtern/include_opencv.h
index 84d25a73a..1cc39ea50 100644
--- a/src/OpenCvSharpExtern/include_opencv.h
+++ b/src/OpenCvSharpExtern/include_opencv.h
@@ -47,10 +47,16 @@
// - 2D (opencv2/geometry/2d.hpp): convexHull, minAreaRect, fitEllipse, boxPoints,
// minEnclosingCircle/Triangle, Subdiv2D, ...
// - 3D (opencv2/geometry/3d.hpp): solvePnP, findHomography, triangulatePoints, ...
+// - point cloud sampling (opencv2/geometry/segment.hpp): voxelGridSampling,
+// randomSampling, farthestPointSampling, normalEstimate, ... (pulled in by 3d.hpp)
// opencv2/opencv.hpp does not pull opencv2/geometry.hpp (and the legacy calib3d
// umbrella that used to is neutralized above), so include it explicitly.
#include
+// opencv2/geometry/mst.hpp (generic graph Minimum Spanning Tree, cv::buildMST) is
+// not pulled in by opencv2/geometry.hpp itself, so include it explicitly too.
+#include
+
// OpenCV 5 moved CascadeClassifier / HOGDescriptor / groupRectangles out of the
// main objdetect module into the contrib xobjdetect module (still in the cv::
// namespace). It is lightweight (depends only on core/imgproc/imgcodecs/features),
diff --git a/src/OpenCvSharpExtern/my_types.h b/src/OpenCvSharpExtern/my_types.h
index c68dc5e5b..a9b7eef1b 100644
--- a/src/OpenCvSharpExtern/my_types.h
+++ b/src/OpenCvSharpExtern/my_types.h
@@ -170,6 +170,13 @@ namespace interop
float distance;
};
+ struct MSTEdge
+ {
+ int source;
+ int target;
+ double weight;
+ };
+
#pragma endregion
typedef struct Vec2b { uchar val[2]; } Vec2b;
@@ -291,6 +298,7 @@ OCS_INTEROP_BITCAST(TermCriteria, cv::TermCriteria)
OCS_INTEROP_BITCAST(RotatedRect, cv::RotatedRect)
OCS_INTEROP_BITCAST(KeyPoint, cv::KeyPoint)
OCS_INTEROP_BITCAST(DMatch, cv::DMatch)
+OCS_INTEROP_BITCAST(MSTEdge, cv::MSTEdge)
#undef OCS_INTEROP_BITCAST
diff --git a/test/OpenCvSharp.Tests/calib3d/GeometryFunctionsTest.cs b/test/OpenCvSharp.Tests/calib3d/GeometryFunctionsTest.cs
index 2dba0d1dc..8426b7688 100644
--- a/test/OpenCvSharp.Tests/calib3d/GeometryFunctionsTest.cs
+++ b/test/OpenCvSharp.Tests/calib3d/GeometryFunctionsTest.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using Xunit;
#pragma warning disable CA5394 // Do not use insecure randomness
@@ -610,4 +611,160 @@ public void FishEyeDistortPointsWithUndistortedMatrix()
Assert.Equal(pts.Length, (int)distorted.Total());
}
+
+ [Fact]
+ public void ApproxPolyN()
+ {
+ // Densely sample a square contour so approxPolyN must contract it back to ~4 vertices.
+ var pts = new List();
+ for (var i = 0; i <= 10; i++) pts.Add(new Point2f(i * 10f, 0));
+ for (var i = 0; i <= 10; i++) pts.Add(new Point2f(100, i * 10f));
+ for (var i = 0; i <= 10; i++) pts.Add(new Point2f(100 - (i * 10f), 100));
+ for (var i = 0; i <= 10; i++) pts.Add(new Point2f(0, 100 - (i * 10f)));
+
+ using var curve = Mat.FromPixelData(pts.Count, 1, MatType.CV_32FC2, pts.ToArray());
+ using var approxCurve = new Mat();
+
+ Cv2.ApproxPolyN(curve, approxCurve, 4);
+
+ Assert.Equal(4, (int)approxCurve.Total());
+ }
+
+ [Fact]
+ public void MinEnclosingConvexPolygon()
+ {
+ var pts = new Point2f[20];
+ for (var i = 0; i < pts.Length; i++)
+ {
+ var angle = 2 * Math.PI * i / pts.Length;
+ pts[i] = new Point2f((float)(50 * Math.Cos(angle)), (float)(50 * Math.Sin(angle)));
+ }
+ using var points = Mat.FromPixelData(pts.Length, 1, MatType.CV_32FC2, pts);
+ using var polygon = new Mat();
+
+ var area = Cv2.MinEnclosingConvexPolygon(points, polygon, 6);
+
+ Assert.True(area > 0);
+ Assert.True((int)polygon.Total() <= 6);
+ }
+
+ [Fact]
+ public void GetClosestEllipsePoints()
+ {
+ var ellipse = new RotatedRect(new Point2f(0, 0), new Size2f(2, 2), 0); // unit circle
+ var pts = new[] { new Point2f(2, 0) };
+ using var points = Mat.FromPixelData(pts.Length, 1, MatType.CV_32FC2, pts);
+ using var closest = new Mat();
+
+ Cv2.GetClosestEllipsePoints(ellipse, points, closest);
+
+ Assert.Equal(1, (int)closest.Total());
+ var closestPt = closest.Get(0);
+ Assert.True(Math.Abs(closestPt.X - 1.0) < 1e-2);
+ Assert.True(Math.Abs(closestPt.Y) < 1e-2);
+ }
+
+ [Fact]
+ public void BuildMST()
+ {
+ var edges = new[]
+ {
+ new MSTEdge(0, 1, 1.0),
+ new MSTEdge(1, 2, 2.0),
+ new MSTEdge(2, 3, 3.0),
+ new MSTEdge(0, 3, 10.0),
+ new MSTEdge(0, 2, 15.0)
+ };
+
+ var mst = Cv2.BuildMST(4, edges, MSTAlgorithm.Kruskal);
+
+ Assert.NotNull(mst);
+ Assert.Equal(3, mst!.Length);
+ Assert.Equal(6.0, mst.Sum(e => e.Weight), 6);
+ }
+
+ [Fact]
+ public void VoxelGridSampling()
+ {
+ // Two dense clusters far apart; a large-enough voxel collapses each cluster to one point.
+ var pts = new List();
+ var rng = new Random(17);
+ for (var i = 0; i < 50; i++)
+ pts.Add(new Point3f((float)rng.NextDouble() * 0.01f, 0, 0));
+ for (var i = 0; i < 50; i++)
+ pts.Add(new Point3f(10 + ((float)rng.NextDouble() * 0.01f), 0, 0));
+
+ using var inputPts = Mat.FromPixelData(pts.Count, 1, MatType.CV_32FC3, pts.ToArray());
+ using var flags = new Mat();
+
+ var sampledCount = Cv2.VoxelGridSampling(flags, inputPts, 1.0f, 1.0f, 1.0f);
+
+ Assert.Equal(2, sampledCount);
+ }
+
+ [Fact]
+ public void RandomSampling()
+ {
+ var pts = new Point3f[100];
+ var rng = new Random(19);
+ for (var i = 0; i < pts.Length; i++)
+ pts[i] = new Point3f((float)rng.NextDouble(), (float)rng.NextDouble(), (float)rng.NextDouble());
+
+ using var inputPts = Mat.FromPixelData(pts.Length, 1, MatType.CV_32FC3, pts);
+ using var sampled = new Mat();
+
+ Cv2.RandomSampling(sampled, inputPts, 10);
+
+ // The native function fills sampled_pts as an Nx3 single-channel Mat.
+ Assert.Equal(10, sampled.Rows);
+ }
+
+ [Fact]
+ public void FarthestPointSampling()
+ {
+ var pts = new Point3f[100];
+ var rng = new Random(23);
+ for (var i = 0; i < pts.Length; i++)
+ pts[i] = new Point3f((float)rng.NextDouble(), (float)rng.NextDouble(), (float)rng.NextDouble());
+
+ using var inputPts = Mat.FromPixelData(pts.Length, 1, MatType.CV_32FC3, pts);
+ using var flags = new Mat();
+
+ var sampledCount = Cv2.FarthestPointSampling(flags, inputPts, 10);
+
+ Assert.Equal(10, sampledCount);
+ }
+
+ [Fact]
+ public void NormalEstimate()
+ {
+ var pts = new[]
+ {
+ new Point3f(0, 0, 0),
+ new Point3f(1, 0, 0),
+ new Point3f(0, 1, 0),
+ new Point3f(1, 1, 0),
+ new Point3f(0.5f, 0.5f, 0)
+ };
+ using var inputPts = Mat.FromPixelData(pts.Length, 1, MatType.CV_32FC3, pts);
+
+ var nnIdxData = new int[pts.Length, pts.Length];
+ for (var i = 0; i < pts.Length; i++)
+ for (var j = 0; j < pts.Length; j++)
+ nnIdxData[i, j] = j;
+ using var nnIdx = Mat.FromArray(nnIdxData);
+
+ using var normals = new Mat();
+ using var curvatures = new Mat();
+
+ Cv2.NormalEstimate(normals, curvatures, inputPts, nnIdx);
+
+ // The native function fills normals as an Nx3 single-channel Mat.
+ Assert.Equal(pts.Length, normals.Rows);
+ for (var i = 0; i < pts.Length; i++)
+ {
+ var nz = normals.Get(i, 2);
+ Assert.True(Math.Abs(Math.Abs(nz) - 1.0) < 1e-2, $"normal[{i}].z={nz}");
+ }
+ }
}