# How to get angle of an contour in 360 degree

**URL:** <https://forum.opencv.org/t/how-to-get-angle-of-an-contour-in-360-degree/6468>\
**Category:** C++\
**Created:** [November 29, 2021, 8:53am UTC](https://forum.opencv.org/t/how-to-get-angle-of-an-contour-in-360-degree/6468 "2021-11-29T08:53:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![G\_Balaji](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/g_balaji/32/3745_2.png) [@G\_Balaji](https://forum.opencv.org/u/G_Balaji)\
**Post date:** [November 29, 2021, 8:53am UTC](https://forum.opencv.org/t/how-to-get-angle-of-an-contour-in-360-degree/6468/1 "2021-11-29T08:53:44Z")

</div>

Hi , I am Trying to detect shape of an object and its angle from an image .By using those angle and contour data ,I have to rotate rectangle region with corresponding to contours angle in 360 degree but by using

`double d\_match=cv::matchShapes(contours[0],contours\_search[i],1,0.0);

cv::RotatedRect minRect = minAreaRect( contours\_search[ki] );`  
I am only getting an angle within range of 0-90 degree.if the object in image is in certain angel then I need to rotate rectangle region with respect to contour angle .  
Please provide me some possible solution .

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [November 29, 2021, 9:24am UTC](https://forum.opencv.org/t/how-to-get-angle-of-an-contour-in-360-degree/6468/2 "2021-11-29T09:24:24Z")

</div>

> [@G\_Balaji](#):
>
> Please provide me some possible solution

there is none. [arctan](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) repeats in -90° … +90°

---

<div class="post-metadata">

**Author:** ![G\_Balaji](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/g_balaji/32/3745_2.png) [@G\_Balaji](https://forum.opencv.org/u/G_Balaji)\
**Post date:** [November 29, 2021, 9:41am UTC](https://forum.opencv.org/t/how-to-get-angle-of-an-contour-in-360-degree/6468/3 "2021-11-29T09:41:50Z")

</div>

by using [arctan](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) , I am able to get -90° to +90° but Ineed to get angle in 360°.  
in my application i have to extract data of contour in register image and store it,in real time I am also need to extract contour data from camera image and need to calculate the angle of contour is change from register image then I have to compute rectangle region angle with respect to changed contour angle

---

<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:** [November 29, 2021, 10:29pm UTC](https://forum.opencv.org/t/how-to-get-angle-of-an-contour-in-360-degree/6468/4 "2021-11-29T22:29:31Z")

</div>

> **[atan2](https://en.wikipedia.org/wiki/Atan2)**
>
> The function 
>   
>     
>       
> atan2
> ⁡
> (
> y
> ,
> x
> )
>       
>     
> {\\displaystyle \\operatorname {atan2} (y,x)}
>   
> or 
>   
>     
>       
> arctan2
> ⁡
> (
> y
> ,
> x
> )
>       
>     
> {\\displaystyle \\operatorname {arctan2} (y,x)}
>   
> (from "2-argument arctangent") is defined as the angle in the Euclidean plane, given in radians, between the positive x axis and the ray to the point (x, y) ≠ (0, 0).
> The f...
