private void Start() { // initialize sensor Microsoft Kinect SDK sensor = Microsoft.Kinect.KinectSensor.KinectSensors.FirstOrDefault(); sensor.Start(); sensor.ElevationAngle = 13; // initialize some element this.Cursor = Cursors.Wait; this.factory = new SDKDataSourceFactory(); this.clusterDataSource = this.factory.CreateClusterDataSource(new Core.Clustering.ClusterDataSourceSettings { MaximumDepthThreshold = 900 }); this.handDataSource = new HandDataSource(this.factory.CreateShapeDataSource(this.clusterDataSource, new Core.Shape.ShapeDataSourceSettings())); var depthImageSource = this.factory.CreateDepthImageDataSource(); depthImageSource.NewDataAvailable += new NewDataHandler <ImageSource>(MainWindow_NewDataAvailable); handDataSource.NewDataAvailable += new NewDataHandler <HandCollection>(handDataSource_NewDataAvailable); HandInterfaceWindow(this.handDataSource, depthImageSource); //new HandInterfaceWindow(this.handDataSource, this.rgbImageDataSource).Show(); depthImageSource.Start(); handDataSource.Start(); this.Cursor = Cursors.Arrow; }
//3次元位置取得 Microsoft.Kinect.CameraSpacePoint GetCenterPosition(OpenCvSharp.CPlusPlus.Point colorImagePoint, ushort[] depthBuffer, int imgW, int imgH) { Microsoft.Kinect.KinectSensor kinect = Microsoft.Kinect.KinectSensor.GetDefault(); Microsoft.Kinect.CameraSpacePoint[] bodyPosition = new Microsoft.Kinect.CameraSpacePoint[imgW * imgH]; kinect.CoordinateMapper.MapColorFrameToCameraSpace(depthBuffer, bodyPosition); Microsoft.Kinect.CameraSpacePoint centerPoint = bodyPosition[colorImagePoint.X + colorImagePoint.Y * imgW]; //Console.WriteLine(centerPoint.X.ToString()); return(centerPoint); }
public Provider() { // Setup the Kinect foreach (var potential in Microsoft.Kinect.KinectSensor.KinectSensors) { if (potential.Status == Microsoft.Kinect.KinectStatus.Connected) { this._kinect = potential; break; } } // Ensure a Kinect was found if (this._kinect == null) { //#todo: change the exception type here throw new Exception(); } Console.WriteLine("Found Kinect"); }
void InitKinect() { foreach (var sensor in Microsoft.Kinect.KinectSensor.KinectSensors) { if (sensor.Status == Microsoft.Kinect.KinectStatus.Connected) { kinect = sensor; break; } } if (kinect == null) { Exit(); return; } kinect.DepthStream.Enable(); kinect.SkeletonStream.Enable(); s.skeletons = new Microsoft.Kinect.Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength]; rs.skeletons = new Microsoft.Kinect.Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength]; kinect.DepthFrameReady += s.DepthFrameReady; kinect.SkeletonFrameReady += s.SkeletonFrameReady; kinect.Start(); }