Skip to content

Commit

Permalink
Merge pull request #1 from creativeIKEP/develop
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
creativeIKEP committed Jan 9, 2022
2 parents 33279c9 + 10878bc commit 21c7f98
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 125 deletions.
3 changes: 0 additions & 3 deletions Assets/Script/PoseVisuallizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class PoseVisuallizer : MonoBehaviour
[SerializeField] WebCamInput webCamInput;
[SerializeField] Shader shader;
[SerializeField] PoseDetectionResource poseDetectionResource;
[SerializeField] bool isUpperBodyOnly;

Material material;
PoseDetecter detecter;
Expand All @@ -33,8 +32,6 @@ public class PoseVisuallizer : MonoBehaviour
void OnRenderObject(){
// Get predicted pose detection result.
material.SetBuffer("_pds", detecter.outputBuffer);
// Select mode, "upper body only" or "full body".
material.SetInt("_upperBodyOnly", (isUpperBodyOnly ? 1 : 0));

// Set pose detection count as vertex shader instance count.
ComputeBuffer.CopyCount(detecter.outputBuffer, boxDrawArgs, sizeof(uint));
Expand Down
5 changes: 2 additions & 3 deletions Assets/Shader/Visualizer.shader
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#define PI 3.14159265359

uint _upperBodyOnly;
StructuredBuffer<PoseDetection> _pds;

float2x2 rot2D(float angle)
Expand Down Expand Up @@ -42,8 +41,8 @@
float2 hip = pd.keyPoints[0];
float2 shoulder = pd.keyPoints[2];

float2 center = _upperBodyOnly ? shoulder : hip;
float2 roi = _upperBodyOnly ? pd.keyPoints[3] : pd.keyPoints[1];
float2 center = hip;
float2 roi = pd.keyPoints[1];

float sizeX = abs(roi.x - center.x);
float sizeY = abs(roi.y - center.y);
Expand Down
5 changes: 5 additions & 0 deletions Packages/PoseDetectionBarracuda/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### [1.0.1] - 2022-01-09
- Supported ComputeBuffer input.

### [1.0.0] - 2021-05-17
This is the first release of `creativeIKEP/PoseDetectionBarracuda`(`jp.ikep.mediapipe.posedetection`).

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Packages/PoseDetectionBarracuda/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PoseDetectionBarracuda
![demo](/screenshot/demo.png)
![demo](https://user-images.githubusercontent.com/34697515/148678516-9b608be0-40a0-4c01-98da-c1c22d021cba.png)

PoseDetectionBarracuda is a human pose detecter that runs the [Mediapipe Pose](https://google.github.io/mediapipe/solutions/pose) Detection neural network model on the [Unity Barracuda](https://docs.unity3d.com/Packages/com.unity.barracuda@latest).

Expand All @@ -21,7 +21,7 @@ To the `scopedRegistries` section:
```
To the `dependencies` section:
```
"jp.ikep.mediapipe.posedetection": "1.0.0"
"jp.ikep.mediapipe.posedetection": "1.0.1"
```
Finally, the manifest file looks like below:
```
Expand All @@ -34,15 +34,16 @@ Finally, the manifest file looks like below:
}
],
"dependencies": {
"jp.ikep.mediapipe.posedetection": "1.0.0",
"jp.ikep.mediapipe.posedetection": "1.0.1",
...
}
}
```

### Install from GitHub URL
PoseDetectionBarracuda can be installed by adding below URL on the Unity Package Manager's window.
```
https://github.com/creativeIKEP/PoseDetectionBarracuda.git?path=Packages/PoseDetectionBarracuda#v1.0.0
https://github.com/creativeIKEP/PoseDetectionBarracuda.git?path=Packages/PoseDetectionBarracuda#v1.0.1
```

## Demo Image
Expand Down
14 changes: 9 additions & 5 deletions Packages/PoseDetectionBarracuda/Script/PoseDetecter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,21 @@ public class PoseDetecter: System.IDisposable
}

public void ProcessImage(Texture inputTexture, float poseThreshold = 0.75f, float iouThreshold = 0.3f){
// Reset append type buffer datas of previous frame.
postProcessBuffer.SetCounterValue(0);
outputBuffer.SetCounterValue(0);

// Resize `inputTexture` texture to network model image size.
preProcessCS.SetTexture(0, "_inputTexture", inputTexture);
preProcessCS.SetBuffer(0, "_output", networkInputBuffer);
preProcessCS.Dispatch(0, IMAGE_SIZE / 8, IMAGE_SIZE / 8, 1);

ProcessImage(networkInputBuffer, poseThreshold, iouThreshold);
}

public void ProcessImage(ComputeBuffer input, float poseThreshold = 0.75f, float iouThreshold = 0.3f){
// Reset append type buffer datas of previous frame.
postProcessBuffer.SetCounterValue(0);
outputBuffer.SetCounterValue(0);

//Execute neural network model.
var inputTensor = new Tensor(1, IMAGE_SIZE, IMAGE_SIZE, 3, networkInputBuffer);
var inputTensor = new Tensor(1, IMAGE_SIZE, IMAGE_SIZE, 3, input);
woker.Execute(inputTensor);
inputTensor.Dispose();

Expand Down
2 changes: 1 addition & 1 deletion Packages/PoseDetectionBarracuda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "jp.ikep.mediapipe.posedetection",
"displayName": "PoseDetectionBarracuda",
"description": "Mediapipe pose detection for Unity Barracuda",
"version": "1.0.0",
"version": "1.0.1",
"unity": "2020.3",
"unityRelease": "6f1",
"keywords": [
Expand Down
3 changes: 0 additions & 3 deletions Packages/PoseDetectionBarracuda/screenshot/demo.png

This file was deleted.

96 changes: 0 additions & 96 deletions Packages/PoseDetectionBarracuda/screenshot/demo.png.meta

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PoseDetectionBarracuda
![demo](/screenshot/demo.png)
![demo](https://user-images.githubusercontent.com/34697515/148678516-9b608be0-40a0-4c01-98da-c1c22d021cba.png)

PoseDetectionBarracuda is a human pose detecter that runs the [Mediapipe Pose](https://google.github.io/mediapipe/solutions/pose) Detection neural network model on the [Unity Barracuda](https://docs.unity3d.com/Packages/com.unity.barracuda@latest).

Expand All @@ -21,7 +21,7 @@ To the `scopedRegistries` section:
```
To the `dependencies` section:
```
"jp.ikep.mediapipe.posedetection": "1.0.0"
"jp.ikep.mediapipe.posedetection": "1.0.1"
```
Finally, the manifest file looks like below:
```
Expand All @@ -34,7 +34,7 @@ Finally, the manifest file looks like below:
}
],
"dependencies": {
"jp.ikep.mediapipe.posedetection": "1.0.0",
"jp.ikep.mediapipe.posedetection": "1.0.1",
...
}
}
Expand All @@ -43,7 +43,7 @@ Finally, the manifest file looks like below:
### Install from GitHub URL
PoseDetectionBarracuda can be installed by adding below URL on the Unity Package Manager's window.
```
https://github.com/creativeIKEP/PoseDetectionBarracuda.git?path=Packages/PoseDetectionBarracuda#v1.0.0
https://github.com/creativeIKEP/PoseDetectionBarracuda.git?path=Packages/PoseDetectionBarracuda#v1.0.1
```

## Demo Image
Expand Down
3 changes: 0 additions & 3 deletions screenshot/demo.png

This file was deleted.

0 comments on commit 21c7f98

Please sign in to comment.