예제 #1
0
        /**
         * Zeichnet ein Item
         */
        private void RenderAccessoryItem(DrawingContext drawingContext, Skeleton person, AccessoryItem item)
        {
            SkeletonPoint headPos = person.Joints[JointType.Head].Position;

            ColorImagePoint colorImagePoint = _sensor.CoordinateMapper.MapSkeletonPointToColorPoint(headPos,
                                                                                                    _sensor.ColorStream
                                                                                                    .Format);

            double g           = item.Width; // Objektgroesse in m.
            double r           = headPos.Z;  // Entfernung in m.
            double imgWidth    = 2 * Math.Atan(g / (2 * r)) * ActualWidth;
            double aspectRatio = item.Image.Width / item.Image.Height;
            double imgHeight   = imgWidth / aspectRatio;

            double offsetX = 0, offsetY = 0;

            switch (item.Position)
            {
            case AccessoryPositon.Hat:
                offsetY = -1.1 * imgHeight;
                break;

            case AccessoryPositon.Beard:
                offsetY = imgHeight / 4;
                break;
            }

            double headX = colorImagePoint.X * (ActualWidth / _sensor.ColorStream.FrameWidth) + offsetX;
            double headY = colorImagePoint.Y * (ActualHeight / _sensor.ColorStream.FrameHeight) + offsetY;

            AccessoryRect = new Rect(headX - imgWidth / 2, headY, imgWidth, imgHeight);
            drawingContext.DrawImage(item.Image, AccessoryRect);
        }
예제 #2
0
 private void SetNewHat()
 {
     Accessories.AccessoryItems.Clear();
     AccessoryItem hat = new AccessoryItem(AccessoryPositon.Hat, _currentOffer.Category.CategoryId, _gender == "Female" ? true : false);
     Accessories.AccessoryItems.Add(hat);
 }
예제 #3
0
        /**
         * Zeichnet ein Item
         */
        private void RenderAccessoryItem(DrawingContext drawingContext, Skeleton person, AccessoryItem item)
        {
            SkeletonPoint headPos = person.Joints[JointType.Head].Position;

            ColorImagePoint colorImagePoint = _sensor.CoordinateMapper.MapSkeletonPointToColorPoint(headPos,
                                                                                                    _sensor.ColorStream
                                                                                                           .Format);

            double g = item.Width; // Objektgroesse in m.
            double r = headPos.Z;  // Entfernung in m.
            double imgWidth = 2 * Math.Atan(g / (2 * r)) * ActualWidth;
            double aspectRatio = item.Image.Width / item.Image.Height;
            double imgHeight = imgWidth / aspectRatio;

            double offsetX = 0, offsetY = 0;
            switch (item.Position)
            {
                case AccessoryPositon.Hat:
                    offsetY = -1.1*imgHeight;
                    break;
                case AccessoryPositon.Beard:
                    offsetY = imgHeight/4;
                    break;
            }

            double headX = colorImagePoint.X * (ActualWidth / _sensor.ColorStream.FrameWidth) + offsetX;
            double headY = colorImagePoint.Y * (ActualHeight / _sensor.ColorStream.FrameHeight) + offsetY;

            AccessoryRect = new Rect(headX - imgWidth / 2, headY, imgWidth, imgHeight);
            drawingContext.DrawImage(item.Image, AccessoryRect);
        }