コード例 #1
0
        private void ProcessPointCloudStreamMessage(object obj, KinectClient client)
        {
            bool coloredPointCloud = false;
            PointCloudStreamMessage msg = (PointCloudStreamMessage)obj;
            if (obj is ColoredPointCloudStreamMessage)
            {
                coloredPointCloud = true;
            }

            double[] doubleArray = msg.PointCloud;
            NullablePoint3D[] pointArray = new NullablePoint3D[doubleArray.Length / 3];
            for (int i = 0; i < doubleArray.Length; i += 3)
            {
                if (double.IsNegativeInfinity(doubleArray[i]))
                {
                    pointArray[i / 3] = null;
                }
                else
                {
                    pointArray[i / 3] = new NullablePoint3D(doubleArray[i], doubleArray[i + 1], doubleArray[i + 2]);
                }
            }

            PointCloud pointCloud = new PointCloud() {Points = pointArray};
            if (coloredPointCloud)
            {
                pointCloud.ColorBytes = ((ColoredPointCloudStreamMessage) msg).ColorPixels;
            }

            dataStore.AddOrUpdatePointCloud(client, pointCloud);

            if (PointCloudMessageArrived != null)
            {
                PointCloudMessageArrived(msg, client);
            }
            if (coloredPointCloud && ColoredPointCloudMessageArrived != null)
            {
                ColoredPointCloudMessageArrived(msg, client);
            }
        }
コード例 #2
0
ファイル: DataStore.cs プロジェクト: frksptr/kinect-demo
 public void AddOrUpdatePointCloud(KinectClient client, PointCloud pointCloud)
 {
     clientPointCloudDictionary[client] = pointCloud;
 }