# Detection of geometric shapes based on contours

**URL:** https://forum.opencv.org/t/detection-of-geometric-shapes-based-on-contours/8501
**Category:** Python
**Tags:** object-detection
**Created:** [April 22, 2022, 12:23pm UTC](https://forum.opencv.org/t/detection-of-geometric-shapes-based-on-contours/8501 "2022-04-22T12:23:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Giacomo\_Zamprogno](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/giacomo_zamprogno/32/5076_2.png) [@Giacomo\_Zamprogno](https://forum.opencv.org/u/Giacomo_Zamprogno)
#### Post date: [April 22, 2022, 12:23pm UTC](https://forum.opencv.org/t/detection-of-geometric-shapes-based-on-contours/8501/1 "2022-04-22T12:23:14Z")

</div>

I am trying to implement a basic “greedy” heuristic for dissection puzzles like the tangram: given a geometric shape I would need to extract an area in a silhouette where such figure might fit, with a given degree of similarity, according to how much of its contour matches.

![example](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/d/d22eb409f3bdbe6d4d6092ff1b759d19ee2a0c69.png)  
For example in the picture there I’ve highlighted 2 placement for the triangle (I show 2, but there are probably 5) but the blue matches more contour/perimeter. I am aware it is unlikely to be an ideal heuristic, but I am more interested in the problem per se.

I thought about using shape-based matching (something derived from Steger 2002), but I am not sure it is the ideal approach here, and was trying to understand whether there is something more appropriate. Unluckily I am not an expert on computer vision and thus I am writing to ask whether there is a class of similar problems I can look into.  
Sorry if the question is a bit general an not code oriented, but after some googling I have realized I don’t know enough terminology to have proper searches.

Thank you in advance

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [April 22, 2022, 3:39pm UTC](https://forum.opencv.org/t/detection-of-geometric-shapes-based-on-contours/8501/2 "2022-04-22T15:39:58Z")

</div>

probably related to bin packing, knapsack, “cutting stock”… problems known in computer science
