none
Kinect warning description RRS feed

  • Question

  • Helo. 
           I'm beginning to use kinect. I have a problem, my code program don't work 

           I want to help solve this problem. using kinect Sdk 1.8 in win7 ,VS2010.

           Thank you.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Microsoft.Kinect;
    using Coding4Fun.Kinect.Wpf;
    using Microsoft.Samples.Kinect.WpfViewers;
    
    namespace SkeletonPK
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
            bool closing = false;
            const int skeletonCount = 6;
            Skeleton[] allSkeletons = new Skeleton[skeletonCount];
            
    
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                kinectSensorChooser1.KinectSensorChanged += new DependencyPropertyChangedEventHandler(kinectSensorChooser1_KinectSensorChanged);
            }
    
            void kinectSensorChooser1_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e)
            {
                KinectSensor oldSensor = (KinectSensor)e.OldValue;
                StopKinect(oldSensor);
    
                KinectSensor newSensor = (KinectSensor)e.NewValue;
    
                newSensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(newSensor_AllFramesReady);
                
                
                newSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
                newSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
                newSensor.SkeletonStream.Enable();
                
                         
                try
                {
                    newSensor.Start();
                }
                catch (System.IO.IOException)
                {
    
                    kinectSensorChooser1.AppConflictOccurred();
                } 
            }
    
            void newSensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
            {
                if (closing)
                {
                    return;
                }
                Skeleton first = GetFirstSkeleton(e);
                if (first == null)
                {
                    return;
                }
                GetCameraPoint(first, e);
    
                //ScalePosition(headImage, first.Joints[JointType.Head]);
                //ScalePosition(leftEllipse, first.Joints[JointType.HandLeft]);
                //ScalePosition(rightEllipse, first.Joints[JointType.HandRight]);
            }
    
            
            void GetCameraPoint(Skeleton first, AllFramesReadyEventArgs e)
            {
                using (DepthImageFrame depth = e.OpenDepthImageFrame())
                {
                    if (depth == null || kinectSensorChooser1.Kinect == null)
                    {
                        return;
                    }
                    
                    DepthImagePoint headDepthPoint = depth.MapFromSkeletonPoint(first.Joints[JointType.Head].Position);
                    DepthImagePoint leftDepthPoint = depth.MapFromSkeletonPoint(first.Joints[JointType.HandLeft].Position);
                    DepthImagePoint rightDepthPoint = depth.MapFromSkeletonPoint(first.Joints[JointType.HandRight].Position);
    
                    ColorImagePoint headColorPoint =
                        depth.MapToColorImagePoint(headDepthPoint.X, headDepthPoint.Y, ColorImageFormat.RgbResolution640x480Fps30);
                    ColorImagePoint leftColorPoint =
                        depth.MapToColorImagePoint(leftDepthPoint.X, leftDepthPoint.Y, ColorImageFormat.RgbResolution640x480Fps30);
                    ColorImagePoint rightColorPoint =
                        depth.MapToColorImagePoint(rightDepthPoint.X, rightDepthPoint.Y, ColorImageFormat.RgbResolution640x480Fps30);
    
                    CameraPosition(headImage, headColorPoint);
                    CameraPosition(leftEllipse, leftColorPoint);
                    CameraPosition(rightEllipse, rightColorPoint);
    
                }
            }
    
            Skeleton GetFirstSkeleton(AllFramesReadyEventArgs e)
            {
                using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
                {
                    if (skeletonFrameData == null)
                    {
                        return null;
                    }
                    skeletonFrameData.CopySkeletonDataTo(allSkeletons);
    
                    Skeleton first = (from s in allSkeletons
                                      where s.TrackingState == SkeletonTrackingState.Tracked
                                      select s).FirstOrDefault();
                    return first;
                }
            }
    
            void StopKinect(KinectSensor sensor)
            {
                if (sensor != null)
                {
                    sensor.Stop();
                    sensor.AudioSource.Stop();
    
                }
            }
    
            private void CameraPosition(FrameworkElement element, ColorImagePoint point)
            {
                Canvas.SetLeft(element, point.X - element.Width / 2);
                Canvas.SetTop(element, point.Y - element.Height / 2);
            }
    
            private void ScalePosition(FrameworkElement element, Joint joint)
            {
                //convert the value to X/Y
                Joint scaledJoint = joint.ScaleTo(1280, 720); 
    
                //convert & scale (.3 = means 1/3 of joint distance)
                //note you need to have Coding4Fun
                //Joint scaledJoint = joint.ScaleTo(1280, 720, .3f, .3f);
    
                Canvas.SetLeft(element, scaledJoint.Position.X);
                Canvas.SetTop(element, scaledJoint.Position.Y);
            }
    
            private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                StopKinect(kinectSensorChooser1.Kinect);
            }
        }
    }
    

    Warning 1 'Microsoft.Kinect.DepthImageFrame.MapFromSkeletonPoint(Microsoft.Kinect.SkeletonPoint)' is obsolete: '"This method is replaced by Microsoft.Kinect.CoordinateMapper.MapSkeletonPointToDepthPoint"'
    Warning 2 'Microsoft.Kinect.DepthImageFrame.MapFromSkeletonPoint(Microsoft.Kinect.SkeletonPoint)' is obsolete: '"This method is replaced by Microsoft.Kinect.CoordinateMapper.MapSkeletonPointToDepthPoint"'
    Warning 3 'Microsoft.Kinect.DepthImageFrame.MapFromSkeletonPoint(Microsoft.Kinect.SkeletonPoint)' is obsolete: '"This method is replaced by Microsoft.Kinect.CoordinateMapper.MapSkeletonPointToDepthPoint"'
    Warning 4 'Microsoft.Kinect.DepthImageFrame.MapToColorImagePoint(int, int, Microsoft.Kinect.ColorImageFormat)' is obsolete: '"This method is replaced by Microsoft.Kinect.CoordinateMapper.MapDepthPointToColorPoint"'
    Warning 5 'Microsoft.Kinect.DepthImageFrame.MapToColorImagePoint(int, int, Microsoft.Kinect.ColorImageFormat)' is obsolete: '"This method is replaced by Microsoft.Kinect.CoordinateMapper.MapDepthPointToColorPoint"'
    Warning 6 'Microsoft.Kinect.DepthImageFrame.MapToColorImagePoint(int, int, Microsoft.Kinect.ColorImageFormat)' is obsolete: '"This method is replaced by Microsoft.Kinect.CoordinateMapper.MapDepthPointToColorPoint"'


    Thursday, May 8, 2014 6:07 PM

All replies

  • The warning provided you the answer. You have to use the coordinate mapper and the listed function. There is a CoordinateMapping-Basics samples provided in the toolkit. For your code you would have to instantiate an instance of the CoordinateMapper and call the function with the correct argument values.

    CoordinateMapper Members
    http://msdn.microsoft.com/en-us/library/microsoft.kinect.coordinatemapper_members.aspx


    Carmine Sirignano - MSFT

    Thursday, May 8, 2014 7:05 PM
  • Hi, Carmine Si - MSFT

    Thank for reply.

    but I don't understand. I try to debug. It's don't work.

    This is my first program. I'm confused. how can i make it to work ?

    Sorry, I'm not good in English.

    void GetCameraPoint(Skeleton first, AllFramesReadyEventArgs e)
            {
                using (DepthImageFrame depth = e.OpenDepthImageFrame())
                {
                    if (depth == null || kinectSensorChooser1.Kinect == null)
                    {
                        return;
                    }
    
                    DepthImagePoint headDepthPoint = kinectSensorChooser1.Kinect.CoordinateMapper.MapSkeletonPointToDepthPoint(first.Joints[JointType.Head].Position, kinectSensorChooser1.Kinect.DepthStream.Format);
                    DepthImagePoint leftDepthPoint = kinectSensorChooser1.Kinect.CoordinateMapper.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandLeft].Position, kinectSensorChooser1.Kinect.DepthStream.Format);
                    DepthImagePoint rightDepthPoint = kinectSensorChooser1.Kinect.CoordinateMapper.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandRight].Position, kinectSensorChooser1.Kinect.DepthStream.Format);
                    //DepthImagePoint headDepthPoint = depth.MapFromSkeletonPoint(first.Joints[JointType.Head].Position);
                    //DepthImagePoint leftDepthPoint = depth.MapFromSkeletonPoint(first.Joints[JointType.HandLeft].Position);
                    //DepthImagePoint rightDepthPoint = depth.MapFromSkeletonPoint(first.Joints[JointType.HandRight].Position);
    
                    //ColorImagePoint headColorPoint =
                    //    depth.MapToColorImagePoint(headDepthPoint.X, headDepthPoint.Y, ColorImageFormat.RgbResolution640x480Fps30);
                    //ColorImagePoint leftColorPoint =
                    //    depth.MapToColorImagePoint(leftDepthPoint.X, leftDepthPoint.Y, ColorImageFormat.RgbResolution640x480Fps30);
                    //ColorImagePoint rightColorPoint =
                    //    depth.MapToColorImagePoint(rightDepthPoint.X, rightDepthPoint.Y, ColorImageFormat.RgbResolution640x480Fps30);
    
                    ColorImagePoint headColorPoint = kinectSensorChooser1.Kinect.CoordinateMapper.MapDepthPointToColorPoint(kinectSensorChooser1.Kinect.DepthStream.Format, headDepthPoint, kinectSensorChooser1.Kinect.ColorStream.Format);
                    ColorImagePoint leftColorPoint = kinectSensorChooser1.Kinect.CoordinateMapper.MapDepthPointToColorPoint(kinectSensorChooser1.Kinect.DepthStream.Format, leftDepthPoint, kinectSensorChooser1.Kinect.ColorStream.Format);
                    ColorImagePoint rightColorPoint = kinectSensorChooser1.Kinect.CoordinateMapper.MapDepthPointToColorPoint(kinectSensorChooser1.Kinect.DepthStream.Format, rightDepthPoint, kinectSensorChooser1.Kinect.ColorStream.Format);
    
                    CameraPosition(headImage, headColorPoint);
                    CameraPosition(leftEllipse, leftColorPoint);
                    CameraPosition(rightEllipse, rightColorPoint);
    
                }
            }


    mapper

    Friday, May 9, 2014 10:40 PM
  • What errors are you getting now by using the Coordinate Mapper?

    Please review the CoordinateMapping Basics sample provided in the Kinect for Windows Toolkit. It provides the necessary steps to acquire the coordinate mapper and call the required functions.

    http://www.microsoft.com/en-us/kinectforwindowsdev/Downloads.aspx

    There are other skeleton samples provided in the SDK as well, you can review the Skeletal Tracking video on this page:http://www.microsoft.com/en-us/kinectforwindowsdev/Resources.aspx


    Carmine Sirignano - MSFT

    Tuesday, May 13, 2014 6:55 PM