简体   繁体   中英

Kinect painting C#, WPF, SDK Kinect

I am new on this site and I really need your help or just a piece of advice guys.

Does anyone know how to do or can help me with making a app similar to this one ?

Draw smooth line in InkCanvas WPF with Kinect

Inline Link

or something like that

Inline Link

I know how to access my Kinect, detect and track each of the joint etc. The only thnig i do not know and with I have problems is that i really do not know how to make a function that will track for example right hand and draw a line on canvas.

Can anyone help me ?

Here you have lots of examples:

The powerpoint control example show you how to detect and track the the hands, and even how to detect some gestures.

EDIT:

Following the example of powerpoint control, in the following code i show you how to track my hands with an ellipse:

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());
            }
        }

This is a method from Microsoft SDK that is called everytime Kinect traks efficiently you skeleton. You just have to put your code for Painting whatever you want where i have my SetEllipsePosition and SetImagePosition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM