public static MCvBox2D MinAreaRect(PointF[] points)
{
IntPtr seq = Marshal.AllocHGlobal(StructSize.MCvContour);
IntPtr block = Marshal.AllocHGlobal(StructSize.MCvSeqBlock);
GCHandle handle = GCHandle.Alloc(points, GCHandleType.Pinned);
CvInvoke.cvMakeSeqHeaderForArray(
CvInvoke.CV_MAKETYPE((int)CvEnum.MAT_DEPTH.CV_32F, 2),
StructSize.MCvSeq,
StructSize.PointF,
handle.AddrOfPinnedObject(),
points.Length,
seq,
block);
MCvBox2D rect = CvInvoke.cvMinAreaRect2(seq, IntPtr.Zero);
handle.Free();
Marshal.FreeHGlobal(seq);
Marshal.FreeHGlobal(block);
return rect;
}