Skip to main content

Python application for Unity Asset of 2D motion capture

Project description

2D Motion Capture for Unity

License: MIT PyPI version

2D Motion Capture for Unity is a python application designed to be a complement of the Unity asset, 2D Motion Capture. This asset enables an easy construction of 2D sprite animations in Unity by a completely device-less motion capture technique, and this application plays a role in analyzing a video file to capture the posture of a human in the video. The extraction of the posture from the human image is implemented using OpenCV and torchvision. With this application, you can easily build a sophisticated animation clip for your Unity project without any need of special equipments, and once the animation is generated, you can freely modify the clips the same way you deal with generic Unity animation.

Features

  • Commandline tool for video analysis and a direct connection to Unity Project
  • Simple video editor used for preparation of source video
  • Extracts human posture using a deep learning model of keypoint RCNN in torchvision
  • Exports posture information to a json file
  • Generates Unity animation clip on the editor environment
  • Easy save & load system for the sprite rigging on Unity

Installation

$ pip install unity-2dmocap

To update the application to the latest version, you can run:

$ pip install --upgrade unity-2dmocap

To check if the application is installed properly, you can try the following:

$ python
>>> import mocap2d
>>> mocap2d.__version__

If it prints out something without an error, the application is installed properly.

Unity Asset

To use this package, you need a 2D Motion Capture asset, which is a counterpart of this package. You can find the asset in the Unity Asset Store.

Usage

Once you have installed the package, you can use the features through a commandline.

$ 2dmocap-unity [-h] { detect, send } -f FILE [-g] [-i INTERVAL] [-s] [-o OUT]

The commands you can use are "detect" and "send". "detect" will analyze the video file and connect to the Unity project. "send" will read the pre-generated json file to the Unity Project without an analysis.

If you are using "detect", the arguments are:

  • -h, --help: show the help message
  • -f FILE, --file FILE: a path to the video file that you want to analyze
  • -g, --gpu: with this argument, the program will run on the gpu instance for a faster analysis
  • -i INTERVAL, --interval INTERVAL: a target interval between animation keyframes in seconds
  • -s, --show: with this argument, the program will show the resulting skeleton during the analysis
  • -o OUT, -output OUT: a directory in which you will save result.json file for the later use

If you are using "send", the arguments are:

  • -f FILE, --file FILE: a path to the json file you want to send

QuickStart

Suppose you want to analyze the video file named "ballet.mp4," and you want to quickly analyze it using the gpu of your machine. In addition, you want to have 0.2 seconds of intervals between keyframes. Then, the following command will start the program.

$ 2dmocap-unity detect --file=ballet.mp4 --gpu --interval=0.2 

Once you type the command, the program will initiate the analysis as follows.

You can wait until the analysis is over, and if you used the argument -s or --show, an external window will show up to show the progress of analysis by drawing a skeleton on the original image. After the analysis is complete, the program will address you to connect to the Unity project.

To connect to your Unity project, open your project on the Unity editor. If you have have successfully imported the "2D Motion Capture" asset, the menu will appear on Window/2D Motion Capture.

If you click on the menu, the following editor window will show up.

As addressed by the program, if you click on "Connect to the Detector" button, the unity will connect with your python session and receive information about the result of the analysis. Then, the window will let you preview the generated animation. If you click on the button "Save Animation Clip", the generated animation clip will be saved to the directory you specify.

Once the animation is generated, you can edit the clip just the same way you edit generic unity animation clips.

Community and Feedback

2D Motion Capture for Unity is an open-source project and we encourage and welcome contribution. We are waiting for the active participation of game developers, animation artists, and the fans of machine learning technology, so if you wish to contribute, please feel free to send pull requests or report issues.

For any further feedback or bug report, please you github's issue template or make a review on the Asset Store page.

Your participation matters a great deal to us.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unity-2dmocap-0.1.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

unity_2dmocap-0.1.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file unity-2dmocap-0.1.2.tar.gz.

File metadata

  • Download URL: unity-2dmocap-0.1.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10

File hashes

Hashes for unity-2dmocap-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f218b59005b21c0737b26a3d40957aebb7bcec23468dd44c5d7b1adbe8a1dd91
MD5 71eea6d532ad686ba191559aef6035bd
BLAKE2b-256 132c8e78f2fe8c82758123e39922a0a76b53c672dfe40c7ac21f446fde185c27

See more details on using hashes here.

File details

Details for the file unity_2dmocap-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: unity_2dmocap-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10

File hashes

Hashes for unity_2dmocap-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 670677b7ad1aa1fed24db5c1c07ef04e7eb8f928a20f27c1233eec2793521e06
MD5 3e44ba014db039044f7fc19f66ff34b8
BLAKE2b-256 b8ba6ca1d4433f299fd1fa102053ca77addec9c2683d378f167c3b1125d1e3c3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page