简体   繁体   English

Python OpenCV:查找曲率切线并检测与另一个圆的交点

[英]Python OpenCV: Finding tangent of a curvature and detecting intersections with another circle

I am doing a line detecting software. 我正在做线路检测软件。 I can successfully detect the contour of line as array of points. 我可以成功地将线的轮廓检测为点阵列。 Now I am trying to extract information from it such as approx angle and error from center (see images below). 现在,我尝试从中提取信息,例如大约角度和中心误差(请参见下图)。

input image: 输入图片:

输入图像

output image: 输出图像:

输出图像


Output image description: 输出图像描述:
Yellow circle is area of interest, but centered on intersecting point of red x-axis line and detected line. 黄色圆圈是感兴趣的区域,但以红色x轴线和检测到的线的交点为中心。 Center of this circle is marked with big blue point. 该圆圈的中心标记有大蓝点。

Green line is the actual output. 绿线是实际输出。 After cropped image with yellow circle, I am going to use OpenCV's fitLine function. 裁剪带有黄色圆圈的图像后,我将使用OpenCV的fitLine函数。 This will give me my precious point locations, I guess. 我想,这将给我我的宝贵位置。

What I need: 我需要的:

I want to use, as said above, fitLine method but since I cannot locate the intersecting point -between mid-x-axis and detected white line- I cannot crop image and so on. 如上所述,我想使用fitLine方法,但是由于无法找到相交点-在x轴中线和检测到的白线之间-我无法裁剪图像,依此类推。 So, I need to locate the point (shown in big blue point in output image). 因此,我需要找到该点(在输出图像中以蓝色大点显示)。

I answer my own question on behalf of the power of research: 我代表研究的力量回答我自己的问题:

I realized that circular mask is not needed since I am cropping the image to find average curve, but still managed to crop a circular area just to be sure I can. 我意识到不需要圆形遮罩,因为我正在裁剪图像以找到平均曲线,但是为了确保可以,仍然设法裁剪了圆形区域。

After cropping image to work with area of interest, I simply used fitLine method with DIST_L2 distance. 裁剪图像以使其适合感兴趣的区域后,我仅使用了DIST_L2距离的fitLine方法。 That was all I wanted. 那就是我想要的。 Note that Python's builtin function sorted was not able to sort my contours by area. 请注意,Python的内置函数sorted无法按区域对轮廓进行排序。

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

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