using Emgu.CV.Structure; PointF[] vertices = CvInvoke.BoxPoints( new MCvBox2D(new PointF(100, 100), new SizeF(50, 30), 0) ).ToArray(); // vertices will contain [(75, 115), (125, 115), (125, 85), (75, 85)]
using Emgu.CV.Structure; RectangleF rect = new RectangleF(new PointF(200, 200), new SizeF(60, 40)); MCvBox2D box = new MCvBox2D(rect, 45); // 45 degrees rotation PointF[] vertices = CvInvoke.BoxPoints(box).ToArray(); // vertices will contain the rotated vertices of the rectangle
using Emgu.CV; using Emgu.CV.Structure; Mat image = new Mat("input.jpg"); PointF[] vertices = CvInvoke.BoxPoints( new MCvBox2D(new PointF(300, 150), new SizeF(120, 80), -30) ).ToArray(); image.DrawPolyline( vertices, true, // closed polygon new Bgr(Color.Yellow).MCvScalar, 3 // line thickness ); image.Save("output.jpg");In all of the above examples, we use the CvInvoke BoxPoints function to calculate the vertices of a rectangle. We then use these vertices to perform various operations, such as drawing lines, drawing polygons, or calculating bounding boxes. The Emgu.CV library provides a convenient interface to the powerful OpenCV image processing library, allowing us to perform complex computer vision tasks with ease.