Ask Your Question

Revision history [back]

How to avoid contours of different shapes to combine

Using opencv along with python, I'm trying to _extract a contour of a triangle inside a square_. With my camera being at a distance of aprox 30 cm from this picture, everything works ok.

image description

As I go away from the image, the black "border" around the triangle get smaller and smaller resulting in this:

image description

What should I do in order to reconstruct the sape of the triangle? The problem is that if my background is white (after applying binary filter) the triangle will be combined with it (resulting in one contour only). I was thinking about Morphology operations but I don't know what Structuring Element should I use or how to do it. I have read about it but I don't know how to get started ( the order of operations )

How to avoid contours of different shapes to combine

Using opencv along with python, I'm trying to _extract extract a contour of a triangle inside a square_. square. With my camera being at a distance of aprox 30 cm from this picture, everything works ok.

image description

As I go away from the image, the black "border" around the triangle get smaller and smaller resulting in this:

image description

What should I do in order to reconstruct the sape of the triangle? The problem is that if my background is white (after applying binary filter) the triangle will be combined with it (resulting in one contour only). I was thinking about Morphology operations but I don't know what Structuring Element should I use or how to do it. I have read about it but I don't know how to get started ( the order of operations )