using Emgu.CV; using Emgu.CV.Structure; using Emgu.CV.CvEnum; using System.Drawing; // create an array of points PointF[] points = new PointF[] { new PointF(10, 20), new PointF(30, 40), new PointF(50, 60) }; // compute the convex hull of the points using CvInvoke.ConvexHull method VectorOfPoint convexHull = new VectorOfPoint(); CvInvoke.ConvexHull(new VectorOfPointF(points), convexHull, true); // display the resulting convex hull Imageimage = new Image (100, 100, new Bgr(255, 255, 255)); image.DrawPolyline(convexHull.ToArray(), true, new Bgr(0, 0, 255), 2); cvShowImage("Convex Hull Example", image.Ptr);
using OpenCvSharp; using OpenCvSharp.Extensions; // create an array of points Point2f[] points = new Point2f[] { new Point2f(10, 20), new Point2f(30, 40), new Point2f(50, 60) }; // compute the convex hull of the points using CvInvoke.ConvexHull method var convexHull = Cv2.ConvexHull(points, returnPoints: true); // display the resulting convex hull var image = new Mat(100, 100, MatType.CV_8UC3, new Scalar(255, 255, 255)); Cv2.Polylines(image, convexHull, true, new Scalar(0, 0, 255), 2); Cv2.ImShow("Convex Hull Example", image); Cv2.WaitKey(0);This example creates an array of three points and computes the convex hull of those points using the Cv2.ConvexHull method from the OpenCvSharp package library. The resulting convex hull is displayed in a new window.