コード例 #1
0
        public static void SetWorkspaceCloudRealVerticesAndCenter(Workspace workspace, FrameSize depthFrameSize)
        {
            dataStore = DataStore.Instance;
            KinectClient client = dataStore.GetClientForWorkspace(workspace.ID);
            double sumX = 0;
            double sumY = 0;
            double sumZ = 0;
            double numberOfPoints = 0;
            Point[] workspaceVertices = {
                new Point(workspace.Vertices[0].X, workspace.Vertices[0].Y),
                new Point(workspace.Vertices[1].X, workspace.Vertices[1].Y),
                new Point(workspace.Vertices[2].X, workspace.Vertices[2].Y),
                new Point(workspace.Vertices[3].X, workspace.Vertices[3].Y),
            };

            List<Point3D> pointCloud = new List<Point3D>();
            NullablePoint3D[] clientPointCloud = dataStore.GetPointCloudForClient(client);
            for (int i = 0; i < clientPointCloud.Count(); i++)
            {
                if (GeometryHelper.InsidePolygon(workspaceVertices, new Point(i%depthFrameSize.Width, i/depthFrameSize.Width)))
                {
                    NullablePoint3D point = clientPointCloud[i];
                    if (point != null)
                    {
                        double x = point.X;
                        double y = point.Y;
                        double z = point.Z;

                        sumX += x;
                        sumY += y;
                        sumZ += z;

                        numberOfPoints += 1;

                        pointCloud.Add(new Point3D(point.X, point.Y, point.Z));
                    }
                }
            }
            workspace.Center = new Point3D(sumX / numberOfPoints, sumY / numberOfPoints, sumZ / numberOfPoints);

            workspace.PointCloud = pointCloud.ToArray();

            SetRealVertices(workspace);
        }
コード例 #2
0
 private void kinectServer_DepthDataArrived(KinectDemoMessage message, KinectClient client)
 {
     depthFrameSize = ((DepthStreamMessage)message).DepthFrameSize;
     serverMessageProcessor.DepthMessageArrived -= kinectServer_DepthDataArrived;
 }
コード例 #3
0
 private void ProcessDepthStreamMessage(object obj, KinectClient sender)
 {
     if (DepthMessageArrived != null)
     {
         DepthMessageArrived((DepthStreamMessage)obj, sender);
         if (depthFrameSize == null)
         {
             depthFrameSize = ((DepthStreamMessage)obj).DepthFrameSize;
         }
     }
 }