Giter Club home page Giter Club logo

kazuhito00 / mediapipe-python-sample Goto Github PK

View Code? Open in Web Editor NEW
291.0 7.0 84.0 561 KB

MediaPipeのPythonパッケージのサンプルです。2021/12/14時点でPython実装のある7機能(Hands、Pose、Face Mesh、Holistic、Face Detection、Objectron、Selfie Segmentation)について用意しています。

License: Apache License 2.0

Python 100.00%
python mediapipe opencv hands pose facemesh face-detection objectron holistic mediapipe-python-sample

mediapipe-python-sample's Introduction

mediapipe-python-sample

MediaPipeのPythonパッケージのサンプルです。
2021/12/14時点でPython実装のある以下7機能について用意しています。

Requirement

  • mediapipe 0.8.8 or later
    ※旧バージョンのMediaPipeを使用する場合はTagsの旧コミット版を利用ください
  • OpenCV 3.4.2 or later
  • matplotlib 3.4.1 or later ※Pose/Holisticでplot_world_landmarkオプションを使用する場合のみ

mediapipeはpipでインストールできます。

pip install mediapipe

Demo

デモの実行方法は以下です。

Face Mesh

python sample_facemesh.py
  • --device
    カメラデバイス番号の指定
    デフォルト:0
  • --width
    カメラキャプチャ時の横幅
    デフォルト:960
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:540
  • --max_num_hands
    最大手検出数
    デフォルト:1
  • --refine_landmarks
    ATTENTION MESH MODELを使用するか否か ※目と口周りのランドマークがより正確になる
    デフォルト:指定なし
  • --min_detection_confidence
    検出信頼値の閾値
    デフォルト:0.5
  • --min_tracking_confidence
    トラッキング信頼値の閾値
    デフォルト:0.5
  • --use_brect
    外接矩形を描画するか否か
    デフォルト:指定なし

Hands

python sample_hand.py
  • --device
    カメラデバイス番号の指定
    デフォルト:0
  • --width
    カメラキャプチャ時の横幅
    デフォルト:960
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:540
  • --model_complexity
    モデルの複雑度(0:軽量 1:高精度)
    デフォルト:1
  • --max_num_faces
    最大顔検出数
    デフォルト:1
  • --min_detection_confidence
    検出信頼値の閾値
    デフォルト:0.7
  • --min_tracking_confidence
    トラッキング信頼値の閾値
    デフォルト:0.5
  • --use_brect
    外接矩形を描画するか否か
    デフォルト:指定なし
  • --plot_world_landmark
    World座標をmatplotlib表示する ※matplotlibを用いるため処理が重くなります
    デフォルト:指定なし

Pose

python sample_pose.py
  • --device
    カメラデバイス番号の指定
    デフォルト:0
  • --width
    カメラキャプチャ時の横幅
    デフォルト:960
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:540
  • --model_complexity
    モデルの複雑度(0:Lite 1:Full 2:Heavy)
    ※性能差はPose Estimation Qualityを参照ください
    デフォルト:1
  • --min_detection_confidence
    検出信頼値の閾値
    デフォルト:0.5
  • --min_tracking_confidence
    トラッキング信頼値の閾値
    デフォルト:0.5
  • --enable_segmentation
    人物セグメンテーションを有効化するか
    デフォルト:指定なし
  • --segmentation_score_th
    人物セグメンテーションの閾値
    デフォルト:0.5
  • --use_brect
    外接矩形を描画するか否か
    デフォルト:指定なし
  • --plot_world_landmark
    World座標をmatplotlib表示する ※matplotlibを用いるため処理が重くなります
    デフォルト:指定なし

Holistic

python sample_holistic.py
  • --device
    カメラデバイス番号の指定
    デフォルト:0
  • --width
    カメラキャプチャ時の横幅
    デフォルト:960
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:540
  • --model_complexity
    モデルの複雑度(0:Lite 1:Full 2:Heavy)
    ※性能差はPose Estimation Qualityを参照ください
    デフォルト:1
  • --min_detection_confidence
    検出信頼値の閾値
    デフォルト:0.5
  • --min_tracking_confidence
    トラッキング信頼値の閾値
    デフォルト:0.5
  • --enable_segmentation
    人物セグメンテーションを有効化するか
    デフォルト:指定なし
  • --unuse_smooth_landmarks
    人物セグメンテーションのスムース化を使用しない
    デフォルト:指定なし
  • --segmentation_score_th
    人物セグメンテーションの閾値
    デフォルト:0.5
  • --use_brect
    外接矩形を描画するか否か
    デフォルト:指定なし
  • --plot_world_landmark
    World座標をmatplotlib表示する ※matplotlibを用いるため処理が重くなります
    デフォルト:指定なし

Face Detection

python sample_facedetection.py
  • --device
    カメラデバイス番号の指定
    デフォルト:0
  • --width
    カメラキャプチャ時の横幅
    デフォルト:960
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:540
  • --model_selection
    モデル選択(0:2m以内の検出に最適なモデル、1:5m以内の検出に最適なモデル)
    デフォルト:0
  • --min_detection_confidence
    検出信頼値の閾値
    デフォルト:0.5

Objectron

python sample_objectron.py
  • --device
    カメラデバイス番号の指定
    デフォルト:0
  • --width
    カメラキャプチャ時の横幅
    デフォルト:960
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:540
  • --static_image_mode
    静止画像モード ※トラッキング無し
    デフォルト:指定なし
  • --min_detection_confidence
    検出信頼値の閾値
    デフォルト:0.5
  • --min_tracking_confidence
    トラッキング信頼値の閾値
    デフォルト:0.99
  • --model_name
    検出対象(20201/03/03時点:'Shoe', 'Chair', 'Cup', 'Camera'の4種類)
    デフォルト:Cup

Selfie Segmentation

python sample_selfie_segmentation.py
  • --device
    カメラデバイス番号の指定
    デフォルト:0
  • --width
    カメラキャプチャ時の横幅
    デフォルト:960
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:540
  • --model_selection
    モデル種類指定
    0:Generalモデル(256x256x1 出力)
    1:Landscapeモデル(144x256x1 出力)
    デフォルト:0
  • --score_th
    スコア閾値(閾値以上:人間、閾値未満:背景)
    デフォルト:0.1
  • --bg_path
    背景画像格納パス ※未指定時はグリーンバック
    デフォルト:None

For Raspberry Pi

以下のRaspberry Pi向けビルドを利用することで、Raspberry Pi上で本サンプルを試すことが出来ます。
mediapipe-bin は、v0.8.4 および v0.8.5のバージョンが提供されています。
mediapipe-python-sample は タグv0.8.4、v0.8.5のコードをご使用ください。

ToDo

  • Holisticのサンプル追加 (mediapipe 0.8.1)
  • Poseのz座標表示を追加 (mediapipe 0.8.3)
  • Face Detectionのサンプル追加 (mediapipe 0.8.3)
  • Objectronのサンプル追加 (mediapipe 0.8.3)

Reference

Author

高橋かずひと(https://twitter.com/KzhtTkhs)

License

mediapipe-python-sample is under Apache-2.0 License.

また、女性の画像、および背景画像はフリー素材ぱくたそ様の写真を利用しています。

mediapipe-python-sample's People

Contributors

kazuhito00 avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mediapipe-python-sample's Issues

Multi Person?

How to track many people, do you have any idea?
Thank you!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.