Using Seq in emgu c#

540 views Asked by At

I have a self-defined struct of a point (as opposed to System.Drawing.Point):

struct PointD
{
    public double X,Y;
}

I want to get a Seq of points, and from there extract the minimum area rectangle:

using (MemStorage stor = new MemStorage())
{
    Seq<PointD> seq = new Seq<PointD>(CvInvoke.CV_MAKETYPE(6, 2), stor);
    seq.Push(new PointD(0.5, 0));
    seq.Push(new PointD(1.0, 0));
    seq.Push(new PointD(0, 1.0));
    seq.Push(new PointD(1.0, 1.0));
    var output = seq.GetMinAreaRect();
}

However, this code throws an exception at GetMinAreaRect(), saying that the input sequence must be 2d points. My question is there a way to get my data format through correctly? I was thinking that I just lack a bit of something, as this code can work for a System.Drawing.Point.

1

There are 1 answers

0
Margus On BEST ANSWER

I assume following would work:

int[] pts = {
  new PointF(0.5, 0),
  new PointF(1.0, 0),
  new PointF(0, 1.0),
  new PointF(1.0, 1.0)
};
MCvBox2D box = PointCollection.MinAreaRect(pts);

Additional example : http://www.emgu.com/wiki/index.php/Minimum_Area_Rectangle_in_CSharp