oveddan / posenet-for-installations

Provides an ideal way to use PoseNet for installations; it works offline and broadcasts poses over websocket.
Apache License 2.0
132 stars 29 forks source link

Examples in OpenFrameworks, Unity, and TouchDesigner #3

Open oveddan opened 6 years ago

oveddan commented 6 years ago

Show some examples of how to consume poses in OpenFrameworks, Unity, and TouchDesigner.

sambit2 commented 6 years ago

Hi @oveddan , I was curious that when can we expect some examples of poses consumption in Unity?

weirenjune commented 6 years ago

Hi I am not too fammiliar with using Github but i have code that can help with communication to unity. So I will just share it here.

Unity has a built-in JSON utility which can parse JSON data. But before we can do that, we need to encapsulate all the data into their respective classes:

[System.Serializable] public class PosenetMessageData //this class holds all the data { public PoseData[] poses; public ImageData image; }

[System.Serializable] public class ImageData { public int width; public int height; }

[System.Serializable] public class PoseData { public float score; //confidence public KeypointsData[] keypoints; }

[System.Serializable] public class KeypointsData { public float score; //confidence public string part; //name of the part public PositionData position; }

[System.Serializable] public class PositionData { public float x; public float y; }

after doing this, simply call: posenetMessageData = JsonUtility.FromJson(e.Data); //e.Data is the message we receive from the websocket

You can use websocket-sharp for websocket communication in unity.

carlottaCC commented 5 years ago

Hi, thank you for the detailed info. is the resolution fine in unity?