0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

Jetson NanoにGPU版のMediapipeをインストールする方法です。
OpenCVがインストールされているのが前提となるため、OpenCVをまだインストールしていない場合はJetson NanoにOpenCVをインストール方法を確認し、OpenCVをインストールしてください。

環境

Module: NVIDIA Jetson Nano 4GB ram
Jetpack 4.6.1
Ubuntu 18.04 Bionic Beaver
Python 3.6.9
OpenCV 4.8.0

インストール手順

sudo apt-get update && sudo apt-get upgrade

依存関係をダウンロードする

sudo apt-get install -y \
    git \
    curl \
    unzip \
    libhdf5-serial-dev  \
    hdf5-tools  \
    libhdf5-dev  \
    zlib1g-dev  \
    zip \
    libjpeg8-dev  \
    liblapack-dev  \
    libblas-dev  \
    gfortran \
    libopencv-core-dev  \
    libopencv-highgui-dev  \
    libopencv-calib3d-dev  \
    libopencv-features2d-dev  \
    libopencv-imgproc-dev  \
    libopencv-video-dev
pip3 install -U pip testresources setuptools==49.6.0
pip3 install -U --no-deps numpy==1.19.4 future==0.18.2 mock==3.0.5 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.4.0 protobuf pybind11 cython pkgconfig

シェルスクリプトファイルのあるリポジトリをクローンし、実行

git clone https://github.com/PINTO0309/mediapipe-bin
cd mediapipe-bin
./v0.8.5/download.sh

パッケージの解凍

unzip v0.8.5.zip -d v0.8.5

Mediapipeのインストール

sudo pip3 install v0.8.5/v0.8.5/numpy119x/py36/mediapipe-0.8.5_cuda102-cp36-cp36m-linux_aarch64.whl
pip3 install dataclasses

これでMediapipeをインストールすることができます。
カメラを接続し、以下のテストコードを実行してみてください。

import time

import cv2
import mediapipe as mp

video_source = "/dev/video0"  # Use a webcam
# video_source = "test_video.mp4"  # Path to video file

# Initialize MediaPipe Pose and Drawing utilities
mp_pose = mp.solutions.pose
mp_drawing = mp.solutions.drawing_utils
pose = mp_pose.Pose()

# Open the video file
cap = cv2.VideoCapture(video_source)
time.sleep(2)

while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break

    # Convert the frame to RGB
    frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    # Process the frame with MediaPipe Pose
    result = pose.process(frame_rgb)

    # Draw the pose landmarks on the frame
    if result.pose_landmarks:
        mp_drawing.draw_landmarks(frame, result.pose_landmarks, mp_pose.POSE_CONNECTIONS)

    # Display the frame
    cv2.imshow('MediaPipe Pose', frame)

    # Exit if 'q' keypyt
    cv2.waitKey(1)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?