# Contours shape detection

**URL:** <https://forum.opencv.org/t/contours-shape-detection/14507>\
**Category:** Python\
**Tags:** lidar, slam\
**Created:** [September 11, 2023, 9:05am UTC](https://forum.opencv.org/t/contours-shape-detection/14507 "2023-09-11T09:05:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FroPyx](https://avatars.discourse-cdn.com/v4/letter/f/f07891/32.png) [@FroPyx](https://forum.opencv.org/u/FroPyx)\
**Post date:** [September 11, 2023, 9:05am UTC](https://forum.opencv.org/t/contours-shape-detection/14507/1 "2023-09-11T09:05:44Z")

</div>

Hi,

I would like to detect and get the position of a template shape in a another image. The template and the shape in the image have the same size.

For example, here is one template (on right) and the image (on left) :

 ![template](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/d/d096f1008af050e23d20028061d8f53312600c04.png)

I must extract the position and rotation of the shape if it exists in the image. How can I manage this ?

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:** [September 11, 2023, 9:39am UTC](https://forum.opencv.org/t/contours-shape-detection/14507/2 "2023-09-11T09:39:26Z")

</div>

is that lidar? looks like lidar.

anyway, that’ll be a real challenge.

you’ll need to extract local features from both sets of data, then find matches.

no, SIFT/… are unlikely to work on this. they’re made for raster data, not point data.

you’ll want to come up with features like straight lines, curves, angles.

---

<div class="post-metadata">

**Author:** ![FroPyx](https://avatars.discourse-cdn.com/v4/letter/f/f07891/32.png) [@FroPyx](https://forum.opencv.org/u/FroPyx)\
**Post date:** [September 11, 2023, 11:26am UTC](https://forum.opencv.org/t/contours-shape-detection/14507/3 "2023-09-11T11:26:49Z")

</div>

Yes, that are lidar datas

---

<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:** [September 11, 2023, 4:00pm UTC](https://forum.opencv.org/t/contours-shape-detection/14507/4 "2023-09-11T16:00:10Z")

</div>

if you don’t know where to start, start by learning about SLAM (simultaneous localization and mapping).

that usually has a much richer “needle” to find (in the haystack), and it has a previous pose to refine continuously, so it usually doesn’t have to find its own location from scratch.

however, in that area of research, there might be approaches for locating/pose-estimating a subset of a point cloud in the larger point cloud.
