# MediaPipe Unity Plugin
This is a Unity (2021.3.18f1) [Native Plugin](https://docs.unity3d.com/Manual/NativePlugins.html) to use [MediaPipe](https://github.com/google/mediapipe) (0.9.1).
The goal of this project is to port the MediaPipe API (C++) _one by one_ to C# so that it can be called from Unity.\
This approach may sacrifice performance when you need to call multiple APIs in a loop, but it gives you the flexibility to use MediaPipe instead.
With this plugin, you can
- Write MediaPipe code in C#.
- Run MediaPipe's official solution on Unity.
- Run your custom `Calculator` and `CalculatorGraph` on Unity.
- :warning: Depending on the type of input/output, you may need to write C++ code.
## :smile_cat: Hello World!
Here is a Hello World! example.\
Compare it with [the official code](https://github.com/google/mediapipe/blob/cf101e62a9d49a51be76836b2b8e5ba5c06b5da0/mediapipe/examples/desktop/hello_world/hello_world.cc)!
```cs
using Mediapipe;
using UnityEngine;
public sealed class HelloWorld : MonoBehaviour
{
private const string _ConfigText = @"
input_stream: ""in""
output_stream: ""out""
node {
calculator: ""PassThroughCalculator""
input_stream: ""in""
output_stream: ""out1""
}
node {
calculator: ""PassThroughCalculator""
input_stream: ""out1""
output_stream: ""out""
}
";
private void Start()
{
var graph = new CalculatorGraph(_ConfigText);
var poller = graph.AddOutputStreamPoller<string>("out").Value();
graph.StartRun().AssertOk();
for (var i = 0; i < 10; i++)
{
graph.AddPacketToInputStream("in", new StringPacket("Hello World!", new Timestamp(i))).AssertOk();
}
graph.CloseInputStream("in").AssertOk();
var packet = new StringPacket();
while (poller.Next(packet))
{
Debug.Log(packet.Get());
}
graph.WaitUntilDone().AssertOk();
}
}
```
For more detailed usage, see [the API Overview](https://github.com/homuler/MediaPipeUnityPlugin/wiki/API-Overview) page or the tutorial on [the Getting Started page](https://github.com/homuler/MediaPipeUnityPlugin/wiki/Getting-Started).
## :hammer_and_wrench: Installation
This repository **does not contain required libraries** (e.g. `libmediapipe_c.so`, `Google.Protobuf.dll`, etc).\
You can download them from [the release page](https://github.com/homuler/MediaPipeUnityPlugin/releases) instead.
| file | contents |
| :-----------------------------------: | :----------------------------------------------------------------------------------------------------------------: |
| `MediaPipeUnityPlugin-all.zip` | All the source code with required libraries. If you need to run sample scenes on your mobile devices, prefer this. |
| `com.github.homuler.mediapipe-*.tgz` | [A tarball package](https://docs.unity3d.com/Manual/upm-ui-tarball.html) |
| `MediaPipeUnityPlugin.*.unitypackage` | A `.unitypackage` file |
If you want to customize the package or minify the package size, you need to build them by yourself.\
For a step-by-step guide, please refer to the [Installation Guide](https://github.com/homuler/MediaPipeUnityPlugin/wiki/Installation-Guide) on Wiki.\
You can also make use of [the Package Workflow](https://github.com/homuler/MediaPipeUnityPlugin/blob/master/.github/workflows/package.yml) on Github Actions after forking this repository.
> :warning: libraries that can be built differ depending on your environment.
### Supported Platforms
> :warning: GPU mode is not supported on macOS and Windows.
| | Editor | Linux (x86_64) | macOS (x86_64) | macOS (ARM64) | Windows (x86_64) | Android | iOS | WebGL |
| :------------------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :---: |
| Linux (AMD64) [^1] | :heavy_check_mark: | :heavy_check_mark: | | | | :heavy_check_mark: | | |
| Intel Mac | :heavy_check_mark: | | :heavy_check_mark: | | | :heavy_check_mark: | :heavy_check_mark: | |
| M1 Mac | :heavy_check_mark: | | | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
| Windows 10/11 (AMD64) [^2] | :heavy_check_mark: | | | | :heavy_check_mark: | :heavy_check_mark: | | |
[^1]: Tested on Arch Linux.
[^2]: Running MediaPipe on Windows is [experimental](https://google.github.io/mediapipe/getting_started/install.html#installing-on-windows).
## :plate_with_cutlery: Try the sample app
### Example Solutions
Here is a list of [solutions](https://google.github.io/mediapipe/solutions/solutions.html) that you can try in the sample app.
> :bell: The graphs you can run are not limited to the ones in this list.
| | Android | iOS | Linux (GPU) | Linux (CPU) | macOS (CPU) | Windows (CPU) | WebGL |
| :---------------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | ----- |
| Face Detection | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Face Mesh | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Iris | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Hands | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Pose | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Holistic | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Selfie Segmentation | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Hair Segmentation | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
| Object Detection | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
### UnityEditor
Select `Mediapipe/Samples/Scenes/Start Scene` and play.
### Desktop
If you've built native libraries for CPU (i.e. `--desktop cpu`), select `CPU` for inference mode from the Inspector Window.
![preferable-inference-mode](https://user-images.githubusercontent.com/4690128/134795568-156f3d41-b46e-477f-a487-d04c99300c33.png)
### Android, iOS
Make sure that you select `GPU` for inference mode before building the app, because `CPU` inference mode is not supported currently.
## :book: Wiki
https://github.com/homuler/MediaPipeUnityPlugin/wiki
## :scroll: LICENSE
[MIT](https://github.com/homuler/MediaPipeUnityPlugin/blob/master/LICENSE)
Note that some files are distributed under other licenses.
- MediaPipe ([Apache Licence 2.0](https://github.com/google/mediapipe/blob/e6c19885c6d3c6f410c730952aeed285279
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
MediaPipeUnityPlugin-all (1359个子文件)
mediapipe_android.aar 239.39MB
Mediapipe.Runtime.Tests.asmdef 580B
Mediapipe.Runtime.asmdef 496B
ProjectSettings.asset 21KB
InputManager.asset 6KB
QualitySettings.asset 5KB
GraphicsSettings.asset 2KB
Physics2DSettings.asset 2KB
EditorBuildSettings.asset 2KB
NavMeshAreas.asset 1KB
MemorySettings.asset 1KB
DynamicsManager.asset 1KB
EditorSettings.asset 1KB
PackageManagerSettings.asset 1003B
UnityConnectSettings.asset 901B
AudioManager.asset 416B
TagManager.asset 395B
VFXManager.asset 308B
TimeManager.asset 195B
VersionControlSettings.asset 188B
XRSettings.asset 158B
NetworkManager.asset 151B
PresetManager.asset 146B
ClusterInputManager.asset 114B
.bazelrc 3KB
.bazelversion 6B
BUILD 18KB
BUILD 12KB
opencv.BUILD 7KB
BUILD 5KB
BUILD 5KB
BUILD 5KB
BUILD 5KB
BUILD 4KB
BUILD 4KB
BUILD 4KB
BUILD 3KB
BUILD 3KB
BUILD 2KB
BUILD 2KB
BUILD 2KB
opencv_linux.BUILD 2KB
BUILD 2KB
BUILD 2KB
BUILD 2KB
opencv_windows.BUILD 1KB
ffmpeg_macos.BUILD 1KB
ffmpeg_linux.BUILD 1KB
BUILD 1KB
opencv_wasm.BUILD 1KB
BUILD 955B
BUILD 903B
BUILD 898B
BUILD 837B
BUILD 734B
BUILD 712B
unity.BUILD 691B
BUILD 637B
BUILD 558B
BUILD 474B
BUILD 200B
pose_landmark_heavy.bytes 26.43MB
pose_landmark_heavy.bytes 26.43MB
pose_landmark_full.bytes 6.14MB
pose_landmark_full.bytes 6.14MB
ssdlite_object_detection.bytes 5.96MB
ssdlite_object_detection.bytes 5.96MB
hand_landmark_full.bytes 5.23MB
hand_landmark_full.bytes 5.23MB
pose_detection.bytes 2.82MB
pose_detection.bytes 2.82MB
pose_landmark_lite.bytes 2.69MB
pose_landmark_lite.bytes 2.69MB
iris_landmark.bytes 2.52MB
iris_landmark.bytes 2.52MB
face_landmark_with_attention.bytes 2.38MB
face_landmark_with_attention.bytes 2.38MB
palm_detection_full.bytes 2.23MB
palm_detection_full.bytes 2.23MB
hand_landmark_lite.bytes 1.98MB
hand_landmark_lite.bytes 1.98MB
palm_detection_lite.bytes 1.89MB
palm_detection_lite.bytes 1.89MB
face_landmark.bytes 1.18MB
face_landmark.bytes 1.18MB
face_detection_full_range.bytes 1.03MB
face_detection_full_range.bytes 1.03MB
hair_segmentation.bytes 763KB
hair_segmentation.bytes 763KB
face_detection_full_range_sparse.bytes 661KB
face_detection_full_range_sparse.bytes 661KB
selfie_segmentation.bytes 244KB
selfie_segmentation.bytes 244KB
face_detection_short_range.bytes 224KB
face_detection_short_range.bytes 224KB
hand_recrop.bytes 121KB
hand_recrop.bytes 121KB
mediapipe_aar.bzl 3KB
android_configure.bzl 3KB
import_model.bzl 2KB
共 1359 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14
资源评论
eleven_mie
- 粉丝: 2
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 以简单、易用、高性能为目标、开源的时序数据库,支持Linux及Windows, Time Series Database.zip
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
- python-leetcode面试题解之第170题两数之和III数据结构设计-题解.zip
- python-leetcode面试题解之第168题Excel表列名称-题解.zip
- python-leetcode面试题解之第167题两数之和II输入有序数组-题解.zip
- python-leetcode面试题解之第166题分数到小数-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功