public void Evaluate(int SpreadMax)
		{
			if (this.FInvalidateConnect)
			{
				if (runtime != null)
				{
					this.runtime.DepthFrameReady -= DepthFrameReady;
				}

				if (this.FInRuntime.PluginIO.IsConnected)
				{
					//Cache runtime node
					this.runtime = this.FInRuntime[0];

					if (runtime != null)
					{
						this.FInRuntime[0].DepthFrameReady += DepthFrameReady;
					}

				}

				this.FInvalidateConnect = false;
			}

			this.FOutFrameIndex[0] = this.frameindex;
		}
Exemple #2
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        faceSrc = new Microsoft.Kinect.Face.FaceFrameSource(this.runtime.Runtime);
                        faceSrc.FaceFrameFeatures = FaceFrameFeatures.FaceEngagement | FaceFrameFeatures.LeftEyeClosed | FaceFrameFeatures.LookingAway | FaceFrameFeatures.FaceEngagement | FaceFrameFeatures.Happy | FaceFrameFeatures.MouthMoved | FaceFrameFeatures.MouthOpen | FaceFrameFeatures.RightEyeClosed | FaceFrameFeatures.RotationOrientation;
                        faceReader = faceSrc.OpenReader();
                        faceReader.FrameArrived += this.faceReader_FrameArrived;

                        hdSrc = new HighDefinitionFaceFrameSource(this.runtime.Runtime);
                        hdRead = hdSrc.OpenReader();
                        hdRead.FrameArrived += hdRead_FrameArrived;
                    }
                }
                else
                {
                    if (faceSrc != null)
                    {
                        faceReader.FrameArrived -= faceReader_FrameArrived;
                        faceReader.Dispose();
                    }
                }

                this.FInvalidateConnect = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.AllFrameReady -= KinectFaceNode_AllFrameReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].AllFrameReady += KinectFaceNode_AllFrameReady;
                    }

                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                this.FOutOK.SliceCount = this.trackedSkeletons.Count;
                this.FOutPosition.SliceCount = this.trackedSkeletons.Count;
                this.FOutRotation.SliceCount = this.trackedSkeletons.Count;

                List<FaceTrackFrame> frames = new List<FaceTrackFrame>();

                int cnt = 0;
                foreach (int key in this.trackedSkeletons.Keys)
                {
                    SkeletonFaceTracker sft = this.trackedSkeletons[key];
                    if (sft.frame != null)
                    {
                        frames.Add((FaceTrackFrame)sft.frame.Clone());
                        this.FOutOK[cnt] = sft.frame.TrackSuccessful;
                        this.FOutPosition[cnt] = new Vector3(sft.frame.Translation.X, sft.frame.Translation.Y, sft.frame.Translation.Z);
                        this.FOutRotation[cnt] = new Vector3(sft.frame.Rotation.X, sft.frame.Rotation.Y, sft.frame.Rotation.Z) * INVTWOPI;

                        EnumIndexableCollection<FeaturePoint, PointF> pp = sft.frame.GetProjected3DShape();
                        EnumIndexableCollection<FeaturePoint, Vector3DF> p = sft.frame.Get3DShape();
                    }
                    else
                    {
                        this.FOutOK[cnt] = false;
                        this.FOutPosition[cnt] = Vector3.Zero;
                        this.FOutRotation[cnt] = Vector3.Zero;
                    }
                    cnt++;
                }

                this.FOutFrame.AssignFrom(frames);
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }

                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List<Body> skels = new List<Body>();
                    List<int> indices = new List<int>();
                    float z = float.MaxValue;
                    int id = -1;

                    lock (m_lock)
                    {

                        for (int i = 0; i < this.lastframe.Length; i++)
                        {
                            if (this.lastframe[i].IsTracked)
                            {
                                skels.Add(this.lastframe[i]);
                                indices.Add(i);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutPosition.SliceCount = cnt;
                    this.FOutUserIndex.SliceCount = cnt;
                    this.FOutShortIndex.SliceCount = cnt;
                    this.FOutClipped.SliceCount = cnt;
                    this.FOutJointPosition.SliceCount = cnt * 25;
                    this.FOutJointState.SliceCount = cnt * 25;
                    this.FOutJointID.SliceCount = cnt * 25;
                    this.FOutJointPositionRGB.SliceCount = cnt * 25;
                    this.FOutJointOrientation.SliceCount = cnt * 25;
                    this.FOutFrameNumber[0] = this.frameid;

                    int jc = 0;
                    for (int i = 0; i < cnt; i++)
                    {
                        Body sk = skels[i];

                        Joint ce = sk.Joints[JointType.SpineBase];
                        this.FOutPosition[i] = new Vector3(ce.Position.X, ce.Position.Y, ce.Position.Z);
                        this.FOutUserIndex[i] = sk.TrackingId.ToString();
                        this.FOutShortIndex[i] = indices[i];

                        Vector4 clip = Vector4.Zero;
                        clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                        clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                        clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                        clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                        this.FOutClipped[i] = clip;

                        foreach (Joint joint in sk.Joints.Values)
                        {

                            var jrgb = this.runtime.Runtime.CoordinateMapper.MapCameraPointToColorSpace(joint.Position);

                            Microsoft.Kinect.Vector4 bo = sk.JointOrientations[joint.JointType].Orientation;
                            this.FOutJointID[jc] = joint.JointType.ToString();
                            this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);

                            this.FOutJointOrientation[jc] = new Quaternion(bo.X, bo.Y, bo.Z, bo.W);
                            this.FOutJointState[jc] = joint.TrackingState.ToString();

                            this.FOutJointPositionRGB[jc] = new Vector2(jrgb.X, jrgb.Y);
                            jc++;
                        }
                    }
                }
                else
                {
                    this.FOutCount[0] = 0;
                    this.FOutPosition.SliceCount = 0;
                    this.FOutUserIndex.SliceCount = 0;
                    this.FOutJointID.SliceCount = 0;
                    this.FOutJointPosition.SliceCount = 0;
                    this.FOutJointState.SliceCount = 0;
                    this.FOutFrameNumber[0] = 0;
                    this.FOutJointOrientation.SliceCount = 0;
                }
                this.FInvalidate = false;
            }
        }
Exemple #5
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }

                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List<Body> skels = new List<Body>();
                    float z = float.MaxValue;
                    int id = -1;

                    lock (m_lock)
                    {

                        foreach (Body sk in this.lastframe)
                        {
                            if (sk.IsTracked)
                            {
                                skels.Add(sk);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutLPosition.SliceCount = cnt;
                    this.FOutRPosition.SliceCount = cnt;
                    FOutLConfidence.SliceCount = cnt;
                    FOutRConfidence.SliceCount = cnt;
                    FOutLState.SliceCount = cnt;
                    FOutRState.SliceCount = cnt;
                    this.FOutUserIndex.SliceCount = cnt;
                    this.FOutFrameNumber[0] = this.frameid;

                    for (int i = 0; i < cnt; i++)
                    {
                        Body sk = skels[i];

                        Joint lhand = sk.Joints[JointType.HandLeft];
                        this.FOutLPosition[i] = new Vector3(lhand.Position.X, lhand.Position.Y, lhand.Position.Z);

                        Joint rhand = sk.Joints[JointType.HandRight];
                        this.FOutRPosition[i] = new Vector3(rhand.Position.X, rhand.Position.Y, rhand.Position.Z);

                        FOutLConfidence[i] = sk.HandLeftConfidence;
                        FOutLState[i] = sk.HandLeftState;

                        FOutRConfidence[i] = sk.HandRightConfidence;
                        FOutRState[i] = sk.HandRightState;

                        this.FOutUserIndex[i] = (int)sk.TrackingId;

                    }
                }
                else
                {
                    this.FOutCount[0] = 0;
                    this.FOutLPosition.SliceCount = 0;
                    this.FOutRPosition.SliceCount = 0;
                    FOutRState.SliceCount = 0;
                    FOutRConfidence.SliceCount = 0;
                    FOutLState.SliceCount = 0;
                    FOutLConfidence.SliceCount = 0;
                    this.FOutUserIndex.SliceCount = 0;
                    this.FOutFrameNumber[0] = 0;
                }
                this.FInvalidate = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }

                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                lock (m_lock)
                {
                    this.FOutId.SliceCount = this.LastGestures.Count;
                    this.FOutType.SliceCount = this.LastGestures.Count;

                    int cnt = 0;
                    foreach (int k in this.LastGestures.Keys)
                    {
                        this.FOutId[cnt] = k;

                         GestureFrame gf = this.LastGestures[k];

                        this.FOutType[cnt] = gf.Gesture;

                        this.FOutNew[cnt] = gf.IsNew;

                        gf.IsNew = false;
                        cnt++;
                    }
                }

                this.FInvalidate = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.source = new PreposeGestures.PreposeGesturesFrameSource(this.runtime.Runtime, 0);
                        this.reader = this.source.OpenReader();
                        this.reader.FrameArrived += Reader_FrameArrived;
                        this.reader.IsPaused = true;
                    }
                }
                else
                {
                    //this.runtime.SkeletonFrameReady -= SkeletonReady;
                    this.reader.FrameArrived -= this.Reader_FrameArrived;
                    this.source.Dispose();

                }

                this.FInvalidateConnect = false;
            }

            if (this.source != null)
            {
                ulong id = 0;
                try
                {
                    id = ulong.Parse(this.FInId[0]);
                }
                catch
                {

                }
                this.source.TrackingId = id;
                this.reader.IsPaused = this.FInPaused[0];
            }

            if (this.FInScript.IsChanged)
            {
                string str = this.FInScript[0];
                var app = PreposeGestures.App.ReadAppText(str);

                this.FOutGestures.SliceCount = app.Gestures.Count;
                this.FOutGestures.AssignFrom(app.Gestures.Select(gs => gs.Name));

                this.source.Gestures.Clear();
                foreach (Gesture g in app.Gestures)
                {
                    this.source.AddGesture(g);
                }

            }

            this.source.myMatcher.Precision = Convert.ToInt32(this.FInPrecision[0] * 100.0);

            this.FOutPaused[0] = this.reader != null ? this.reader.IsPaused : true;
            this.FOuTrackingId[0] = this.source.TrackingId.ToString();
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FTextureOutput[0] == null) { this.FTextureOutput[0] = new DX11Resource<DX11DynamicTexture2D>(); }

            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.OnRuntimeDisconnected();
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];
                    this.OnRuntimeConnected();
                }
                else
                {
                    this.OnRuntimeDisconnected();
                }

                this.FInvalidateConnect = false;
            }

            this.OnEvaluate();

            this.FOutFrameIndex[0] = this.frameindex;
        }
Exemple #9
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    this.runtime.SkeletonFrameReady += SkeletonReady;

                    if (runtime != null)
                    {
                        FaceFrameFeatures faceFrameFeatures =
                            FaceFrameFeatures.BoundingBoxInColorSpace
                            | FaceFrameFeatures.PointsInColorSpace
                            | FaceFrameFeatures.RotationOrientation
                            | FaceFrameFeatures.FaceEngagement
                            | FaceFrameFeatures.Glasses
                            | FaceFrameFeatures.Happy
                            | FaceFrameFeatures.LeftEyeClosed
                            | FaceFrameFeatures.RightEyeClosed
                            | FaceFrameFeatures.LookingAway
                            | FaceFrameFeatures.MouthMoved
                            | FaceFrameFeatures.MouthOpen;

                        for (int i = 0; i < this.faceFrameSources.Length; i++)
                        {
                            this.faceFrameSources[i] = new FaceFrameSource(this.runtime.Runtime, 0, faceFrameFeatures);
                            this.faceFrameReaders[i] = this.faceFrameSources[i].OpenReader();
                            this.faceFrameReaders[i].FrameArrived += this.faceReader_FrameArrived;
                        }
                    }
                }
                else
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                    for (int i = 0; i < this.faceFrameSources.Length; i++)
                    {
                        this.faceFrameReaders[i].FrameArrived -= this.faceReader_FrameArrived;
                        this.faceFrameReaders[i].Dispose();
                        this.faceFrameSources[i].Dispose();
                    }
                }

                this.FInvalidateConnect = false;
            }

            List<FaceFrameResult> results = new List<FaceFrameResult>();

            for (int i = 0; i < lastResults.Length; i++)
            {
                if (this.lastResults[i] != null && this.faceFrameReaders[i].FaceFrameSource.IsTrackingIdValid)
                {
                    results.Add(lastResults[i]);
                }
            }

            this.FOutWearGlasses.SliceCount = results.Count;
            this.FOutUserIndex.SliceCount = results.Count;
            this.FOutSizeInfrared.SliceCount = results.Count;
            this.FOutSizeColor.SliceCount = results.Count;
            this.FOutRightEyeClosed.SliceCount = results.Count;
            this.FOutPositionInfrared.SliceCount = results.Count;
            this.FOutPositionColor.SliceCount = results.Count;
            this.FOutPointsColor.SliceCount = results.Count;
            this.FOutOrientation.SliceCount = results.Count;
            this.FOutMouthOpen.SliceCount = results.Count;
            this.FOutMouthMoved.SliceCount = results.Count;
            this.FOutlookAway.SliceCount = results.Count;
            this.FOutLeftEyeClosed.SliceCount = results.Count;
            this.FOutHappy.SliceCount = results.Count;
            this.FOutEngaged.SliceCount = results.Count;
            this.FOutPointsWorld.SliceCount = results.Count;

            for (int i = 0; i < results.Count; i++)
            {
                this.WriteFaceData(results[i], i);
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }

                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List<Skeleton> skels = new List<Skeleton>();
                    float z = float.MaxValue;
                    int id = -1;

                    lock (m_lock)
                    {

                        foreach (Skeleton sk in this.lastframe)
                        {
                            if (sk.TrackingState == SkeletonTrackingState.Tracked)
                            {
                                skels.Add(sk);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutPosition.SliceCount = cnt;
                    this.FOutUserIndex.SliceCount = cnt;
                    this.FOutClipped.SliceCount = cnt;
                    this.FOutJointPosition.SliceCount = cnt * 20;
                    this.FOutJointColorPosition.SliceCount = cnt * 20;
                    this.FOutJointDepthPosition.SliceCount = cnt * 20;
                    this.FOutJointState.SliceCount = cnt * 20;
                    this.FOutJointID.SliceCount = cnt * 20;
                    this.FOutJointOrientation.SliceCount = cnt * 20;
                    this.FOutJointWOrientation.SliceCount = cnt * 20;
                    this.FOutJointTo.SliceCount = cnt * 20;
                    this.FOutJointFrom.SliceCount = cnt * 20;
                    this.FOutFrameNumber[0] = this.frameid;

                    int jc = 0;
                    for (int i = 0; i < cnt; i++)
                    {
                        Skeleton sk = skels[i];
                        this.FOutPosition[i] = new Vector3(sk.Position.X, sk.Position.Y, sk.Position.Z);
                        this.FOutUserIndex[i] = sk.TrackingId;

                        Vector4 clip = Vector4.Zero;
                        clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                        clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                        clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                        clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                        this.FOutClipped[i] = clip;

                        foreach (Joint joint in sk.Joints)
                        {
                            this.FOutJointFrom[jc] = sk.BoneOrientations[joint.JointType].StartJoint.ToString();
                            this.FOutJointTo[jc] = sk.BoneOrientations[joint.JointType].EndJoint.ToString();
                            BoneRotation bo = sk.BoneOrientations[joint.JointType].HierarchicalRotation;
                            BoneRotation bow = sk.BoneOrientations[joint.JointType].AbsoluteRotation;
                            this.FOutJointID[jc] = joint.JointType.ToString();
                            this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);

                            ColorImagePoint cp = this.runtime.Runtime.MapSkeletonPointToColor(joint.Position, ColorImageFormat.RgbResolution640x480Fps30);
                            this.FOutJointColorPosition[jc] = new Vector2(cp.X, cp.Y);
                            DepthImagePoint dp = this.runtime.Runtime.MapSkeletonPointToDepth(joint.Position, DepthImageFormat.Resolution320x240Fps30);
                            this.FOutJointDepthPosition[jc] = new Vector4(dp.X, dp.Y, dp.Depth, dp.PlayerIndex);

                            this.FOutJointOrientation[jc] = new Quaternion(bo.Quaternion.X, bo.Quaternion.Y, bo.Quaternion.Z, bo.Quaternion.W);
                            this.FOutJointWOrientation[jc] = new Quaternion(bow.Quaternion.X, bow.Quaternion.Y, bow.Quaternion.Z, bow.Quaternion.W);
                            this.FOutJointState[jc] = joint.TrackingState.ToString();
                            jc++;
                        }
                    }
                }
                else
                {
                    this.FOutCount[0] = 0;
                    this.FOutPosition.SliceCount = 0;
                    this.FOutUserIndex.SliceCount = 0;
                    this.FOutJointID.SliceCount = 0;
                    this.FOutJointPosition.SliceCount = 0;
                    this.FOutJointState.SliceCount = 0;
                    this.FOutFrameNumber[0] = 0;
                    this.FOutJointOrientation.SliceCount = 0;
                    this.FOutJointWOrientation.SliceCount = 0;
                    this.FOutJointTo.SliceCount = 0;
                    this.FOutJointFrom.SliceCount = 0;
                    this.FOutJointColorPosition.SliceCount = 0;
                    this.FOutJointDepthPosition.SliceCount = 0;
                }
                this.FInvalidate = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                    if (this.vgbFrameReader != null)
                    {
                        this.vgbFrameReader.FrameArrived -= vgbFrameReader_FrameArrived;
                        this.vgbFrameReader.Dispose();
                        this.vgbFrameReader = null;
                    }
                    if (this.vgbFrameSource != null)
                    {
                        this.vgbFrameSource.Dispose();
                        this.vgbFrameSource = null;
                    }
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.vgbFrameSource = new VisualGestureBuilderFrameSource(this.runtime.Runtime, 0);
                        this.vgbFrameReader = this.vgbFrameSource.OpenReader();
                        this.vgbFrameReader.FrameArrived += vgbFrameReader_FrameArrived;
                        this.runtime.SkeletonFrameReady += SkeletonReady;
                    }

                }
                this.FInvalidateConnect = false;
            }

            if (this.gesturefile.IsChanged)
            {
                string s = this.gesturefile[0];

                this.Reset();

                try
                {
                    this.database = new VisualGestureBuilderDatabase(s);

                    this.gesturenames.SliceCount = (int)this.database.AvailableGesturesCount;
                    this.gesturetype.SliceCount = this.gesturenames.SliceCount;
                    this.gesturedetected.SliceCount = this.gesturenames.SliceCount;
                    this.gestureconfidence.SliceCount = this.gesturenames.SliceCount;
                    this.gestureprogress.SliceCount = this.gesturenames.SliceCount;

                    int cnt = 0;
                    foreach (Gesture g in database.AvailableGestures)
                    {
                        this.gesturenames[cnt] = g.Name;
                        this.gesturetype[cnt] = g.GestureType;
                        this.vgbFrameSource.AddGesture(g);
                        cnt++;
                    }
                }
                catch (Exception ex)
                {
                    this.logger.Log(ex);
                }
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    stream = new InteractionStream(this.FInRuntime[0].Runtime, new InteractionClientTest());
                    stream.InteractionFrameReady += stream_InteractionFrameReady;
                    this.runtime = this.FInRuntime[0];
                    this.runtime.SkeletonFrameReady += runtime_SkeletonFrameReady;
                    this.runtime.DepthFrameReady += this.runtime_DepthFrameReady;
                }
                else
                {
                    if (stream != null)
                    {
                        this.runtime.SkeletonFrameReady -= runtime_SkeletonFrameReady;
                        this.runtime.DepthFrameReady -= this.runtime_DepthFrameReady;
                        stream.InteractionFrameReady -= stream_InteractionFrameReady;
                        stream.Dispose();
                        stream = null;
                        this.runtime = null;
                    }
                }

                this.FInvalidateConnect = false;
            }

            List<UserInfo> infs = new List<UserInfo>();

            for (int i = 0; i < this.infos.Length;i++)
            {
                if (this.infos[i] != null)
                {
                    if (this.infos[i].SkeletonTrackingId != 0)
                    {
                        infs.Add(this.infos[i]);
                    }
                }
            }

            this.FOutSkelId.SliceCount = infs.Count;
            this.FOutUI.SliceCount = infs.Count;

            for (int i = 0; i < infs.Count; i++)
            {
                UserInfo ui = infs[i];
                this.FOutSkelId[i] = ui.SkeletonTrackingId;
                this.FOutUI[i] = ui;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FOutGeom[0] == null)
            {
                this.FOutGeom[0] = new DX11Resource<DX11IndexOnlyGeometry>();
                this.FOutFaceVertices[0] = new DX11Resource<IDX11ReadableStructureBuffer>();
                this.FOutFaceUV[0] = new DX11Resource<IDX11ReadableStructureBuffer>();
            }

            if (this.FInvalidateConnect)
            {
                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        //this.runtime.SkeletonFrameReady += SkeletonReady;
                        this.faceFrameSource = new HighDefinitionFaceFrameSource(this.runtime.Runtime);
                        this.faceFrameReader = this.faceFrameSource.OpenReader();
                        this.faceFrameReader.FrameArrived += this.faceReader_FrameArrived;
                        this.faceFrameReader.IsPaused = true;
                    }
                }
                else
                {
                    //this.runtime.SkeletonFrameReady -= SkeletonReady;
                    this.faceFrameReader.FrameArrived -= this.faceReader_FrameArrived;
                    this.faceFrameReader.Dispose();

                }

                this.FInvalidateConnect = false;
            }

            if (this.faceFrameSource != null)
            {
                ulong id = 0;
                try
                {
                    id = ulong.Parse(this.FInId[0]);
                }
                catch
                {

                }
                this.faceFrameSource.TrackingId = id;
                this.faceFrameReader.IsPaused = this.FInPaused[0];
            }

            this.FOutPaused[0] = this.faceFrameReader != null ? this.faceFrameReader.IsPaused : true;
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }

                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List<Body> skels = new List<Body>();
                    float z = float.MaxValue;
                    int id = -1;

                    lock (m_lock)
                    {

                        foreach (Body sk in this.lastframe)
                        {
                            if (sk.IsTracked)
                            {
                                skels.Add(sk);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutPosition.SliceCount = cnt;
                    this.FOutUserIndex.SliceCount = cnt;
                    this.FOutClipped.SliceCount = cnt;
                    this.FOutJointPosition.SliceCount = cnt * 25;
                    this.FOutJointState.SliceCount = cnt * 25;
                    this.FOutJointID.SliceCount = cnt * 25;
                    this.FOutJointOrientation.SliceCount = cnt * 25;
                    this.FOutFrameNumber[0] = this.frameid;
                    this.FOutWearGlasses.SliceCount = cnt;
                    this.FOutHappy.SliceCount = cnt;
                    this.FOutNeutral.SliceCount = cnt;

                    int jc = 0;
                    for (int i = 0; i < cnt; i++)
                    {
                        Body sk = skels[i];

                        Joint ce = sk.Joints[JointType.SpineBase];
                        this.FOutPosition[i] = new Vector3(ce.Position.X, ce.Position.Y, ce.Position.Z);
                        this.FOutUserIndex[i] = (int)sk.TrackingId;
                        this.FOutWearGlasses[i] = sk.Appearance[Appearance.WearingGlasses];
                        this.FOutHappy[i] = sk.Expressions[Expression.Happy];
                        this.FOutNeutral[i] = sk.Expressions[Expression.Neutral];

                        //var t = sk.Expressions[Expression.]

                        Vector4 clip = Vector4.Zero;
                        clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                        clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                        clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                        clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                        this.FOutClipped[i] = clip;

                        foreach (Joint joint in sk.Joints.Values)
                        {
                            Microsoft.Kinect.Vector4 bo = sk.JointOrientations[joint.JointType].Orientation;
                            this.FOutJointID[jc] = joint.JointType.ToString();
                            this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);

                            this.FOutJointOrientation[jc] = new Quaternion(bo.X, bo.Y, bo.Z, bo.W);
                            this.FOutJointState[jc] = joint.TrackingState.ToString();
                            jc++;
                        }
                    }
                }
                else
                {
                    this.FOutCount[0] = 0;
                    this.FOutPosition.SliceCount = 0;
                    this.FOutUserIndex.SliceCount = 0;
                    this.FOutJointID.SliceCount = 0;
                    this.FOutJointPosition.SliceCount = 0;
                    this.FOutJointState.SliceCount = 0;
                    this.FOutFrameNumber[0] = 0;
                    this.FOutJointOrientation.SliceCount = 0;
                    this.FOutWearGlasses.SliceCount = 0;
                }
                this.FInvalidate = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            this.VoxelResolutionX = this.FInVX[0];
            this.VoxelResolutionY = this.FInVY[0];
            this.VoxelResolutionZ = this.FInVZ[0];
            this.VoxelsPerMeter = this.FInVPM[0];

            if (this.FTextureOutput[0] == null) { this.FTextureOutput[0] = new DX11Resource<DX11DynamicTexture2D>(); }
            if (this.FPCOut[0] == null) { this.FPCOut[0] = new DX11Resource<IDX11ReadableStructureBuffer>(); }
            if (this.FGeomOut[0] == null) { this.FGeomOut[0] = new DX11Resource<DX11IndexedGeometry>(); }

            if (this.FOutVoxels[0] == null) { this.FOutVoxels[0] = new DX11Resource<IDX11ReadableStructureBuffer>(); }

            if (this.FInExport[0]) { this.FGeomOut[0].Dispose(); this.FGeomOut[0] = new DX11Resource<DX11IndexedGeometry>(); }

            if (this.FInvalidateConnect)
            {
                this.FInvalidateConnect = false;

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    this.runtime = this.FInRuntime[0];
                    this.runtime.DepthFrameReady += this.runtime_DepthFrameReady;

                    var volParam = new ReconstructionParameters(VoxelsPerMeter, VoxelResolutionX, VoxelResolutionY, VoxelResolutionZ);
                    this.worldToCameraTransform = Matrix4.Identity;

                    //this.volume = Reconstruction.FusionCreateReconstruction(volParam, ProcessorType, 0, this.worldToCameraTransform);
                    this.colorVolume = ColorReconstruction.FusionCreateReconstruction(volParam, ProcessorType, 0, this.worldToCameraTransform);

                    //this.volume.
                    /*FusionPointCloudImageFrame pc;
                    pc.*/

                    this.defaultWorldToVolumeTransform = this.colorVolume.GetCurrentWorldToVolumeTransform();

                    // Depth frames generated from the depth input
                    this.depthFloatBuffer = new FusionFloatImageFrame(width, height);

                    // Point cloud frames generated from the depth float input
                    this.pointCloudBuffer = new FusionPointCloudImageFrame(width, height);

                    // Create images to raycast the Reconstruction Volume
                    this.shadedSurfaceColorFrame = new FusionColorImageFrame(width, height);

                    this.ResetReconstruction();
                }
            }

            if (this.runtime != null)
            {
                bool needreset = this.FInReset[0];

                if (needreset) { this.ResetReconstruction(); }
            }
        }