OpenCV 和 Python 中直线的反射
我正在尝试计算 OpenCV 中一条线在表面上的反射。
我使用一个弹丸进行跟踪,它正在绘制线 2 和边框。
我“只是”想画一条反弹角度的线,正如您在我的绘图中看到的那样。
我得到了一个计算三个给定点的角度的代码,但在我的示例中,第 2 行不是静态的。它会移动,因为它是由移动的射弹牵引的。因此,为了计算这个,我需要边界和 2 号线的交点。我有点费劲去得到它。.
有没有一种简单的方法来解决这个问题?
谢谢。
I am trying to calculate the reflection of a line on a surface in OpenCV.
I work with a projectile im tracking which is drawing line 2 and a border.
I "just" want to draw a line of the bounce angle as you can see in my drawing.
I got a code that calculate the angle of three given points but in my example line 2 is not static. It will move because its drawn by a moving projectile. So to calculate this i need the intersection point of the border and Line 2. Im kinda struggeling to get that..
Is there an easy way to solve this ?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的评论:
射弹坐标 (P0)
撞击点 (P1)
边界极值 (A, B)
我假设 P1 属于该段AB。
应将 P0 投影在经过 A、B 的直线上。称此点为 PP。然后您应该计算
This 等于 alpha,您可以用它来计算反射段,具体取决于它的长度。
我建议使用 shapely 库:
https://shapely.readthedocs.io/en/稳定/manual.html
From your comment:
Projectile coordinates (P0)
Impact point (P1)
Border extremes (A, B)
I assume that P1 belongs to the segment AB.
You should project P0 in the straight line passing by A, B. Call this point PP. You should then compute
This is equal to alpha, that you can use to compute the reflection segment, depending on how long it is.
I suggest to use the shapely library:
https://shapely.readthedocs.io/en/stable/manual.html