user2950911 user2950911 - 1 year ago 293
C++ Question

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). I'd appreciate any suggestions.

Here are some examples of the extracted contour:

1 2 3 4


i have tried a variant of your suggestion and it is doing the job for me:

r1 r2 r2

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

Answer Source

You can try this approach,

  1. Find contour and approxPolyDP.

  2. Suppose you got approxPolyDP point like P1,P2,P3 etc...

  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.

For Angle you can use the equation

double Angle = atan2(y2 - y1, x2 - x1) * 180.0 / CV_PI; 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download