コード例 #1
0
        public SubjectView()
        {
            input      = (EinputMode)Enum.Parse(typeof(EinputMode), ConfigurationManager.AppSettings["inputMode"], true);
            projection = (EprojectionMode)Enum.Parse(typeof(EprojectionMode), ConfigurationManager.AppSettings["projectionMode"], true);
            Boolean.TryParse(ConfigurationManager.AppSettings["drawSkeleton"], out drawSkeleton);
            Boolean.TryParse(ConfigurationManager.AppSettings["drawLineModel"], out drawLineModel);
            Boolean.TryParse(ConfigurationManager.AppSettings["drawSilhouette"], out drawSilhouette);
            Boolean.TryParse(ConfigurationManager.AppSettings["drawGrid"], out drawGrid);
            float.TryParse(ConfigurationManager.AppSettings["xRange"], out xRange);
            float.TryParse(ConfigurationManager.AppSettings["yRange"], out yRange);
            float.TryParse(ConfigurationManager.AppSettings["zRange"], out zRange);
            InitializeComponent();
            if (drawGrid)
            {
                sideGrid = new Line[17];
                for (int i = 0; i < sideGrid.Length; i++)
                {
                    Line l = new Line();
                    sideGrid[i]       = l;
                    l.StrokeThickness = 1;
                    l.Stroke          = new SolidColorBrush(Colors.Gray);
                    l.Opacity         = 0.25;
                    sideView.Children.Add(l);
                }
                sideLabels = new Label[7];
                for (int i = 0; i < sideLabels.Length; i++)
                {
                    Label l = new Label
                    {
                        Content  = (i + 1).ToString(),
                        FontSize = 10,
                        Opacity  = 0.25
                    };
                    sideView.Children.Add(l);
                    sideLabels[i] = l;
                }
                frontGrid = new Line[7];
                for (int i = 0; i < frontGrid.Length; i++)
                {
                    Line l = new Line();
                    frontGrid[i]      = l;
                    l.StrokeThickness = 1;
                    l.Stroke          = new SolidColorBrush(Colors.Gray);
                    l.Opacity         = 0.25;
                    frontView.Children.Add(l);
                }
                frontLabels = new Label[7];
                for (int i = 0; i < frontLabels.Length; i++)
                {
                    Label l = new Label();
                    if (i == 0)
                    {
                        l.Content = "left";
                    }
                    else if (i == frontLabels.Length - 1)
                    {
                        l.Content = "right";
                    }
                    else
                    {
                        l.Content = ((0.5 + i - frontLabels.Length * 0.5) * 0.5).ToString();
                    }
                    l.FontSize = 10;
                    l.Opacity  = 0.25;
                    frontView.Children.Add(l);
                    frontLabels[i] = l;
                }
            }
            if (drawSkeleton)
            {
                frontViewBones = new Line[bonesEndPoints.Length / 2];
                sideViewBones  = new Line[bonesEndPoints.Length / 2];
                for (int i = 0; i < frontViewBones.Length; i++)
                {
                    Line l = new Line();
                    frontViewBones[i] = l;
                    l.StrokeThickness = 4;
                    frontView.Children.Add(l);
                    l = new Line();
                    sideViewBones[i]  = l;
                    l.StrokeThickness = 4;
                    sideView.Children.Add(l);
                }
            }
            if (drawLineModel)
            {
                frontStick = new Line
                {
                    Stroke          = Brushes.Maroon,
                    StrokeThickness = 1,
                    StrokeDashArray = new DoubleCollection()
                    {
                        4
                    }
                };
                frontView.Children.Add(frontStick);

                frontAngel = new Label
                {
                    FontSize   = 20,
                    Foreground = Brushes.Maroon
                };
                frontView.Children.Add(frontAngel);

                sideStick = new Line
                {
                    Stroke          = Brushes.Maroon,
                    StrokeThickness = 1,
                    StrokeDashArray = new DoubleCollection()
                    {
                        4
                    }
                };
                sideView.Children.Add(sideStick);

                sideAngel = new Label
                {
                    FontSize   = 20,
                    Foreground = Brushes.Maroon
                };
                sideView.Children.Add(sideAngel);
            }
            this.SizeChanged += ViewChanged;
        }
コード例 #2
0
        public void getStickModelFromSilhouette(out float slopeX, out float slopeZ, out float offsetX, out float offsetZ, EprojectionMode projection)
        {
            float x, y, z;
            float silhouettexy = silhouette.depthMeanXY;
            float silhouetteyy = silhouette.depthMeanYY;
            float silhouetteyz = silhouette.depthMeanYZ;

            slopeX = slopeZ = offsetX = offsetZ = -1;
            x      = silhouette.depthMeanX;
            y      = silhouette.depthMeanY;
            z      = silhouette.depthMeanZ;
            if (projection == EprojectionMode.ground)
            {
                projectPointToTheGround(this, ref x, ref y, ref z, false);
                projectCovarianceToTheGround(this, out silhouettexy, out silhouetteyy, out silhouetteyz, false);
            }
            if ((silhouetteyy - y * y) < 1e-10)
            {
                x = z = 0;
                return;
            }
            slopeX  = (silhouettexy - x * y) / (silhouetteyy - y * y);
            slopeZ  = (silhouetteyz - z * y) / (silhouetteyy - y * y);
            offsetX = x - slopeX * y;
            offsetZ = z - slopeZ * y;
        }
コード例 #3
0
 public Trajectory()
 {
     input           = (EinputMode)Enum.Parse(typeof(EinputMode), ConfigurationManager.AppSettings["inputMode"], true);
     projection      = (EprojectionMode)Enum.Parse(typeof(EprojectionMode), ConfigurationManager.AppSettings["projectionMode"], true);
     useKinectGround = !(input == EinputMode.silhouetteLine || input == EinputMode.silhouetteMean);
 }
コード例 #4
0
        /// <summary>
        /// estimates the center of mass
        /// </summary>
        /// <param name="x"></param>
        /// <param name="z"></param>
        /// <param name="slopeX"></param>
        /// <param name="slopeZ"></param>
        /// <param name="input"></param>
        /// <param name="projection"></param>
        /// <returns>returns false if the quality of the frame is too low</returns>
        public bool getCOM(out float x, out float z, out float slopeX, out float slopeZ, out Extreams extreamValues, EinputMode input = EinputMode.line, EprojectionMode projection = EprojectionMode.ground)
        {
            slopeX = slopeZ = 0;
            float minX = -1, maxX = -1, minZ = -1, maxZ = -1;
            float y;

            if (input != EinputMode.wii && silhouette.points.Length > 0)
            {
                var halfX = silhouette.xRange / 2;
                minX = silhouette.points.Min(p => p.X) * silhouette.xRange / 256 - halfX;
                maxX = silhouette.points.Max(p => p.X) * silhouette.xRange / 256 - halfX;
                minZ = silhouette.points.Min(p => p.Z) * silhouette.zRange / 256;
                maxZ = silhouette.points.Max(p => p.Z) * silhouette.zRange / 256;
            }
            extreamValues = new Extreams(minX, maxX, minZ, maxZ, FrameTime);

            switch (input)
            {
            case EinputMode.wii:
                x = WiiBoardData.CenterOfPressureY / 1000;
                z = WiiBoardData.CenterOfPressureX / 1000;
                break;

            case EinputMode.mean:
                if (projection == EprojectionMode.ground)
                {
                    x = depthMeanX; y = depthMeanY; z = depthMeanZ;
                    projectPointToTheGround(this, ref x, ref y, ref z, true);
                }
                else
                {
                    x = depthMeanX;
                    z = depthMeanZ;
                }
                break;

            case EinputMode.silhouetteMean:
                if (silhouette.numberOfPixelsInBody < 10)
                {
                    x = z = -2;
                    return(false);
                }
                if (projection == EprojectionMode.ground)
                {
                    x = silhouette.depthMeanX; y = silhouette.depthMeanY; z = silhouette.depthMeanZ;
                    projectPointToTheGround(this, ref x, ref y, ref z, false);
                }
                else
                {
                    x = silhouette.depthMeanX;
                    z = silhouette.depthMeanZ;
                }
                break;

            case EinputMode.neck:
                getJointPosition(JointTypeGait.Neck, false, out x, out y, out z);
                if (projection == EprojectionMode.ground)
                {
                    projectPointToTheGround(this, ref x, ref y, ref z, true);
                }
                break;

            case EinputMode.line:
                float xy = depthMeanXY;
                float yy = depthMeanYY;
                float yz = depthMeanYZ;
                x = depthMeanX;
                y = depthMeanY;
                z = depthMeanZ;
                if (projection == EprojectionMode.ground)
                {
                    projectPointToTheGround(this, ref x, ref y, ref z, true);
                    projectCovarianceToTheGround(this, out xy, out yy, out yz, true);
                }
                slopeX = (xy - x * y) / (yy - y * y);
                slopeZ = (yz - z * y) / (yy - y * y);
                float offsetX = x - slopeX * y;
                float offsetZ = z - slopeZ * y;
                x = slopeX + offsetX;
                z = slopeZ + offsetZ;
                break;

            case EinputMode.silhouetteLine:
                if (silhouette.numberOfPixelsInBody < 10)
                {
                    x = z = -2;
                    return(false);
                }
                float silhouetteOffsetX;
                float silhouetteOffsetZ;
                getStickModelFromSilhouette(out slopeX, out slopeZ, out silhouetteOffsetX, out silhouetteOffsetZ, projection);
                x = slopeX + silhouetteOffsetX;
                z = slopeZ + silhouetteOffsetZ;
                break;

            default:
                throw new Exception("Unknown input mode");
            }
            return(true);
        }
コード例 #5
0
 public Trajectory(EinputMode input, EprojectionMode projection)
 {
     this.input      = input;
     this.projection = projection;
     useKinectGround = !(input == EinputMode.silhouetteLine || input == EinputMode.silhouetteMean);
 }