【问题标题】:Find average of blob edge coordinates using AForge?使用 AForge 查找斑点边缘坐标的平均值?
【发布时间】:2013-09-20 18:53:36
【问题描述】:

我试图找到给定位图图像中斑点的 x 和 y 坐标的平均值。据我所知,我应该使用

BlobCounter blobCounter = new BlobCounter();
blobCounter.ProcessImage((Bitmap)pictureBox1.Image);
Blob[] blobs = blobCounter.GetObjectsInformation();
foreach (Blob blob in blobs)
{
     blobCounter.GetBlobsLeftAndRightEdges(Blob blob, out leftPoints, out rightPoints);

}

但是 a),我收到一个错误,说“GetBlobsLeftAndRightEdges 方法没有重载需要 1 个参数”,并且 b),我不知道从那里去哪里。有什么帮助吗?

【问题讨论】:

    标签: c# aforge


    【解决方案1】:

    你尝试用维度信息填充数组 像

    public Rectangle[] Blobcounter.GetObjectsRectangles() ?

    【讨论】:

      【解决方案2】:

      我不知道你为什么想要所有 blob 的 X 和 Y 坐标的平均值,只是为了更好地帮助你。但无论如何,如果您想要每个 blob 的 X 和 Y 坐标,您可以将 for 循环中的代码替换为:

      矩形rect = blob.Rectangle;

      rect 提供 X 和 Y 属性来获取 blob 的 X 和 Y 坐标,以及一些可以帮助您进一步处理的属性。..

      【讨论】:

        【解决方案3】:

        以下将解决您的错误a):

        在执行blobCounter.GetBlobsLeftAndRightEdges方法时,声明leftPointsrightPoints列表变量并删除类名Blob

        BlobCounter blobCounter = new BlobCounter();
        blobCounter.ProcessImage((Bitmap)pictureBox1.Image);
        Blob[] blobs = blobCounter.GetObjectsInformation();
        
        List<IntPoint> leftPoints;
        List<IntPoint> rightPoints;
        
        foreach (Blob blob in blobs)
        {
             blobCounter.GetBlobsLeftAndRightEdges(blob, out leftPoints, out rightPoints);
        }
        

        【讨论】:

          【解决方案4】:

          代码中缺少 List leftPoints = null;List rightPoints = null; 的声明。您需要在调用代码中分配out参数。

          【讨论】:

            猜你喜欢
            • 2012-05-21
            • 1970-01-01
            • 2018-05-08
            • 1970-01-01
            • 1970-01-01
            • 2022-11-28
            • 2017-06-02
            • 2018-07-20
            • 2013-09-06
            相关资源
            最近更新 更多