Welcome to RDK X5 Board repository
2.Attitude detection
2. Attitude detection
2.1 Introduction
MediaPipe is a data stream processing machine learning application development framework developed and open-source by Google. It is a graph based data processing pipeline used to build and utilize various forms of data sources, such as video, audio, sensor data, and any time series data. MediaPipe is cross platform and can run on embedded platforms (such as Raspberry Pi), mobile devices (iOS and Android), workstations, and servers, with support for mobile GPU acceleration. MediaPipe provides cross platform, customizable ML solutions for real-time and streaming media.
The core framework of MediaPipe is implemented in C++and provides support for languages such as Java and Objective C. The main concepts of MediaPipe include packets, streams, calculators, graphs, and subgraphs.
Features of MediaPipe
End to end acceleration: Built in fast ML inference and processing can accelerate even on regular hardware.
Build once, deploy anytime, anywhere: A unified solution suitable for Android, iOS, desktop/cloud, web, and IoT.
Ready to use solution: a cutting-edge ML solution that showcases all the functionalities of the framework.
Free and open-source: frameworks and solutions under Apache 2.0, fully extensible and customizable.
2.2 MediaPipe Pose**
MediaPipe Pose is an ML solution for high fidelity body pose tracking, utilizing BlazePose research to infer 33 3D coordinates and full body background segmentation masks from RGB video frames. This research also provides momentum for the ML Kit pose detection API.
The landmark model in the MediaPipe pose predicted the positions of 33 pose coordinates (see the figure below).

2.3 Pose detection
2.3.1、Start
Input following command in the terminal
ros2 run yahboomcar_mediapipe 02_PoseDetector

2.3.2、Code
Code path:~/orbbec_ws/src/yahboomcar_mediapipe/yahboomcar_mediapipe/02_PoseDetector.py
x#!/usr/bin/env python3# encoding: utf-8
#import ros libimport rclpyfrom rclpy.node import Nodefrom geometry_msgs.msg import Pointimport mediapipe as mp#import define msgfrom yahboomcar_msgs.msg import PointArray#import commom libimport cv2 as cvimport numpy as npimport timeprint("import done")
class PoseDetector(Node): def __init__(self, name,mode=False, smooth=True, detectionCon=0.5, trackCon=0.5): super().__init__(name) self.mpPose = mp.solutions.pose self.mpDraw = mp.solutions.drawing_utils self.pose = self.mpPose.Pose( static_image_mode=mode, smooth_landmarks=smooth, min_detection_confidence=detectionCon, min_tracking_confidence=trackCon ) self.pub_point = self.create_publisher(PointArray,'/mediapipe/points',1000) self.lmDrawSpec = mp.solutions.drawing_utils.DrawingSpec(color=(0, 0, 255), thickness=-1, circle_radius=6) self.drawSpec = mp.solutions.drawing_utils.DrawingSpec(color=(0, 255, 0), thickness=2, circle_radius=2)
def pubPosePoint(self, frame, draw=True): pointArray = PointArray() img = np.zeros(frame.shape, np.uint8) img_R