简体   繁体   中英

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). 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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