Пример #1
0
        private void ComputeAngularAccelerations(TrajectoryKinematics kinematics, CalibrationHelper calibrationHelper)
        {
            if (kinematics.Length <= 4)
            {
                PadAngularAccelerations(kinematics);
                return;
            }

            for (int i = 2; i < kinematics.Length - 2; i++)
            {
                double d1  = GetDisplacementAngle(kinematics, i - 1, i - 2);
                double d2  = GetDisplacementAngle(kinematics, i, i - 1);
                double d3  = GetDisplacementAngle(kinematics, i + 1, i);
                double d4  = GetDisplacementAngle(kinematics, i + 2, i + 1);
                float  t02 = calibrationHelper.GetTime(2);
                float  t24 = calibrationHelper.GetTime(2);
                float  t13 = calibrationHelper.GetTime(2);

                float v1 = (float)((d1 + d2) / t02);
                float v2 = (float)((d3 + d4) / t24);
                float a  = (float)((v2 - v1) / t13);
                kinematics.AngularAcceleration[i] = calibrationHelper.ConvertAngularAcceleration(a);
            }

            PadAngularAccelerations(kinematics);
        }
Пример #2
0
        private void ComputeVelocities(TrajectoryKinematics kinematics, CalibrationHelper calibrationHelper)
        {
            if (kinematics.Length <= 2)
            {
                PadVelocities(kinematics);
                return;
            }

            for (int i = 1; i < kinematics.Length - 1; i++)
            {
                PointF a = kinematics.Coordinates(i - 1);
                PointF b = kinematics.Coordinates(i + 1);
                float  t = calibrationHelper.GetTime(2);

                kinematics.Speed[i] = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Magnitude));
                kinematics.HorizontalVelocity[i] = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Horizontal));
                kinematics.VerticalVelocity[i]   = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Vertical));
            }

            PadVelocities(kinematics);

            double        constantVelocitySpan = 40;
            MovingAverage filter = new MovingAverage();

            kinematics.Speed = filter.FilterSamples(kinematics.Speed, calibrationHelper.CaptureFramesPerSecond, constantVelocitySpan, 1);
            kinematics.HorizontalVelocity = filter.FilterSamples(kinematics.HorizontalVelocity, calibrationHelper.CaptureFramesPerSecond, constantVelocitySpan, 1);
            kinematics.VerticalVelocity   = filter.FilterSamples(kinematics.VerticalVelocity, calibrationHelper.CaptureFramesPerSecond, constantVelocitySpan, 1);
        }
Пример #3
0
        private void ComputeAcceleration(TimeSeriesCollection tsc, CalibrationHelper calibrationHelper)
        {
            if (tsc.Length <= 2)
            {
                PadAccelerations(tsc);
                return;
            }

            for (int i = 1; i < tsc.Length - 1; i++)
            {
                float v1    = velocities[i - 1];
                float v2    = velocities[i + 1];
                float t     = calibrationHelper.GetTime(2);
                float alpha = (v2 - v1) / t;

                tsc[Kinematics.AngularAcceleration][i] = (double)calibrationHelper.ConvertAngularAcceleration(alpha);

                float at = radii[i] * alpha;
                tsc[Kinematics.TangentialAcceleration][i] = (double)calibrationHelper.ConvertAcceleration(at);

                float ac = radii[i] * velocities[i] * velocities[i];
                tsc[Kinematics.CentripetalAcceleration][i] = (double)calibrationHelper.ConvertAcceleration(ac);

                float a = (float)Math.Sqrt(at * at + ac * ac);
                tsc[Kinematics.ResultantLinearAcceleration][i] = (double)calibrationHelper.ConvertAcceleration(a);
            }

            PadAccelerations(tsc);
        }
Пример #4
0
        private void ComputeAccelerations(TrajectoryKinematics kinematics, CalibrationHelper calibrationHelper)
        {
            if (kinematics.Length <= 4)
            {
                PadAccelerations(kinematics);
                return;
            }

            // First pass: average speed over 2t centered on each data point.
            for (int i = 2; i < kinematics.Length - 2; i++)
            {
                PointF p0  = kinematics.Coordinates(i - 2);
                PointF p2  = kinematics.Coordinates(i);
                PointF p4  = kinematics.Coordinates(i + 2);
                float  t02 = calibrationHelper.GetTime(2);
                float  t24 = calibrationHelper.GetTime(2);
                float  t13 = calibrationHelper.GetTime(2);

                double acceleration = (kinematics.Speed[i + 1] - kinematics.Speed[i - 1]) / t13;
                kinematics.Acceleration[i] = calibrationHelper.ConvertAccelerationFromVelocity((float)acceleration);

                double horizontalAcceleration = (kinematics.HorizontalVelocity[i + 1] - kinematics.HorizontalVelocity[i - 1]) / t13;
                kinematics.HorizontalAcceleration[i] = calibrationHelper.ConvertAccelerationFromVelocity((float)horizontalAcceleration);

                double verticalAcceleration = (kinematics.VerticalVelocity[i + 1] - kinematics.VerticalVelocity[i - 1]) / t13;
                kinematics.VerticalAcceleration[i] = calibrationHelper.ConvertAccelerationFromVelocity((float)verticalAcceleration);
            }

            PadAccelerations(kinematics);

            double        constantAccelerationSpan = 50;
            MovingAverage filter = new MovingAverage();

            kinematics.Acceleration           = filter.FilterSamples(kinematics.Acceleration, calibrationHelper.CaptureFramesPerSecond, constantAccelerationSpan, 2);
            kinematics.HorizontalAcceleration = filter.FilterSamples(kinematics.HorizontalAcceleration, calibrationHelper.CaptureFramesPerSecond, constantAccelerationSpan, 2);
            kinematics.VerticalAcceleration   = filter.FilterSamples(kinematics.VerticalAcceleration, calibrationHelper.CaptureFramesPerSecond, constantAccelerationSpan, 2);
        }
Пример #5
0
        private void ComputeRawAccelerations(TrajectoryKinematics kinematics, CalibrationHelper calibrationHelper)
        {
            if (kinematics.Length <= 4)
            {
                PadRawAccelerations(kinematics);
                return;
            }

            for (int i = 2; i < kinematics.Length - 2; i++)
            {
                PointF p0  = kinematics.RawCoordinates(i - 2);
                PointF p2  = kinematics.RawCoordinates(i);
                PointF p4  = kinematics.RawCoordinates(i + 2);
                float  t02 = calibrationHelper.GetTime(2);
                float  t24 = calibrationHelper.GetTime(2);
                float  t13 = calibrationHelper.GetTime(2);

                kinematics.RawAcceleration[i]           = calibrationHelper.ConvertAcceleration(GetAcceleration(p0, p2, p4, t02, t24, t13, Component.Magnitude));
                kinematics.RawHorizontalAcceleration[i] = calibrationHelper.ConvertAcceleration(GetAcceleration(p0, p2, p4, t02, t24, t13, Component.Horizontal));
                kinematics.RawVerticalAcceleration[i]   = calibrationHelper.ConvertAcceleration(GetAcceleration(p0, p2, p4, t02, t24, t13, Component.Vertical));
            }

            PadRawAccelerations(kinematics);
        }
Пример #6
0
        private void ComputeAccelerations(TimeSeriesCollection tsc, CalibrationHelper calibrationHelper, Func <int, PointF> getCoord)
        {
            if (tsc.Length <= 4)
            {
                PadAccelerations(tsc);
                return;
            }

            // First pass: average speed over 2t centered on each data point.
            for (int i = 2; i < tsc.Length - 2; i++)
            {
                float t = calibrationHelper.GetTime(2);

                double acceleration = (tsc[Kinematics.LinearSpeed][i + 1] - tsc[Kinematics.LinearSpeed][i - 1]) / t;
                tsc[Kinematics.LinearAcceleration][i] = calibrationHelper.ConvertAccelerationFromVelocity((float)acceleration);

                double horizontalAcceleration = (tsc[Kinematics.LinearHorizontalVelocity][i + 1] - tsc[Kinematics.LinearHorizontalVelocity][i - 1]) / t;
                tsc[Kinematics.LinearHorizontalAcceleration][i] = calibrationHelper.ConvertAccelerationFromVelocity((float)horizontalAcceleration);

                double verticalAcceleration = (tsc[Kinematics.LinearVerticalVelocity][i + 1] - tsc[Kinematics.LinearVerticalVelocity][i - 1]) / t;
                tsc[Kinematics.LinearVerticalAcceleration][i] = calibrationHelper.ConvertAccelerationFromVelocity((float)verticalAcceleration);
            }

            PadAccelerations(tsc);

            // Second pass: extra smoothing derivatives.
            // This is only applied for high speed videos where the digitization is very noisy
            // due to the combination of increased time resolution and decreased spatial resolution.
            double        constantAccelerationSpan = 50;
            MovingAverage filter = new MovingAverage();

            double[] averagedAcceleration           = filter.FilterSamples(tsc[Kinematics.LinearAcceleration], calibrationHelper.CaptureFramesPerSecond, constantAccelerationSpan, 2);
            double[] averagedHorizontalAcceleration = filter.FilterSamples(tsc[Kinematics.LinearHorizontalAcceleration], calibrationHelper.CaptureFramesPerSecond, constantAccelerationSpan, 2);
            double[] averagedVerticalAcceleration   = filter.FilterSamples(tsc[Kinematics.LinearVerticalAcceleration], calibrationHelper.CaptureFramesPerSecond, constantAccelerationSpan, 2);

            for (int i = 0; i < tsc.Length; i++)
            {
                tsc[Kinematics.LinearAcceleration][i]           = averagedAcceleration[i];
                tsc[Kinematics.LinearHorizontalAcceleration][i] = averagedHorizontalAcceleration[i];
                tsc[Kinematics.LinearVerticalAcceleration][i]   = averagedVerticalAcceleration[i];
            }
        }
Пример #7
0
        private void ComputeRawVelocities(TrajectoryKinematics kinematics, CalibrationHelper calibrationHelper)
        {
            if (kinematics.Length <= 2)
            {
                PadRawVelocities(kinematics);
                return;
            }

            for (int i = 1; i < kinematics.Length - 1; i++)
            {
                PointF a = kinematics.RawCoordinates(i - 1);
                PointF b = kinematics.RawCoordinates(i + 1);
                float  t = calibrationHelper.GetTime(2);

                kinematics.RawSpeed[i] = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Magnitude));
                kinematics.RawHorizontalVelocity[i] = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Horizontal));
                kinematics.RawVerticalVelocity[i]   = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Vertical));
            }

            PadRawVelocities(kinematics);
        }
Пример #8
0
        private void ComputeAngularVelocities(TrajectoryKinematics kinematics, CalibrationHelper calibrationHelper)
        {
            if (kinematics.Length <= 2)
            {
                PadAngularVelocities(kinematics);
                return;
            }

            for (int i = 1; i < kinematics.Length - 1; i++)
            {
                double d1             = GetDisplacementAngle(kinematics, i, i - 1);
                double d2             = GetDisplacementAngle(kinematics, i + 1, i);
                float  time           = calibrationHelper.GetTime(2);
                float  inRadPerSecond = (float)((d1 + d2) / time);

                kinematics.AngularVelocity[i]         = calibrationHelper.ConvertAngularVelocity(inRadPerSecond);
                kinematics.TangentialVelocity[i]      = calibrationHelper.ConvertSpeed((float)(inRadPerSecond * kinematics.RotationRadius));
                kinematics.CentripetalAcceleration[i] = calibrationHelper.ConvertAcceleration((float)(inRadPerSecond * inRadPerSecond * kinematics.RotationRadius));
            }

            PadAngularVelocities(kinematics);
        }
Пример #9
0
        private void ComputeVelocities(TimeSeriesCollection tsc, CalibrationHelper calibrationHelper, Func <int, PointF> getCoord)
        {
            if (tsc.Length <= 2)
            {
                PadVelocities(tsc);
                return;
            }

            for (int i = 1; i < tsc.Length - 1; i++)
            {
                PointF a = getCoord(i - 1);
                PointF b = getCoord(i + 1);
                float  t = calibrationHelper.GetTime(2);

                tsc[Kinematics.LinearSpeed][i] = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Magnitude));
                tsc[Kinematics.LinearHorizontalVelocity][i] = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Horizontal));
                tsc[Kinematics.LinearVerticalVelocity][i]   = (double)calibrationHelper.ConvertSpeed(GetSpeed(a, b, t, Component.Vertical));
            }

            PadVelocities(tsc);

            // Second pass: apply extra smoothing to the derivatives.
            // This is only applied for high speed videos where the digitization is very noisy
            // due to the combination of increased time resolution and decreased spatial resolution.
            double        constantVelocitySpan = 40;
            MovingAverage filter = new MovingAverage();

            double[] averagedVelocity           = filter.FilterSamples(tsc[Kinematics.LinearSpeed], calibrationHelper.CaptureFramesPerSecond, constantVelocitySpan, 1);
            double[] averagedHorizontalVelocity = filter.FilterSamples(tsc[Kinematics.LinearHorizontalVelocity], calibrationHelper.CaptureFramesPerSecond, constantVelocitySpan, 1);
            double[] averagedVerticalVelocity   = filter.FilterSamples(tsc[Kinematics.LinearVerticalVelocity], calibrationHelper.CaptureFramesPerSecond, constantVelocitySpan, 1);

            for (int i = 0; i < tsc.Length; i++)
            {
                tsc[Kinematics.LinearSpeed][i] = averagedVelocity[i];
                tsc[Kinematics.LinearHorizontalVelocity][i] = averagedHorizontalVelocity[i];
                tsc[Kinematics.LinearVerticalVelocity][i]   = averagedVerticalVelocity[i];
            }
        }
Пример #10
0
        private void ComputeVelocity(TimeSeriesCollection tsc, CalibrationHelper calibrationHelper)
        {
            if (tsc.Length <= 2)
            {
                PadVelocities(tsc);
                return;
            }

            for (int i = 1; i < tsc.Length - 1; i++)
            {
                float a1    = positions[i - 1];
                float a2    = positions[i + 1];
                float t     = calibrationHelper.GetTime(2);
                float omega = (a2 - a1) / t;

                velocities[i] = omega;
                tsc[Kinematics.AngularVelocity][i] = (double)calibrationHelper.ConvertAngularVelocity(omega);

                float v = radii[i] * omega;
                tsc[Kinematics.TangentialVelocity][i] = (double)calibrationHelper.ConvertSpeed(v);
            }

            PadVelocities(tsc);
        }