예제 #1
0
        public BitmapSource GetColorPointCloud()
        {
            var response = _restClient.GetCloudpoints();

            var bitmap = response.GenerateColorBitmap();

            return(bitmap);
        }
예제 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            actualFramerate.MeasureHere();

            if (isServerOnline)
            {
                string connected = isConnected ? "Kinect ready" : "Kinect unavailable";
                Text = "Server online, " + connected + " " + actualFramerate.FrameRate + "   fps, Target: " + targetedFramerate.FrameRate + " fps,   ↑" + service.GetCurrentUpload() + " KB/s   ↓" + service.GetCurrentDownload() + " KB/s"; // Window Title Text
                if (isConnected)
                {
                    Graphics g = Graphics.FromImage(bmp.Bitmap);
                    g.Clear(Color.Transparent);

                    IList <CloudPoint> cloudpoints = service.GetCloudpoints();

                    if (cloudpoints == null)
                    {
                        g.Clear(Color.Magenta);
                        Text = "Internal server error";
                    }
                    else
                    {
                        foreach (CloudPoint p in cloudpoints)
                        {
                            // Color
                            bmp.SetPixel((int)p.GetX(), (int)p.GetY(), Color.FromArgb((int)(p.GetR() * 256), (int)(p.GetG() * 256), (int)(p.GetB() * 256)));

                            // Depth
                            bmp.SetPixel((int)p.GetX() + 512, (int)p.GetY(), Color.FromArgb((byte)(p.GetZ() % 4096), (byte)(p.GetZ() % 4096), (byte)(p.GetZ() % 4096)));
                        }

                        e.Graphics.DrawImage(bmp.Bitmap, 0, 0);
                    }
                }
            }
            else
            {
                Text = "Server unreachable";
            }
        }
예제 #3
0
    void Update()
    {
        if (freeze)
        {
            return;
        }

        MaterialPropertyBlock props      = new MaterialPropertyBlock();
        IList <CloudPoint>    cloudpoint = null;

        cloudpoint   = skeletonMode ? iRemoteService.GetSkeleton() : iRemoteService.GetCloudpoints();
        pointColor.a = 0;
        float max = 0;
        int   i;
        int   bodyPointIndex;

        int stepRange = 1;

        if (detailedFace)
        {
            stepRange = cloudpoint.Count / bodyPoints.Length;
        }

        for (bodyPointIndex = 0, i = 0;
             i < cloudpoint.Count && bodyPointIndex < bodyPoints.Length;
             i += stepRange, bodyPointIndex++)
        {
            CloudPoint item = cloudpoint[i];
            float      x, y, z;
            float      secondFactor;
            pointColor.r = item.GetR();
            pointColor.g = item.GetG();
            pointColor.b = item.GetB();
            bodyPoints[bodyPointIndex].SetActive(true);

            if (skeletonMode)
            {
                z = item.GetZ() * 10;
                x = (item.GetX() * 10);
                y = (item.GetY() * 10);
            }
            else
            {
                z            = item.GetZ() / 100;
                secondFactor = z * factor;
                x            = (item.GetX() - width / 2.0f) * secondFactor;   // x und y mal z genommen
                y            = -(item.GetY() - height / 2.0f) * secondFactor; //180° Drehung
            }

            // y - 2 für Cameraanpassung bei reset
            bodyPoints[bodyPointIndex].transform.localPosition = new Vector3(x, y - 2, z - distanceToHead);
            bodyPoints[bodyPointIndex].transform.localScale    = new Vector3(cubeScale, cubeScale, cubeScale);
            props.SetColor("_Color", pointColor);
            bodyPoints[bodyPointIndex].GetComponent <MeshRenderer>().SetPropertyBlock(props);

            if (max < y)
            {
                max = y;
                currentDistanceToHead = z;
            }
        }

        pointColor.a = 1;
        for (int j = bodyPointIndex; j < bodyPoints.Length; j++)
        {
            bodyPoints[j].SetActive(false);
        }
    }