简体   繁体   English

添加曲线切线,以及切线的法线。 OpenCV Python

[英]Adding tangent to curve, and the normal to the tangent. OpenCV Python

Im trying to add tangents along the curve in the image below, like the red lines in the second picture.我试图沿着下图中的曲线添加切线,就像第二张图片中的红线。 Then I would like to use the tangents to find the the 90 degrees normal line to the tangent(the green lines).然后我想使用切线找到切线(绿线)的 90 度法线。 The goal is to find the distance between the two white lines at different places.目标是找到不同位置的两条白线之间的距离。 I use Python and OpenCV, if anyone have any suggestion to how I could do this I would be very grateful.我使用 Python 和 OpenCV,如果有人对我如何做到这一点有任何建议,我将不胜感激。 Code example would be awesome.代码示例会很棒。

原图

带有渐变曲线的图像

This post is pretty old but I'm getting close.这篇文章很老了,但我正在接近。 Firstly, I draw two horizontal lines, with a distance of 2-3 pixels between them.首先,我画两条水平线,它们之间的距离为 2-3 个像素。 Then, I calculate the intersection of both with one of the initial curves.然后,我计算两者与初始曲线之一的交点。 Now you have two points on the initial curve at the left.现在您在左侧的初始曲线上有两个点。 Then the tangent can be calculated (basic math).然后可以计算切线(基础数学)。 You calculate the middle of the two points (basic math).您计算两点的中间值(基础数学)。 Then the normal can be drawn using this calculated middle point and the tangent (basic math again, if I'm not incorrect).然后可以使用这个计算出的中点和切线来绘制法线(如果我没记错的话,又是基础数学)。 Should have the tangent and normal line now.现在应该有切线和法线。

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

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