infocom-tpo/PoseNet-Unity

Using the position of keypoints

Opened this issue · 1 comments

I'd like to use the key points generated on the wrists to interact with the world. I'm using a raycast but when I use the key point position the ray spawns at the wrong x,y coordinates. Where in the code can I get the actual position of each keypoint?

Solved: The position of each keypoint is relative to the width/height of the webcam object in the scene. So it will give a Vector2 with an x and y between 0-128 (or 256 depending on width and height of the webcam object in scene).

This is how I got a vector3 of the location of the Right Wrist keypoint.
Square size = webcam object width/height. So here its 256
Screen width and height are my resolution that I've stretched the square to fit to. So 1920x1080

if (keypoint.part == "rightWrist")
{
float xValue = (keypoint.position.x / squareSize) * screenWidth;
float yvalue = (keypoint.position.y / squareSize) * screenHeight;

            _YOffset = -(screenHeight / 16);
            _XOffset = -(screenWidth / 16);
            rWristPoint = Camera.main.ScreenToWorldPoint(new Vector3(-xValue + _XOffset + screenWidth, -yvalue + screenHeight + _YOffset, _zvalue));
            rwristPosition = Camera.main.WorldToScreenPoint(rWristPoint);
        }