Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
yanchxx committed Dec 5, 2022
1 parent cd5fe68 commit 1d0ee1c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# custom
.DS_Store
test_data
dev

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 yoyo-nb
Copyright (c) 2022 yanch2116

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
109 changes: 64 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
# Blender addon for driving character
# CharacterDriven-BlenderAddon

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
![stars](https://img.shields.io/github/stars/yanch2116/CDBA.svg?style=flat)
![GitHub repo size](https://img.shields.io/github/repo-size/yanch2116/CDBA.svg)
![GitHub repo size](https://img.shields.io/github/repo-size/yanchxx/CDBA.svg)

This addon has two parts. The first part helps you get a 3D character that can be drived by ROMP. The second part is to drive a 3D character in Blender using ROMP based on image, video or webcam.
This addon helps you drive a 3D character in Blender using ROMP based on image, video or webcam and get a 3D character that can be drived by ROMP.

## Demo

- Use a video to drive a 3D character.
![image](demo/offline_animation.gif)

- Use webcam to drive a 3D character on a linux computer with GPU 1070.
![image](demo/webcam_linux_local.gif)

- Use webcam to drive a 3D character on a Macbook Pro connected to a linux server with GPU 1070.
![image](demo/webcam_mac_server.gif)
![webcam_linux_local](https://i.imgur.com/BGKjDkr.gif)

- Use webcam to drive a 3D character on a Macbook Pro connected to a linux server with GPU 1070. (Due to the network latency and program limitation in Blender python, the driving is not fluent.)

![webcam_mac_server](https://i.imgur.com/f8ZykuP.gif)

- Use a video to drive 3D characters.

<https://user-images.githubusercontent.com/38496769/187074564-621cd40e-6da4-4d17-839a-42bb676578d4.mp4>

- Use webcam to drive a 3D character on a Macbook Pro with CPU.
![image](demo/webcam_mac_local.gif)
<https://user-images.githubusercontent.com/38496769/187074566-96d89b59-4721-4ccd-9a6d-c13d4b146f71.mp4>

## Installation

### For Blender Addon
- Download [CharacterDriven-BlenderAddon]()
- Install the addon in Blender
- Check your 3d view and there should be two new menu item called CDBA and CATS
- Install opencv in Blender python

- Download the [addon.zip](https://github.com/yanchxx/CDBA/releases/download/v1.0/addon.zip).
- Install the addon in Blender.
- Check your 3d view and there should be a new menu item called CDBA.
- Install opencv in Blender python.

```Shell
# If your Blender python doesn't have pip, install pip first
# if your Blender python doesn't have pip, install pip first
/path/to/blender/python -m pip install opencv-python
```

### For Simple ROMP

```Shell
# If you want to use GPU, you need to install pytorch-gpu and cuda first.
# if you want to use GPU, you need to install pytorch-gpu and cuda first
pip install --upgrade setuptools numpy cython
pip install --upgrade simple-romp

# Test if romp run successfully.
romp --mode=video --show_largest -i=/path/to/video.mp4 -o=/path/to/results # For GPU
romp --mode=video --show_largest --onnx -i=/path/to/video.mp4 -o=/path/to/results # For CPU
# test if romp run successfully
romp --mode=video --show_largest -i=/path/to/video.mp4 -o=/path/to/results # for GPU
romp --mode=video --show_largest --onnx -i=/path/to/video.mp4 -o=/path/to/results # for CPU
```

## How To Use

A video tutorial is available [here]().

### Panel

![image](demo/ui.png)
![panel](https://i.imgur.com/LQGtecn.png)

Common

- Character: The character's object name.
- Armature: The character's armature name.
- IP: The IP address of the romp_server.
Expand All @@ -66,44 +67,62 @@ Common
- Fix Bones: Make mixamo rigged character compatible with ROMP.

Image or Video

- Offline Animation: Select your image or video file to drive your character.

Webcam

- FPS: The frame rate of the webcam.
- Width: The width of the webcam.
- Height: The height of the webcam.
- Webcam Animation: Open your webcam to drive your character.

### Make Your 3D Character Compatible with ROMP

- Use [mixamo auto-rigger](https://www.mixamo.com/#/) to rig your 3D character. Remember to select no fingers (25).
- Import the rigged 3D character to Blender.
- If your character is T-pose, skip this step. If your character is A-pose,
- install the [cats-blender-plugin](https://github.com/absolute-quantum/cats-blender-plugin) in Blender;
- select your character and go to `Pose Mode`;
- click the `CATS` tab, then click the `Apply as Rest Pose` button;
> All mixamo rigged characters are T-pose in Object Mode. You need to check whether your character's rest pose is A-pose or T-pose in Edit Mode.
- Click the `CDBA` tab, then click `Fix Bones` to make your character compatible with ROMP.
### Drive Your 3D Character

- Start Simple ROMP.
- Import the rigged 3D character and use [test_data.zip](https://github.com/yanchxx/CDBA/releases/download/v1.0/test_data.zip) for test.
- Start [romp_server.py](romp_server.py).

```Shell
python romp_server.py [port]
```

- Open Blender using command line.

```Shell
# if you start the software by clicking on its icon
# it will crash when using webcam animation
blender
```

- Make sure the settings are correct in Blender CDBA Panel
- Make sure your character object's and armature's name is same with the one in Common Panel.
- Make sure you can connect to the romp_server using the IP and Port in Common Panel.
- Other settings are optional, the default is fine.
- Click Offline Animation to use image or video to drive your character.
- Click Webcam Animation to use webcam to drive your character.
- Make sure your character object's and armature's name is same with the one in Common Panel.
- Make sure you can connect to the romp_server using the IP and Port in Common Panel.
- Other settings are optional, the default is fine.
- Set the number in the red box to specify the starting point for keyframe insertion.
![frame_start](https://i.imgur.com/s5fd1U3.png)
- Click `Offline Animation` to use image or video to drive your character.
- Click `Webcam Animation` to use webcam to drive your character.

> The Blender and romp_server.py is not necessary to be in the same computer. You can run romp_server.py on a linux server and use port forwarding to make the romp_server can be accessed from your local computer. A simple method is to use VS Code to set up port forwarding.
### Make Your 3D Character Compatible with ROMP

- Use [mixamo auto-rigger](https://www.mixamo.com/#/) to rig your 3D character. Remember to select no fingers (25).
- Import the rigged 3D character to Blender.
- If your character is T-pose, skip this step. If your character is A-pose,
- install the [cats-blender-plugin](https://github.com/absolute-quantum/cats-blender-plugin) in Blender;
- select your character and go to `Pose Mode`;
- click the `CATS` tab, then click the `Apply as Rest Pose` button.

> The Blender and romp_server is not necessary to be in the same computer. You can install romp_server on a linux server and use port forwarding to make the romp_server can be accessed from your local computer. A simple method is to use VS Code to set up port forwarding as I do in the video tutorial.
> All mixamo rigged characters are T-pose in Object Mode. You need to check whether your character's rest pose is A-pose or T-pose in Edit Mode.
- Click the `CDBA` tab, then click `Fix Bones` to make your character compatible with ROMP.

If you are familiar with Blender and want to use your own model, you should make sure it's armature is SMPL's skeleton. The armature should name Armature and each bone has the same name as the bones in [demo model](blender/Alpha.fbx)(Only the 24 bones of SMPL skeleton are needed, and the fingers don't need to change their names).
## Acknowledgement

- [模之屋](https://www.aplaybox.com/u/680828836)
- [ROMP](https://github.com/Arthur151/ROMP)
- [neuron_mocap_live-blender](https://github.com/pnmocap/neuron_mocap_live-blender)
- [QuickMocap-BlenderAddon](https://github.com/vltmedia/QuickMocap-BlenderAddon)
- [Mixamo](https://www.mixamo.com/#/)
- [模之屋](https://www.aplaybox.com/u/680828836)
- [cats-blender-plugin](https://github.com/absolute-quantum/cats-blender-plugin)
- [neuron_mocap_live-blender](https://github.com/pnmocap/neuron_mocap_live-blender)
- [QuickMocap-BlenderAddon](https://github.com/vltmedia/QuickMocap-BlenderAddon)
2 changes: 0 additions & 2 deletions addon/ops/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ def execute(self, ctx):
self.webcam = cv2.VideoCapture(0)
self.webcam.set(3, ctx.scene.width)
self.webcam.set(4, ctx.scene.height)
cv2.namedWindow("frame")
cv2.resizeWindow("frame",320, 240)

init = json.dumps(
{
Expand Down
1 change: 1 addition & 0 deletions romp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
warnings.filterwarnings('ignore')
os.environ['CUDA_VISIBLE_DEVICES'] = '0'


class NumpyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.integer):
Expand Down

0 comments on commit 1d0ee1c

Please sign in to comment.