Kinect / PyKinect2

Wrapper to expose Kinect for Windows v2 API in Python
MIT License
496 stars 236 forks source link

How do i get the Euler Angle of a joint? #92

Open 1234562123 opened 3 years ago

1234562123 commented 3 years ago

I can currently get the 3D coordinates of the hand by following code Self. X = joints [PyKinectV2. JointType_HandRight] Position. X Self. Y = joints [PyKinectV2. JointType_HandRight] Position. Y self.z = joints[PyKinectV2.JointType_HandRight].Position.z But I also want to get the attitude of the hand joint and the Euler Angle, how do I code it?

KonstantinosAng commented 3 years ago

You can get the quaternions of a joint:

# Find Joint Quaternions of Wrist Right

qx = body.joint_orientations[PyKinectV2. JointType_HandRight].Orientation.x
qy = body.joint_orientations[PyKinectV2. JointType_HandRight].Orientation.y
qz = body.joint_orientations[PyKinectV2. JointType_HandRight].Orientation.z
qw = body.joint_orientations[PyKinectV2. JointType_HandRight].Orientation.w

where body is kinect.get_last_body_frame().bodies[bodyID]

and then you can use the transformations library to get the euler angles:

import transformations

(roll, pitch, yaw) = transformations.euler_from_quaternion([qx, qy, qz, qw])