Esempio n. 1
0
        private void SpecialBottomPointsUpdate(List <HeadPoint> points)
        {
            var bottomPoints = new int[] { 9, 10, 11, 33, 32, 31 };

            for (var i = 0; i < bottomPoints.Length; ++i)
            {
                var point = points[bottomPoints[i]];
                var delta = MirroredHeadPoint.GetFrontWorldPoint(ProgramCore.Project.DetectedBottomPoints[i], ProgramCore.CurrentProgram) - point.Value;
                point.Value += delta;
                autodotsShapeHelper.Transform(point.Value, bottomPoints[i]);
            }

            var bottomPointsX = new int[] { 7, 8, 30, 29 };

            for (var i = 0; i < bottomPointsX.Length; ++i)
            {
                var point = points[bottomPointsX[i]];
                var delta = MirroredHeadPoint.GetFrontWorldPoint(ProgramCore.Project.DetectedBottomPoints[i + 6], ProgramCore.CurrentProgram) - point.Value;
                delta        = new Vector2(point.Value.X + delta.X, point.Value.Y) - point.Value;
                point.Value += delta;
                foreach (var l in point.LinkedPoints)
                {
                    var p = points[l];
                    p.Value += delta;
                    autodotsShapeHelper.Transform(p.Value, l);
                }
                autodotsShapeHelper.Transform(point.Value, bottomPointsX[i]);
            }
        }
Esempio n. 2
0
        private void SpecialCenterUpdate(List <HeadPoint> points, List <int> indexes, Vector2 targetPoint)
        {
            float maxX, minX;
            var   center = GetCenter(points, indexes, out minX, out maxX);

            var rightPosUserSelected = MirroredHeadPoint.GetFrontWorldPoint(targetPoint, ProgramCore.CurrentProgram);          // перенояем координаты с левой картинки в правой
            var delta2 = rightPosUserSelected - center;

            foreach (var index in indexes)
            {
                var p = points[index];
                p.Value += delta2;
                autodotsShapeHelper.Transform(p.Value, index);
            }
        }
Esempio n. 3
0
        private void SpecialTopHaedWidth(List <HeadPoint> points)
        {
            var topHeadIndices = new int[] { 6, 5, 4, 3, 0, 25, 26, 27, 28 };
            var a           = MirroredHeadPoint.GetFrontWorldPoint(ProgramCore.Project.DetectedTopPoints[0], ProgramCore.CurrentProgram);
            var b           = MirroredHeadPoint.GetFrontWorldPoint(ProgramCore.Project.DetectedTopPoints[1], ProgramCore.CurrentProgram);
            var width       = b.X - a.X;
            var invOldWidth = 1.0f / (points[28].Value.X - points[6].Value.X);
            var minX        = points[6].Value.X;

            foreach (var index in topHeadIndices)
            {
                var point = points[index];
                var x     = (point.Value.X - minX) * invOldWidth * width + a.X;
                point.Value = new Vector2(x, point.Value.Y);
                autodotsShapeHelper.Transform(point.Value, index);
            }
        }
Esempio n. 4
0
        private void SpecialEyePointsUpdate(List <HeadPoint> points, bool isLeft)
        {
            var eyePoints = isLeft ? new[] { 21, 22, 23, 24 } : new[] { 45, 44, 43, 46 };

            for (var i = 0; i < eyePoints.Length; ++i)
            {
                var point = points[eyePoints[i]];
                var delta =
                    MirroredHeadPoint.GetFrontWorldPoint(isLeft ? ProgramCore.Project.DetectedLeftEyePoints[i] : ProgramCore.Project.DetectedRightEyePoints[i], ProgramCore.CurrentProgram) - point.Value;
                point.Value += delta;
                foreach (var l in point.LinkedPoints)
                {
                    var p = points[l];
                    p.Value += delta;
                    autodotsShapeHelper.Transform(p.Value, l);
                }
                autodotsShapeHelper.Transform(point.Value, eyePoints[i]);
            }
        }
Esempio n. 5
0
        private void SpecialNosePointsUpdate(List <HeadPoint> points)
        {
            var bottomNosePoints = new int[] { 19, 41, 52 };

            for (var i = 0; i < bottomNosePoints.Length; ++i)
            {
                var point = points[bottomNosePoints[i]];
                var delta = MirroredHeadPoint.GetFrontWorldPoint(ProgramCore.Project.DetectedNosePoints[i], ProgramCore.CurrentProgram) - point.Value;
                if (bottomNosePoints[i] != 52)
                {
                    delta.Y -= 0.2f;
                }
                //delta = new Vector2(point.Value.X + delta.X, point.Value.Y) - point.Value;
                point.Value += delta;
                foreach (var l in point.LinkedPoints)
                {
                    var p = points[l];
                    p.Value += delta;
                    autodotsShapeHelper.Transform(p.Value, l);
                }
                autodotsShapeHelper.Transform(point.Value, bottomNosePoints[i]);
            }
        }
Esempio n. 6
0
        private void SpecialLipsPointsUpdate(List <HeadPoint> points, Vector2 targetPoint)
        {
            var mouthIndices = headController.GetMouthIndexes();

            var borders = new Vector3[] { ProgramCore.Project.DetectedLipsPoints[0], ProgramCore.Project.DetectedLipsPoints[4] };

            float maxX, minX;
            var   center = GetCenter(points, mouthIndices, out minX, out maxX);
            var   rightPosUserSelected = MirroredHeadPoint.GetFrontWorldPoint(targetPoint, ProgramCore.CurrentProgram);        // перенояем координаты с левой картинки в правой
            var   delta2 = rightPosUserSelected - center;

            var leftBorder  = MirroredHeadPoint.GetFrontWorldPoint(borders[0], ProgramCore.CurrentProgram) - rightPosUserSelected;
            var rightBorder = MirroredHeadPoint.GetFrontWorldPoint(borders[1], ProgramCore.CurrentProgram) - rightPosUserSelected;

            minX = minX - center.X;
            maxX = maxX - center.X;

            //Подгоняем все точки в центр и растягиваем по ширине
            foreach (var index in mouthIndices)
            {
                var p  = points[index];
                var dx = p.Value.X - center.X;
                dx      = dx < 0.0f ? (dx * leftBorder.X / minX) : (rightBorder.X * dx / maxX);
                p.Value = new Vector2(center.X + dx + delta2.X, p.Value.Y + delta2.Y);
            }
            //Проставляем фиксированные точки
            var indices = new int[] { 15, 17, 1, 39, 37, 38, 16, 51, 53 };
            var i       = 0;

            foreach (var index in indices)
            {
                var p = points[index];
                p.Value = MirroredHeadPoint.GetFrontWorldPoint(ProgramCore.Project.DetectedLipsPoints[i++], ProgramCore.CurrentProgram);
            }

            foreach (var index in mouthIndices)
            {
                var p = points[index];
                autodotsShapeHelper.Transform(p.Value, index);
            }
            var lipsPoints = new List <Vector2>();

            for (int j = 9; j < 13; ++j)
            {
                lipsPoints.Add(MirroredHeadPoint.GetFrontWorldPoint(ProgramCore.Project.DetectedLipsPoints[j], ProgramCore.CurrentProgram));
            }
            autodotsShapeHelper.TransformLips(lipsPoints);

            var         aIndex      = indices[indices.Length - 2];
            var         a           = points[aIndex];
            var         bIndex      = indices[indices.Length - 1];
            var         b           = points[bIndex];
            const float minLipsDist = 0.3f;

            if (a.Value.Y - b.Value.Y < minLipsDist)
            {
                var centerY = (a.Value.Y + b.Value.Y) * 0.5f;
                a.Value.Y = centerY - minLipsDist * 0.5f;
                b.Value.Y = centerY + minLipsDist * 0.5f;
            }

            autodotsShapeHelper.Transform(a.Value, aIndex);
            autodotsShapeHelper.Transform(b.Value, bIndex);
        }