簡體   English   中英

在Emgu C#中使用Seq

[英]Using Seq in emgu c#

我有一個點的自定義結構(與System.Drawing.Point相對):

struct PointD
{
    public double X,Y;
}

我想獲得一個點的Seq ,然后從中提取最小面積的矩形:

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();
}

但是,此代碼在GetMinAreaRect()處引發異常,表示輸入序列必須為2d點。 我的問題是有辦法正確獲取我的數據格式嗎? 我當時以為我只是缺少一些東西,因為此代碼可以用於System.Drawing.Point

我認為以下將工作:

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);

附加示例: http : //www.emgu.com/wiki/index.php/Minimum_Area_Rectangle_in_CSharp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM