【问题标题】:Standard Hough Lines in EMGU CVEMGU CV 中的标准霍夫线
【发布时间】:2013-03-08 19:05:59
【问题描述】:

我需要使用标准 Hough 变换(而不是使用实现概率 Hough 变换的 HoughLinesBinary 方法)并尝试通过创建 HoughLinesBinary 方法的自定义版本来实现:

using (MemStorage stor = new MemStorage())
     {
        IntPtr lines = CvInvoke.cvHoughLines2(canny.Ptr, stor.Ptr, Emgu.CV.CvEnum.HOUGH_TYPE.CV_HOUGH_STANDARD, rhoResolution, (thetaResolution*Math.PI)/180, threshold, 0, 0);

        Seq<MCvMat> segments = new Seq<MCvMat>(lines, stor);
        List<MCvMat> lineslist = segments.ToList();
        foreach(MCvMat line in lineslist)
        {
           //Process lines: (rho, theta)
        }
     }

我的问题是我不确定返回的序列是什么类型。我相信它应该是 MCvMat,因为阅读了 CvMat* 在 OpenCV 中使用的文档,其中还指出对于标准“矩阵必须是(创建的序列将是)CV_32FC2 类型”

我不清楚我需要做什么来返回和处理来自标准霍夫线的正确输出数据(即每行的 2x1 向量给出 rho 和 theta 信息)。

任何帮助将不胜感激。谢谢

-萨尔

【问题讨论】:

    标签: opencv emgucv hough-transform


    【解决方案1】:

    几天前我自己也遇到了同样的问题。这就是我使用编组解决它的方法。如果您找到更简单的解决方案,请告诉我。

    using (MemStorage stor = new MemStorage())
    {
        IntPtr lines = CvInvoke.cvHoughLines2(canny.Ptr, stor.Ptr, Emgu.CV.CvEnum.HOUGH_TYPE.CV_HOUGH_STANDARD, rhoResolution, (thetaResolution*Math.PI)/180, threshold, 0, 0);
    
        int maxLines = 100;
        for(int i = 0; i < maxLines; i++)
        {
            IntPtr line = CvInvoke.cvGetSeqElem(lines, i);
            if (line == IntPtr.Zero)
            {
                // No more lines
                break;
            }
            PolarCoordinates coords = (PolarCoordinates)System.Runtime.InteropServices.Marshal.PtrToStructure(line, typeof(PolarCoordinates));
    
            // Do something with your Hough lines
        }
    }
    

    结构体定义如下:

    public struct PolarCoordinates
    {
        public float Rho;
        public float Theta;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 2013-03-09
      • 2014-10-07
      • 1970-01-01
      相关资源
      最近更新 更多