OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to detect a rectangular contour with opencv

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Guest
i am trying to determine the bounding rectangle (position and rotation) for a mainly rectangular shaped contour using OpenCV and python. There is one problem: Parts of the background interfere with the rectangle.

Does anyone have an idea, what else, i could try?

I have tried the following:


  • A closing with different kernel sizes and number of interations -> The rectangular shape was destroyed before all the noise was gone


  • Iterating over the image and all possible 180 degrees of rotation and trying to find the rectangle position and rotation that contains the most white pixels. (This is possible since i know the size of the rectangle. But it was extremely slow and not that precise)


  • Feature Matching (wasnt expecting much, and didnt work at all)


  • Edge detection


  • Contour Approximation with a Polygon with 4 Points

Testimages Images are the following:


Many thanks for your help in advance!
<p>i am trying to determine the bounding rectangle (position and rotation) for a mainly rectangular shaped contour using OpenCV and python. There is one problem: Parts of the background interfere with the rectangle.</p>
<p>Does anyone have an idea, what else, i could try?</p>
<p>I have tried the following:</p>
<ul>
<li><p>A closing with different kernel sizes and number of interations -> The rectangular shape was destroyed before all the noise was gone</p>
</li>
<li><p>Iterating over the image and all possible 180 degrees of rotation and trying to find the rectangle position and rotation that contains the most white pixels. (This is possible since i know the size of the rectangle. But it was extremely slow and not that precise)</p>
</li>
<li><p>Feature Matching (wasnt expecting much, and didnt work at all)</p>
</li>
<li><p>Edge detection</p>
</li>
<li><p>Contour Approximation with a Polygon with 4 Points</p>
</li>
</ul>
<p>Testimages Images are the following:</p>
<ul>
<li><a href="https://i.sstatic.net/wiw0HupY.png" rel="nofollow noreferrer">Testimage1</a></li>
<li><a href="https://i.sstatic.net/fm5Mal6t.png" rel="nofollow noreferrer">Testimage2</a></li>
<li><a href="https://i.sstatic.net/KnSzn2aG.png" rel="nofollow noreferrer">Testimage3</a></li>
<li><a href="https://i.sstatic.net/I0s1gaWk.png" rel="nofollow noreferrer">Testimage4</a></li>
<li><a href="https://i.sstatic.net/M6WYfdup.png" rel="nofollow noreferrer">Testimage5</a></li>
</ul>
<p>Many thanks for your help in advance!</p>
 

Latest posts

Top