本文介绍了如何从霍夫变换(rho,theta)将坐标转换回图像(x,y)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个通过在Opencv中调用霍夫变换函数产生的线向量,需要将它们转换回图像坐标.我从Opencv的官方文档中找到了这段示例代码,但我不理解.有人可以解释吗?

I have a vector of lines produced by calling hough transformation function in Opencv, and need to convert them back to image coordinates. I found this piece of sample code from Opencv's official documentation, but I don't understand it. Would any one explain please?

for( size_t i = 0; i < lines->size(); i++ )
{
    float rho = lines->at(i)[0]; //[0] is rho
    float theta = lines->at(i)[1]; //[1] is theta
    double a = cos(theta), b = sin(theta);
    double x0 = a*rho, y0 = b*rho;
    cv::Point pt1(cvRound(x0 + 1000*(-b)),
              cvRound(y0 + 1000*(a)));
    cv::Point pt2(cvRound(x0 - 1000*(-b)),
              cvRound(y0 - 1000*(a)));
    line( *mat, pt1, pt2, Scalar(255,0,0), 1, 8 );
}

这条线的1000条是什么?

What is the 1000 doing this line?

pt1(cvRound(x0 + 1000*(-b)), cvRound(y0 + 1000*(a)))

此外,为什么pt2的y线为负?例如,如果我的第一行是(rho,theta)格式的(0,0),则pt2将是(0,-1000).

Furthermore, why does pt2 have negative y cords?For example, if my first line is (0,0) in (rho, theta) format, pt2 would be (0, -1000).

谢谢

推荐答案

这就是法线的数学原理.看看这篇文章-

That's how the math for normal lines works. Have a look at this article - Converting lines from normal to slope intercept form it goes through the math.

这篇关于如何从霍夫变换(rho,theta)将坐标转换回图像(x,y)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 02:08