0

I'm starting in OpenCV in Python. I made a code that can detect your face, eyes and smile. I need to get the rotation based on the position of eyes/points.

Example:

enter image description here

Is there any way of doing this with Python?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Auax
  • 346
  • 2
  • 11
  • Just use the proper cyclometric function from `numpy` (`arccos` for example). You do know how to calculate the length of that line and differences along X/Y axis? – Michał Szydłowski Jul 04 '20 at 11:30

1 Answers1

1

If you have X and Y of 2 points you can use atan2 function. You can read more about it here: https://en.wikipedia.org/wiki/Atan2

Your code to calculate the angle between the points will go like this:

deltaY = point1_y - point2_y 
deltaX = point1_x - point2_x
my_radians = math.atan2(deltaY , deltaX)

If you want to convert radians to degrees

my_degrees = math.degrees(my_radians)

To convert from degrees to radians

my_radians = math.radians(my_degrees)
xszym
  • 928
  • 1
  • 5
  • 11