当前位置: 首页>>代码示例>>C#>>正文


C# DepthImageFrame.MapToColorImagePoint方法代码示例

本文整理汇总了C#中Microsoft.Kinect.DepthImageFrame.MapToColorImagePoint方法的典型用法代码示例。如果您正苦于以下问题:C# DepthImageFrame.MapToColorImagePoint方法的具体用法?C# DepthImageFrame.MapToColorImagePoint怎么用?C# DepthImageFrame.MapToColorImagePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Kinect.DepthImageFrame的用法示例。


在下文中一共展示了DepthImageFrame.MapToColorImagePoint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPosition2DLocation

        private Point GetPosition2DLocation(DepthImageFrame depthFrame, SkeletonPoint skeletonPoint)
        {
            DepthImagePoint depthPoint = depthFrame.MapFromSkeletonPoint(skeletonPoint);

            ColorImagePoint colorPoint = depthFrame.MapToColorImagePoint(depthPoint.X, depthPoint.Y, this._sensor.ColorStream.Format);

            // map back to skeleton.Width & skeleton.Height
            //return new Point(
            //    (int)(this.RenderSize.Width * colorPoint.X / this._sensor.ColorStream.FrameWidth),
            //    (int)(this.RenderSize.Height * colorPoint.Y / this._sensor.ColorStream.FrameHeight));
            return new Point(
                (int)(canvas1.Width * colorPoint.X / this._sensor.ColorStream.FrameWidth),
                (int)(canvas1.Height * colorPoint.Y / this._sensor.ColorStream.FrameHeight));
        }
开发者ID:williamchai,项目名称:kinect-ipd,代码行数:14,代码来源:MainWindow.xaml.cs

示例2: GetPosition2DLocation

        /// <summary>
        /// Convert real-world positions to 2D image coords.
        /// </summary>
        /// <param name="depthFrame">Datth frame used to conversion.</param>
        /// <param name="skeletonPosition">Point which position should be converted.</param>
        /// <returns>Point in 2D image.</returns>
        private Point GetPosition2DLocation(DepthImageFrame depthFrame, SkeletonPoint skeletonPosition)
        {
            DepthImagePoint depthPoint = depthFrame.MapFromSkeletonPoint(skeletonPosition);
            ColorImagePoint colorPoint = depthFrame.MapToColorImagePoint(depthPoint.X, depthPoint.Y, kinect.ColorStream.Format);

            // map back to skeleton.Width & skeleton.Height
            return new Point(colorPoint.X, colorPoint.Y);
        }
开发者ID:PuniCZ,项目名称:KinectGestureRecognition,代码行数:14,代码来源:KinectGesturePlayer.cs

示例3: ProcessFrame

        public void ProcessFrame(KinectSensor sensor, byte[] colorImage, ColorImageFormat colorImageFormat, DepthImageFrame depthFrame, short[] depthImage, DepthImageFormat depthImageFormat, Skeleton[] skeletonData, SkeletonFrame skeletonFrame)
        {
            //Console.WriteLine("N: ---------");
            coordinates.Clear();
            int detectedFace = 0;
            int trackedSkeletonsCount = 0;

            int playerIndex = -1;
            for (int i = 0; i < skeletonData.Length; i++)
            //foreach (Skeleton skeleton in skeletonData)
            {
                Skeleton skeleton = skeletonData[i];
                if (skeleton.TrackingState == SkeletonTrackingState.Tracked
                    || skeleton.TrackingState == SkeletonTrackingState.PositionOnly)
                {
                    // We want keep a record of any skeleton, tracked or untracked.
                    if (!trackedSkeletons.ContainsKey(skeleton.TrackingId))
                    {
                        trackedSkeletons.Add(skeleton.TrackingId, new SkeletonFaceTracker());
                    }

                    DepthImagePoint depthPoint = depthFrame.MapFromSkeletonPoint(skeleton.Joints[JointType.Head].Position);
                    ColorImagePoint colorPoint = depthFrame.MapToColorImagePoint(depthPoint.X, depthPoint.Y, colorImageFormat);

                    Coordinates2D c = new Coordinates2D();

                    playerIndex = i + 1;

                    c.X = colorPoint.X;
                    c.Y = colorPoint.Y;
                    c.Width = 0;
                    c.Height = 0;
                    c.LeftEyeX = 0;
                    c.LeftEyeY = 0;
                    c.RightEyeX = 0;
                    c.RightEyeY = 0;
                    c.PlayerIndex = playerIndex;

                    trackedSkeletonsCount++;

                    // Give each tracker the upated frame.
                    SkeletonFaceTracker skeletonFaceTracker;
                    if (!scannedIdentities.Contains(skeleton.TrackingId) &&
                        detectedFace < 1 &&
                        trackedSkeletons.TryGetValue(skeleton.TrackingId, out skeletonFaceTracker))
                    {
                        detectedFace++;
                        scannedIdentities.Add(skeleton.TrackingId);

                        skeletonFaceTracker.OnFrameReady(sensor, colorImageFormat, colorImage, depthImageFormat, depthImage, skeleton);
                        skeletonFaceTracker.LastTrackedFrame = skeletonFrame.FrameNumber;
                        Coordinates2D? realCoords = skeletonFaceTracker.GetFaceCoordinates();
                        if (realCoords.HasValue)
                        {
                            c = realCoords.Value;
                            c.PlayerIndex = playerIndex;
                        }
                    }

                    c.TrackingId = skeleton.TrackingId;
                    coordinates.Add(c);
                }
            }

            if (scannedIdentities.Count > 0 && scannedIdentities.Count >= trackedSkeletonsCount)
            {
                scannedIdentities.Clear();
                //Console.WriteLine("Clearing");
            }

            RemoveOldTrackers(skeletonFrame.FrameNumber);

            //if (coordinates.Count > 0)
            {
                int[] identities = new int[coordinates.Count];

              //  stopwatch.Reset();
              //  stopwatch.Start();
                double[] distances = new double[coordinates.Count * 8];
                this.
                 ProcessImage(colorImage, GetWidth(colorImageFormat), GetHeight(colorImageFormat), depthImage, 640, 480, coordinates.ToArray(), identities, distances);
              //  stopwatch.Stop();
             //       foreach (int i in identities)
             //       {
             //           Console.WriteLine("Recognized: {0} (in {1} millis - {2} ticks)", i, stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks);
             //       }
            }
        }
开发者ID:lomelina,项目名称:Biosandbox,代码行数:88,代码来源:BiometricEngine.cs

示例4: MapToPoint

 public Point MapToPoint(SkeletonPoint s, DepthImageFrame depth)
 {
     DepthImagePoint dp = depth.MapFromSkeletonPoint(s);
     ColorImagePoint cp = depth.MapToColorImagePoint(dp.X, dp.Y, ColorImageFormat.RgbResolution640x480Fps30);
     return new Point(cp.X, cp.Y);
 }
开发者ID:pedrotanaka,项目名称:CS160-Final-Project,代码行数:6,代码来源:KinectController.cs


注:本文中的Microsoft.Kinect.DepthImageFrame.MapToColorImagePoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。