public void synchronize(
            ReplayDepthImageFrame depthFrame,
            ReplayColorImageFrame colorFrame,
            ReplaySkeletonFrame skletonFrame,
            Boolean isPauseMode
            )
        {
            IsPauseMode = isPauseMode;
            colorFrame.CopyPixelDataTo(_colorByte);
            depthFrame.CopyPixelDataTo(_depthShort);
            for (int i = 0; i < _pixelDepthDataLength; i++)
            {
                _depthByte[i] = (byte)(_depthShort[i] * 0.064-1);
            }

            _isCreation = true;
            IsSkeletonDetected = skletonFrame.IsSkeletonDetected;

            if (skletonFrame.IsSkeletonDetected)
            {
                UserSkeleton[SkeletonDataType.RIGHT_HAND] = new Point(
                    skletonFrame.RightHandPositionX,
                    skletonFrame.RightHandPositionY
                    );

                UserSkeleton[SkeletonDataType.LEFT_HAND] = new Point(
                    skletonFrame.LeftHandPositionX,
                    skletonFrame.LeftHandPositionY
                    );

                UserSkeleton[SkeletonDataType.SPINE] = new Point(
                    skletonFrame.SpinePositionX,
                    skletonFrame.SpinePositionY
                    );
            }
            _isCreation = false;
        }
示例#2
0
		private void UpdateSkeletons(ReplaySkeletonFrame frame)
		{
			_skeletons = frame.Skeletons;
			var trackedSkeleton = _skeletons.FirstOrDefault(s => s.TrackingState == SkeletonTrackingState.Tracked);

			if (trackedSkeleton == null)
				return;

			DrawJoints(trackedSkeleton);
		}
示例#3
0
        private void ProcessSkeletonFrame(ReplaySkeletonFrame skeletonFrame)
        {
            if (skeletonFrame == null)
                return;
            _skeletons = skeletonFrame.Skeletons;

            var trackedSkeleton = _skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked).ToList();

            if (!trackedSkeleton.Any())
                return;

            //Assumptions: Player 1 on left side of screen with saber in right hand, Player 2 on right side of screen with saber in left hand
            trackedSkeleton = trackedSkeleton.OrderBy(s => s.Joints[JointType.Spine].Position.X).ToList();

            DrawSaber(trackedSkeleton[0], Sabre1, FightingHand.Right, HulkMode);
            GameMode = false;

            if (trackedSkeleton.Count <= 1) return;

            GameMode = true;
            DrawSaber(trackedSkeleton[1], Sabre2, FightingHand.Left, false);
            DetectSaberCollision();
            DetectPlayerHit(trackedSkeleton[0], trackedSkeleton[1], Sabre1, Sabre2);
        }
		internal void AddFrames(BinaryReader reader)
		{
			//not the best of approaches - assuming that color frame is the 1st frame followed by depth and skeleton frame
			while (reader.BaseStream.Position < reader.BaseStream.Length)
			{
				var header = (FrameType)reader.ReadInt32();
				switch (header)
				{
					case FrameType.Color:
						var colorFrame = new ReplayColorImageFrame();
						colorFrame.CreateFromReader(reader);
						frames.Add(new ReplayAllFrames { ColorImageFrame = colorFrame });
						break;
					case FrameType.Depth:

						var depthFrame = new ReplayDepthImageFrame();
						depthFrame.CreateFromReader(reader);
						if (frames.Any())
							frames.Last().DepthImageFrame = depthFrame;
						break;
					case FrameType.Skeletons:
						var skeletonFrame = new ReplaySkeletonFrame();
						skeletonFrame.CreateFromReader(reader);
						if (frames.Any())
							frames.Last().SkeletonFrame = skeletonFrame;
						break;
				}
			}
		}
        //public void initialstore(ReplaySkeletonFrame frame, int framenumber)


        public void storeframe(ReplaySkeletonFrame frame, int framenumber, CoordinateMapper replayCoordinateMapper)
        {
            //int framenumber;
            double leftShoulderAngle, leftHipAngle, leftKneeAngle, headHeight;
            double headX, headY, leftHandX, leftHandY, rightHandX, rightHandY;
            double leftshoulderX, leftshoulderY, rightshoulderX, rightshoulderY;
            double hipX, hipY, leftKneeX, leftKneeY, rightKneeX, rightKneeY;
            double leftFootX, leftFootY, rightFootX, rightFootY;

            //side view

            double headYabs, headZabs, leftHandYabs, leftHandZabs;
            double leftshoulderYabs, leftshoulderZabs, hipYabs, hipZabs;
            double leftKneeYabs, leftKneeZabs, leftFootYabs, leftFootZabs;



            if (isStartingFrame == true)
            {
                initialFrameNumber = framenumber;
                System.Console.WriteLine("initialFrame = " + initialFrameNumber);
                isStartingFrame = false;

            }

            if (frame == null)
            {
                //currentFrameNumber = framenumber - initialFrameNumber;
                leftShoulderAngle = 999;
                leftHipAngle = 999;
                leftKneeAngle = 999;
                headHeight = 999;
                headX = 999;
                headY = 999;
                leftHandX = 999;
                leftHandY = 999;
                rightHandX = 999;
                rightHandY = 999;
                leftshoulderX = 999;
                leftshoulderY = 999;
                rightshoulderX = 999;
                rightshoulderY = 999;
                hipX = 999;
                hipY = 999;
                leftKneeX = 999; 
                leftKneeY = 999;
                rightKneeX = 999;
                rightKneeY = 999;
                leftFootX = 999;
                leftFootY = 999;
                rightFootX = 999;
                rightFootY = 999;

                //side view
                headYabs = 999;
                headZabs = 999;
                leftHandYabs = 999;
                leftHandZabs = 999;
                leftshoulderYabs = 999;
                leftshoulderZabs = 999;
                hipYabs = 999;
                hipZabs = 999;
                leftKneeYabs = 999;
                leftKneeZabs = 999;
                leftFootYabs = 999;
                leftFootZabs = 999;
                

                //currentFrameNumber++;
            }

            else
            {


                var trackedSkeleton = frame.Skeletons.FirstOrDefault(a => a.TrackingState == SkeletonTrackingState.Tracked);
                //IMPORTATNT: 23 occurences frame here for deadlift1.replay
                if (trackedSkeleton == null)
                    return;

                //set starting frame of the video to index 1
                //framenumber = frame.FrameNumber - initialFrameNumber + 1;
                //currentFrameNumber = framenumber;
                leftShoulderAngle = JointAngle(trackedSkeleton.Joints[JointType.ShoulderLeft], trackedSkeleton.Joints[JointType.WristLeft], trackedSkeleton.Joints[JointType.HipLeft]);
                leftHipAngle = JointAngle(trackedSkeleton.Joints[JointType.HipLeft], trackedSkeleton.Joints[JointType.ShoulderLeft], trackedSkeleton.Joints[JointType.KneeLeft]);
                leftKneeAngle = JointAngle(trackedSkeleton.Joints[JointType.KneeLeft], trackedSkeleton.Joints[JointType.FootLeft], trackedSkeleton.Joints[JointType.HipLeft]);
                headHeight = trackedSkeleton.Joints[JointType.Head].Position.Y;
                //frontal view
                headX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.Head].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                headY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.Head].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                leftHandX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.HandLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                leftHandY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.HandLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                rightHandX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.HandRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                rightHandY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.HandRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                leftshoulderX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.ShoulderLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                leftshoulderY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.ShoulderLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                rightshoulderX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.ShoulderRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                rightshoulderY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.ShoulderRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                hipX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.HipCenter].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                hipY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.HipCenter].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                leftKneeX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.KneeLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                leftKneeY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.KneeLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                rightKneeX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.KneeRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                rightKneeY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.KneeRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                leftFootX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.FootLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                leftFootY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.FootLeft].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;
                rightFootX = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.FootRight].Position, ColorImageFormat.RgbResolution640x480Fps30).X;
                rightFootY = replayCoordinateMapper.MapSkeletonPointToColorPoint(trackedSkeleton.Joints[JointType.FootRight].Position, ColorImageFormat.RgbResolution640x480Fps30).Y;


                //side view 22/03/2013
                headYabs = trackedSkeleton.Joints[JointType.Head].Position.Y;
                headZabs = trackedSkeleton.Joints[JointType.Head].Position.Z;
                leftHandYabs = trackedSkeleton.Joints[JointType.HandLeft].Position.Y;
                leftHandZabs = trackedSkeleton.Joints[JointType.HandLeft].Position.Z;
                leftshoulderYabs = trackedSkeleton.Joints[JointType.ShoulderLeft].Position.Y;
                leftshoulderZabs = trackedSkeleton.Joints[JointType.ShoulderLeft].Position.Z;
                hipYabs = trackedSkeleton.Joints[JointType.HipCenter].Position.Y;
                hipZabs = trackedSkeleton.Joints[JointType.HipCenter].Position.Z;
                leftKneeYabs = trackedSkeleton.Joints[JointType.KneeLeft].Position.Y;
                leftKneeZabs = trackedSkeleton.Joints[JointType.KneeLeft].Position.Z;
                leftFootYabs = trackedSkeleton.Joints[JointType.FootLeft].Position.Y;
                leftFootZabs = trackedSkeleton.Joints[JointType.FootLeft].Position.Z;
                

            }

            currentFrameNumber = framenumber - initialFrameNumber + 1;
            //System.Console.WriteLine("framenumber = " + framenumber);
            //System.Console.WriteLine("initialFrameNumber = " + initialFrameNumber);
            //System.Console.WriteLine("currentFrameNumber = " + currentFrameNumber);
            Framedata currentframe = new Framedata(currentFrameNumber, leftHipAngle, leftShoulderAngle, leftKneeAngle, headHeight, headX, headY, leftHandX, leftHandY, rightHandX, rightHandY, leftshoulderX, leftshoulderY, rightshoulderX, rightshoulderY, hipX, hipY, leftKneeX, leftKneeY, rightKneeX, rightKneeY, leftFootX, leftFootY, rightFootX, rightFootY, headYabs, headZabs, leftHandYabs, leftHandZabs, leftshoulderYabs, leftshoulderZabs, hipYabs, hipZabs, leftKneeYabs, leftKneeZabs, leftFootYabs, leftFootZabs);
            jointsdata.Add(currentframe);



        }