pitch、yaw、roll三个角的区别

1 篇文章 0 订阅

Z轴正方向为前进方向

pitch():俯仰,将物体绕X轴旋转(localRotationX)

pitch yaw roll 的区别(转载) - 江南雨 - 江南雨的博客
yaw():航向,将物体绕Y轴旋转(localRotationY)

pitch yaw roll 的区别(转载) - 江南雨 - 江南雨的博客
roll():横滚,将物体绕Z轴旋转(localRotationZ)

pitch yaw roll 的区别(转载) - 江南雨 - 江南雨的博客

  • 58
    点赞
  • 168
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
以下是使用C++代码实现通过mediapipe 0.8.9计算右肩姿态的PitchYawRoll的示例: ``` #include <iostream> #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/formats/landmark.pb.h" #include "mediapipe/framework/formats/landmark_util.h" #include "mediapipe/framework/formats/image_frame.h" #include "mediapipe/framework/formats/image_frame_opencv.h" #include "mediapipe/framework/port/opencv_highgui_inc.h" #include "mediapipe/framework/port/opencv_imgproc_inc.h" namespace mediapipe { void CalculateShoulderRotation(const NormalizedLandmarkList& landmarks) { // Find the right shoulder landmark. const auto& right_shoulder = landmarks.landmark(12); // Find the right elbow landmark. const auto& right_elbow = landmarks.landmark(14); // Find the right wrist landmark. const auto& right_wrist = landmarks.landmark(16); // Calculate the shoulder, elbow and wrist positions in 3D space. cv::Vec3d shoulder_pos(right_shoulder.x(), right_shoulder.y(), right_shoulder.z()); cv::Vec3d elbow_pos(right_elbow.x(), right_elbow.y(), right_elbow.z()); cv::Vec3d wrist_pos(right_wrist.x(), right_wrist.y(), right_wrist.z()); // Calculate the vector from the shoulder to the elbow. cv::Vec3d shoulder_to_elbow = elbow_pos - shoulder_pos; // Calculate the vector from the elbow to the wrist. cv::Vec3d elbow_to_wrist = wrist_pos - elbow_pos; // Calculate the rotation matrix from the shoulder to the wrist. cv::Matx33d rotation_matrix = cv::Matx33d::zeros(); cv::Vec3d axis = shoulder_to_elbow.cross(elbow_to_wrist); double angle = std::acos(shoulder_to_elbow.dot(elbow_to_wrist) / (cv::norm(shoulder_to_elbow) * cv::norm(elbow_to_wrist))); cv::Rodrigues(axis * angle, rotation_matrix); // Extract the Pitch, Yaw and Roll angles from the rotation matrix. double pitch = std::atan2(rotation_matrix(2,1), rotation_matrix(2,2)); double yaw = std::atan2(-rotation_matrix(2,0), std::sqrt(rotation_matrix(2,1)*rotation_matrix(2,1) + rotation_matrix(2,2)*rotation_matrix(2,2))); double roll = std::atan2(rotation_matrix(1,0), rotation_matrix(0,0)); // Output the results. std::cout << "Right Shoulder Rotation: Pitch=" << pitch << ", Yaw=" << yaw << ", Roll=" << roll << std::endl; } } // namespace mediapipe int main() { // Load the image and landmarks. cv::Mat image = cv::imread("image.jpg"); NormalizedLandmarkList landmarks = ...; // Load or calculate the landmark data. // Calculate the right shoulder rotation. mediapipe::CalculateShoulderRotation(landmarks); return 0; } ``` 在这个示例中,我们使用mediapipe的`NormalizedLandmarkList`格式存储关键点(landmarks)数据,使用OpenCV进行向量和矩阵计算,并最终输出右肩的PitchYawRoll三个旋转度。需要注意的是,这只是一个简单的示例,实际应用中还需要考虑更多的因素,如姿态变化、噪声和误差等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值