xn.SkeletonCapability.StartTracking C# (CSharp) Method

StartTracking() public method

public StartTracking ( UInt32 user ) : void
user System.UInt32
return void
        public void StartTracking(UserID user)
        {
            UInt32 status = OpenNIImporter.xnStartSkeletonTracking(this.InternalObject, user);
            WrapperUtils.CheckStatus(status);
        }

Usage Example

Example #1
0
        public void Run()
        {
            this.context = new Context (SAMPLE_XML_FILE);

            var ges = context.FindExistingNode (NodeType.Gesture) as GestureGenerator;
            if (ges == null)
                throw new Exception ("Viewer must have a gesture node!");

            //foreach (var ggs in ges.EnumerateAllGestures ()) Console.Error.WriteLine (ggs); return;

            this.depth = context.FindExistingNode (NodeType.Depth) as DepthGenerator;
            if (this.depth == null)
                throw new Exception ("Viewer must have a depth node!");

            user_gen = new UserGenerator (context);
            skel_cap = new SkeletonCapability (user_gen);
            pose_cap = new PoseDetectionCapability (user_gen);
            calib_pose = skel_cap.GetCalibrationPose ();

            user_gen.NewUser += delegate (ProductionNode node, uint id) {
                if (user_count++ > 0)
                    Console.Error.WriteLine ("WARNING: this application does not recognize more than 1 person");
                else
                    pose_cap.StartPoseDetection (calib_pose, id);
            };

            user_gen.LostUser += delegate (ProductionNode node, uint id) {
                user_count--;
                joints.Remove (id);
            };

            pose_cap.PoseDetected += delegate (ProductionNode node, string pose, uint id) {
                pose_cap.StopPoseDetection (id);
                skel_cap.RequestCalibration (id, true);
            };

            skel_cap.CalibrationEnd += delegate (ProductionNode node, uint id, bool success) {
                if (success) {
                    skel_cap.StartTracking (id);
                    joints.Add (id, new Dictionary<SkeletonJoint, SkeletonJointPosition>());
                } else {
                    pose_cap.StartPoseDetection (calib_pose, id);
                }
            };

            skel_cap.SetSkeletonProfile (SkeletonProfile.All);
            joints = new Dictionary<uint,Dictionary<SkeletonJoint,SkeletonJointPosition>> ();
            user_gen.StartGenerating ();

            histogram = new int [this.depth.GetDeviceMaxDepth ()];

            MapOutputMode mapMode = this.depth.GetMapOutputMode ();

            tcp_client = new TcpClient ();
            tcp_client.Connect ("localhost", 9801);
            tcp_writer = new StreamWriter (tcp_client.GetStream ());

            //			bitmap = new Bitmap ((int) mapMode.nXRes, (int) mapMode.nYRes/*, System.Drawing.Imaging.PixelFormat.Format24bppRgb*/);
            should_run = true;
            readerThread = new Thread (ReaderThread);
            readerThread.Start ();

            shouldPrintState = false;

            Console.WriteLine ("Type [CR] to stop");
            Console.ReadLine ();
            should_run = false;
        }