Пример #1
0
    void Start()
    {
        mapping = new OpenPoseMapping();

        // setup texture for webcam
        webcamTexture = new WebCamTexture();
    }
Пример #2
0
    public static void DrawConnections(JToken human, OpenPoseMapping mapping)
    {
        for (int c = 0; c < connections.GetLength(0); c++)
        {
            JToken start = null, end = null;
            foreach (JToken bodypart in human)
            {
                string name = (string)bodypart[0];

                if (name == connections[c, 0])
                {
                    start = bodypart;
                }
                else if (name == connections[c, 1])
                {
                    end = bodypart;
                }
            }

            if (start != null && end != null)
            {
                Vector3 startPoint = GetMappedPosition((float)start[1], (float)start[2], mapping);
                Vector3 endPoint   = GetMappedPosition((float)end[1], (float)end[2], mapping);
                Gizmos.DrawLine(startPoint, endPoint);
            }
        }
    }
Пример #3
0
    private static Vector3 GetMappedPosition(float x, float y, OpenPoseMapping mapping)
    {
        float mappedX = x * mapping.width + mapping.offset;
        float mappedY = y * mapping.height;

        return(new Vector3(mappedX, -mappedY, 0));
    }
Пример #4
0
 public static void DrawParts(JToken human, OpenPoseMapping mapping, float radius = 1)
 {
     foreach (JToken bodypart in human)
     {
         Vector3 pos = GetMappedPosition((float)bodypart[1], (float)bodypart[2], mapping);
         Gizmos.DrawWireSphere(pos, radius);
     }
 }