Kinect painting C#, WPF, SDK Kinect

本文关键字:Kinect SDK WPF painting | 更新日期: 2023-09-27 18:20:24

我是这个网站的新手,我真的需要你的帮助,或者只是一条建议。

有人知道如何做或者可以帮助我制作类似于这个的应用程序吗?

使用Kinect 在InkCanvas WPF中绘制平滑线条

内联链路

或者类似的东西

内联链路

我知道如何访问我的Kinect,检测和跟踪每个关节等。我唯一不知道的是,我遇到的问题是,我真的不知道如何制作一个功能,例如跟踪右手并在画布上画一条线。

有人能帮我吗?

Kinect painting C#, WPF, SDK Kinect

这里有很多例子:

  • http://www.microsoft.com/en-us/kinectforwindows/develop/how-to-videos.aspx

powerpoint控件示例向您展示了如何检测和跟踪手,甚至如何检测一些手势。

编辑:

按照powerpoint控制的例子,在下面的代码中,我向你展示了如何用椭圆跟踪我的手:

void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            try
            {
                using (var skeletonFrame = e.OpenSkeletonFrame())
                {
                    if (skeletonFrame == null)
                        return;
                    if (skeletons == null ||
                        skeletons.Length != skeletonFrame.SkeletonArrayLength)
                    {
                        skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    }
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
                Skeleton closestSkeleton = skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked)
                                                    .OrderBy(s => s.Position.Z * Math.Abs(s.Position.X))
                                                    .FirstOrDefault();
                if (closestSkeleton == null)
                    return;
                var rightFoot = closestSkeleton.Joints[JointType.FootRight];
                var leftFoot = closestSkeleton.Joints[JointType.FootLeft];
                var rightHand = closestSkeleton.Joints[JointType.HandRight];
                var leftHand = closestSkeleton.Joints[JointType.HandLeft];
                if (rightFoot.TrackingState == JointTrackingState.NotTracked ||
                    rightHand.TrackingState == JointTrackingState.NotTracked ||
                    leftHand.TrackingState == JointTrackingState.NotTracked)
                {
                    //Don't have a good read on the joints so we cannot process gestures
                    return;
                }
                CoordinateMapper mapper = sensor.CoordinateMapper;
                var point = mapper.MapSkeletonPointToColorPoint(closestSkeleton.Joints[JointType.Head].Position, sensor.ColorStream.Format);
                var point1 = mapper.MapSkeletonPointToColorPoint(rightHand.Position, sensor.ColorStream.Format);
                var point2 = mapper.MapSkeletonPointToColorPoint(leftHand.Position, sensor.ColorStream.Format);
                    // - Put Your Draw Code Here insted of the following:
                    SetEllipsePosition(ellipseRightFoot, rightFoot, false);
                    SetEllipsePosition(ellipseLeftFoot, leftFoot, false);
                    SetEllipsePosition(ellipseLeftHand, leftHand, isBackGestureActive);
                    SetEllipsePosition(ellipseRightHand, rightHand, isForwardGestureActive);
                    SetImagePosition(punhal, rightHand);
                    SetImagePosition2(punhal2, leftHand);
                    // -------------------------------------------------
            catch
            {
                myException(this, new EventArgs());
            }
        }

这是微软SDK中的一种方法,每次Kinect都会高效地追踪你的骨骼。你只需要把你想要的绘画代码放在我的SetEllipsePosition和SetImagePosition的地方。