Skip to content

Instantly share code, notes, and snippets.

@AdroitAnandAI
Last active September 21, 2020 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdroitAnandAI/2003fe860c3a6184449e47945e776aa0 to your computer and use it in GitHub Desktop.
Save AdroitAnandAI/2003fe860c3a6184449e47945e776aa0 to your computer and use it in GitHub Desktop.
Euler to Cartesian Conversion
# yaw and pitch are important for mouse control
poseArrowX = orientation[0] #* arrowLength
poseArrowY = orientation[1] #* arrowLength
# Taking 2nd and 3rd row for 2D Projection
############################# LEFT EYE ###################################
cv2.arrowedLine(frame, leftEye_Center,
(int((xCenter_left + arrowLength * (cosR * cosY + sinY * sinP * sinR))),
int((yCenter_left + arrowLength * cosP * sinR))), (255, 0, 0), 4)
# center to top
cv2.arrowedLine(frame, leftEye_Center,
(int(((xCenter_left + arrowLength * (sinY * sinP * cosR - cosY * sinR)))),
int((yCenter_left + arrowLength * cosP * cosR))), (0, 0, 255), 4)
center to forward
cv2.arrowedLine(frame, leftEye_Center, \
(int(((xCenter_left + arrowLength * sinY * cosP))), \
int((yCenter_left - arrowLength * sinP))), (0, 255, 0), 4)
############################# RIGHT EYE ###################################
cv2.arrowedLine(frame, rightEye_Center,
(int((xCenter_right + arrowLength * (cosR * cosY + sinY * sinP * sinR))),
int((yCenter_right + arrowLength * cosP * sinR))), (255, 0, 0), 4)
# center to top
cv2.arrowedLine(frame, rightEye_Center,
(int(((xCenter_right + arrowLength * (sinY * sinP * cosR - cosY * sinR)))),
int((yCenter_right + arrowLength * cosP * cosR))), (0, 0, 255), 4)
center to forward
cv2.arrowedLine(frame, rightEye_Center,
(int(((xCenter_right + arrowLength * sinY * cosP))),
int((yCenter_right - arrowLength * sinP))), (0, 255, 0), 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment