ForeverPs / content-aware-rotation

Implementation of Kaiming He's Paper Content-Aware Rotation on ICCV 2013
33 stars 4 forks source link

Pk的计算疑问 #2

Closed tachikoma777 closed 4 years ago

tachikoma777 commented 4 years ago

a1, b1, c1, d1 = abcd(p1[0], p1[1], x1, y1, x2, y2) a2, b2, c2, d2 = abcd(p2[0], p2[1], x1, y1, x2, y2)

你好,我在处理长线条的时候结果比较奇怪,看到这里计算Pk只用到一个quad的顶点。是默认线段不跨quad吗? 如果是比较长的直线,是不是用多个quad的顶点计算Pk比较好呢?

多谢!

ForeverPs commented 4 years ago

线条会被meshgrid分割开,也就是说,一个长线条会被分割到若干个meshgrid之内,每一小段用它所在的mesh的四个顶点表示。

---原始邮件--- 发件人: "tachikoma"<notifications@github.com> 发送时间: 2020年10月10日(周六) 下午4:24 收件人: "ForeverPs/content-aware-rotation"<content-aware-rotation@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: [ForeverPs/content-aware-rotation] Pk的计算疑问 (#2)

a1, b1, c1, d1 = abcd(p1[0], p1[1], x1, y1, x2, y2) a2, b2, c2, d2 = abcd(p2[0], p2[1], x1, y1, x2, y2)

你好,我在处理长线条的时候结果比较奇怪,看到这里计算Pk只用到一个quad的顶点。是默认线段不跨quad吗? 如果是比较长的直线,是不是用多个quad的顶点计算Pk比较好呢?

多谢!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

tachikoma777 commented 4 years ago

感谢回复,我没有找到对line进行分割的部分,请问在哪一段代码里呢? 在计算Pk之前print(line)都是完整的直线

ForeverPs commented 4 years ago

see function detect_lines() in lsd_detect_lines.py

tachikoma777 commented 4 years ago

see function detect_lines() in lsd_detect_lines.py

`def intersect(pt1, pt2, pt3, pt4):

return the intersection of pt1 - pt2 and pt3 - pt4

`

这个寻找交点的代码的运行结果有点奇怪,我这边所有情况都是不满足if, return False。 eg: intersect([0,2], [2,2], [1,1], [1,3]) p=[0.999999999975 ,0] ---> p return None.

能帮忙确认下吗,麻烦啦

ForeverPs commented 4 years ago

是的,可能是推导出错了,这个就是求一下两条直线的交点而已,已经修改。 def intersect(pt1, pt2, pt3, pt4):

return the intersection of pt1 - pt2 and pt3 - pt4

a0 = pt1[1] - pt2[1]
b0 = pt2[0] - pt1[0]
c0 = pt1[0] * pt2[1] - pt2[0] * pt1[1]

a1 = pt3[1] - pt4[1]
b1 = pt4[0] - pt3[0]
c1 = pt3[0] * pt4[1] - pt4[0] * pt3[1]

d = a0 * b1 - a1 * b0
if d == 0:
    return False, None
x = (b0 * c1 - b1 * c0) / d
y = (a1 * c0 - a0 * c1) / d
return True, [x, y]
tachikoma777 commented 4 years ago

thx!