Ejemplo n.º 1
0
    // clips color camera image to the dimensions of the user
    private Texture2D ClipUserImage(long userId, Texture2D texImage)
    {
        BodySlicer slicer = BodySlicer.Instance;

        if (slicer && texImage)
        {
            if (slicer.getCalibratedUserId() != userId)
            {
                slicer.OnCalibrationSuccess(userId);
            }

            BodySliceData sliceH = slicer.getBodySliceData(BodySlice.HEIGHT);
            BodySliceData sliceW = slicer.getBodySliceData(BodySlice.WIDTH);

            if (sliceH.isSliceValid && sliceW.isSliceValid)
            {
                int rectX = (int)sliceW.startColorPoint.x;
                int rectW = sliceW.colorPointsLength;

                int rectY = (int)sliceH.startColorPoint.y;
                int rectH = sliceH.colorPointsLength;

                Texture2D texClipped = new Texture2D(rectW, rectH, TextureFormat.ARGB32, false);
                texClipped.SetPixels(texImage.GetPixels(rectX, rectY, rectW, rectH));

                return(texClipped);
            }
        }

        return(texImage);
    }
Ejemplo n.º 2
0
    void Start()
    {
        manager    = KinectManager.Instance;
        bodySlicer = BodySlicer.Instance;

        if (manager && manager.IsInitialized())
        {
            if (backgroundImage)
            {
                Vector3 localScale = backgroundImage.transform.localScale;
                localScale.x = (float)manager.GetDepthImageWidth() * (float)Screen.height / ((float)manager.GetDepthImageHeight() * (float)Screen.width);
                localScale.y = -1f;

                backgroundImage.transform.localScale = localScale;
            }
        }
    }
Ejemplo n.º 3
0
    ////////////////////////////////////////////////////////////////////////


    void Awake()
    {
        instance = this;
    }