小编And*_*ade的帖子

如何计算两条线之间的交点

我试图使用霍夫变换计算光流算法的线之间的交点.但是,当我使用算法计算交叉点时,我没有得到我应该得到的分数.

我将Lines保存为我创建的类的实例ImageLine.这是我的交集方法的代码.

Point ImageLine::intersectionWith(ImageLine other)
{
    float A2 = other.Y2() - other.Y1();
    float B2 = other.X2() - other.X1();
    float C2 = A2*other.X1() + B2*other.Y1();

    float A1 = y2 - y1;
    float B1 = x2 - x1;
    float C1 = A1 * x1 + B1 * y1;

   float det = A1*B2 - A2*B1;
   if (det == 0)
   {
        return Point(-1,-1);
   }
   Point d = Point((B2 * C1 - B1 * C2) / det, -(A1 * C2 - A2 * …
Run Code Online (Sandbox Code Playgroud)

c++ opencv intersection line

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

intersection ×1

line ×1

opencv ×1