Reputation: 933
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:
edit: @Haris:
i have tried a variant of your suggestion and it is doing the job for me:
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!
Upvotes: 3
Views: 10481
Reputation: 14053
You can try this approach,
Suppose you got approxPolyDP point like P1,P2,P3 etc...
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;
Upvotes: 9