# Opencv python irregular square detection

**URL:** <https://forum.opencv.org/t/opencv-python-irregular-square-detection/15719>\
**Category:** Python\
**Created:** [December 4, 2023, 7:05am UTC](https://forum.opencv.org/t/opencv-python-irregular-square-detection/15719 "2023-12-04T07:05:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MobileRobotics](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mobilerobotics/32/8060_2.png) [@MobileRobotics](https://forum.opencv.org/u/MobileRobotics)\
**Post date:** [December 4, 2023, 7:05am UTC](https://forum.opencv.org/t/opencv-python-irregular-square-detection/15719/1 "2023-12-04T07:05:27Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/e/ebf490945eaaec7f0c09f8e1f2a4c2e7eb343ab2.jpeg)  
I want to detect the part marked in the red square.  
The two on the right were successful using findcontours.  
However, the one on the left is recognized as a large lump.

[![Imgur](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/7/77b293756886ddb28e4158e68590a550722bdeba.png "imgur.com") ](https://imgur.com/niAIg0Q)

---

<div class="post-metadata">

**Author:** ![lwzbuaa](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@lwzbuaa](https://forum.opencv.org/u/lwzbuaa)\
**Post date:** [December 10, 2023, 1:51am UTC](https://forum.opencv.org/t/opencv-python-irregular-square-detection/15719/2 "2023-12-10T01:51:42Z")

</div>

this can be solved by Template match,if needed,you can scale the template to be matched in mutli-scale image resolution!

---

<div class="post-metadata">

**Author:** ![MobileRobotics](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mobilerobotics/32/8060_2.png) [@MobileRobotics](https://forum.opencv.org/u/MobileRobotics)\
**Post date:** [December 10, 2023, 11:25pm UTC](https://forum.opencv.org/t/opencv-python-irregular-square-detection/15719/3 "2023-12-10T23:25:21Z")

</div>

I tried template matching but it didn’t work.
