打印
[STM32N6]

视觉识别案例2-人体姿态估计库 mediapipe

[复制链接]
505|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 一路向北lm 于 2025-4-3 16:37 编辑

Mediapipe 是一个开源的跨平台框架,它提供了大量的解决方案,用于构建高性能、跨平台的计算机视觉应用。Mediapipe 使用计算图(Calculation Graph)来表示算法的执行流程,可以轻松地组合和扩展不同的算法模块。板卡出厂的demo中展示的就是mediapipe的姿态检测。


人脸检测
mp_face_detection = mp.solutions.face_detection
# 创建 FaceDetection 类实例
face_detection = mp_face_detection.FaceDetection()
# 读取图像
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# 检测图像中的人脸
results = face_detection.process(img_rgb)
# 绘制人脸矩形框
if results.detections:
    for detection in results.detections:
        mp_drawing.draw_detection(img, detection)<span style="color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 255);">手势识别</span>
手势识别
mp_hands = mp.solutions.hands
# 创建 Hand 类实例
hands = mp_hands.Hands()
# 读取图像
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# 处理图像
results = hands.process(img_rgb)
# 绘制手势关键点
if results.multi_hand_landmarks:
    for hand_landmarks in results.multi_hand_landmarks:
        mp_drawing.draw_landmarks(
            img,
            hand_landmarks,
            mp_hands.HAND_CONNECTIONS,
        )
姿态估计
mp_pose = mp.solutions.pose
# 创建 Pose 类实例
pose = mp_pose.Pose()
# 读取图像
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# 处理图像
results = pose.process(img_rgb)
# 绘制姿态关键点
if results.pose_landmarks:
    mp_drawing.draw_landmarks(
        img,
        results.pose_landmarks,
        mp_pose.POSE_CONNECTIONS,
    )


使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

293

主题

3836

帖子

80

粉丝