简体   繁体   English

对象轮廓上的opencv角点检测

[英]opencv corner detection on object contour

I have images of a smelting cube, forming into a droplet over time. 我有一个熔炼立方体的图像,随着时间的推移形成一个液滴。 So far, i extracted the contour of it, but next i'd need to to distinguish between object and surface. 到目前为止,我提取了它的轮廓,但接下来我需要区分物体和表面。 My Idea is to detect the corners where object touches surface, but i am struggling to find a reasonable approach how to do so (preferably using the c++ interface of opencv). 我的想法是检测物体接触表面的角落,但我很难找到一个合理的方法如何这样做(最好使用opencv的c ++接口)。 I'd appreciate any suggestions. 我很感激任何建议。
Here are some examples of the extracted contour: 以下是提取轮廓的一些示例:
1234

edit: @Haris: 编辑:@Haris:

i have tried a variant of your suggestion and it is doing the job for me: 我试过你的建议的一个变种,它正在为我做的工作:

R1R2R2

In the approximated contour i approach from the left, looking for the first angle with a value in a specified range, then the same from the right. 在近似轮廓i中,从左侧接近,查找具有指定范围内的值的第一个角度,然后从右侧查找相同的角度。 As the approximated contour points are a subset of the original contour points, I then identify the 2 corner points in the original sequence, and cut it at both corners. 由于近似轮廓点是原始轮廓点的子集,然后我识别原始序列中的2个角点,并在两个角处切割它。 The middle part i take as the droplet, and the left and right part, i reassamble to be my surface line. 中间部分我作为液滴,左右部分,我重新定位为我的表面线。 There might be better, more stable approaches, but this works for me. 可能有更好,更稳定的方法,但这对我有用。 Thanks! 谢谢!

You can try this approach, 你可以尝试这种方法,

  1. Find contour and approxPolyDP. 查找轮廓和近似值。

  2. Suppose you got approxPolyDP point like P1,P2,P3 etc... 假设您有像P1,P2,P3等大约的点...

  3. Now calculate angle between consecutive line, that is angle between line(P1,P2), line(P2,P3) etc.. and check the difference in angle for each adjustment line, if the difference comes close to 90 degree you can say there is a corner. 现在计算连续线之间的角度,即线(P1,P2),线(P2,P3)之间的角度等。并检查每条调整线的角度差异,如果差值接近90度你可以说那里是一个角落。

For Angle you can use the equation 对于角度,您可以使用等式

double Angle = atan2(y2 - y1, x2 - x1) * 180.0 / CV_PI; 

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

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