简体   繁体   English

OpenCV中的级联Hough变换

[英]Cascaded Hough Transform in OpenCV

Is it possible to perform a Cascaded Hough Transform in OpenCV? 是否可以在OpenCV中执行级联Hough变换? I understand its just a HT followed by another one. 我理解它只是一个HT,然后是另一个。 The problem I'm facing is that the values returned are always rho and theta and never in y-intercept form. 我面临的问题是,返回的值始终是rho和theta,而不是y截距形式。

Is it possible to convert these values back to y-intercept and split them into sub-spaces so I can detect vanishing points? 有可能将这些值转换回y轴截距并将它们分成子空间,这样我就可以检测到消失点了吗?

Or is it just better to program an implementation of HT myself in, say, Python? 或者,在Python中编写HT的实现更好吗?

I don't think OpenCV can perform cascaded hough transforms. 我不认为OpenCV可以执行级联霍夫变换。 You should convert them to xy space yourself. 你应该自己将它们转换为xy空间。 This article might help you: 本文可能对您有所帮助:

http://aishack.in/tutorials/converting-lines-from-normal-to-slopeintercept-form/ http://aishack.in/tutorials/converting-lines-from-normal-to-slopeintercept-form/

you could try to populate the Hough domain with m and c parameters instead, so that y = mx + c can be re-written as c = y - mx so instead of the usual rho = x cos(theta) + y sin(theta), you have c = y - mx 您可以尝试用m和c参数填充Hough域,这样y = mx + c就可以重写为c = y - mx而不是通常的rho = x cos(theta)+ y sin(theta) ),你有c = y - mx

normally, you'd go through the thetas and calculate the rho, then you increment the accumulator value for that pair of rho and theta. 通常,您需要经过theta并计算rho,然后再增加那对rho和theta的累加器值。 Here, you'd go through the value of m and calculate the values of c, then accumulate that m,c element in the accumulator. 在这里,您将遍历m的值并计算c的值,然后将m,c元素累加到累加器中。 The bin with the most votes would be the right m,c 得票最多的垃圾箱是正确的m,c

// going through the image looking for edge pixels
for (i = 0;i<numrows;i++)
    {
        for (j = 0;j<numcols;j++)
        {
            if (img[i*numcols + j] > 1)
            {
                for (n = first_m;n<last_m;n++)
                {   
                    index = i - n * j;
                    accum[n][index]++;
                }
            }
        }
    }

I guess where this becomes ineffective is that its hard to define the step size for going through m as they should technically go from -infinity to infinity so you'd kind of have trouble. 我猜这个无效的地方是很难定义通过m的步长,因为它们在技术上应该从-infinity到无穷大,所以你有点麻烦。 yeah, so much for Hough transform in terms of m,c. 是的,就m,c而言,Hough变换非常多。 Lol 大声笑

I guess you could go the other way and isolate m so it would be m = (yc)/x so that now, you cycle through a bunch of y values that make sense and its much more manageable though it's still hard to define your accumulator matrix because m still has no limit. 我想你可以走另一条路并隔离m所以它将是m =(yc)/ x所以现在,你循环通过一堆有意义的y值,它更易于管理,虽然它仍然很难定义你的累加器矩阵因为m仍然没有限制。 I guess you could limit the values of m that you would be interested in looking for. 我想您可以限制想要寻找的m的值。

Yeah, much more sense to go with rho and theta and convert them into y = mx + c and then even making a brand new image and re-running the hough transform on it. 是的,更有意义的是与rho和theta一起转换为y = mx + c,然后甚至制作一个全新的图像并重新运行hough变换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM