コード例 #1
0
ファイル: KinematicsHelper.cs プロジェクト: jfpk/kinoveaIDS
        private void ComputeFilteredCoordinates(TrajectoryKinematics kinematics, CalibrationHelper calibrationHelper)
        {
            double framerate = calibrationHelper.CaptureFramesPerSecond;

            ButterworthFilter filter = new ButterworthFilter();
            int bestCutoffIndex;

            kinematics.FilterResultXs = filter.FilterSamples(kinematics.RawXs, framerate, 100, out bestCutoffIndex);
            kinematics.XCutoffIndex   = bestCutoffIndex;

            kinematics.FilterResultYs = filter.FilterSamples(kinematics.RawYs, framerate, 100, out bestCutoffIndex);
            kinematics.YCutoffIndex   = bestCutoffIndex;
        }
コード例 #2
0
        /// <summary>
        /// Initialize the data and filter it if possible.
        /// </summary>
        public void Initialize(List <TimedPoint> samples, CalibrationHelper calibrationHelper)
        {
            this.Length = samples.Count;

            Times = new long[samples.Count];
            RawXs = new double[samples.Count];
            RawYs = new double[samples.Count];

            XCutoffIndex = -1;
            YCutoffIndex = -1;

            // Raw coordinates.
            for (int i = 0; i < samples.Count; i++)
            {
                PointF point = calibrationHelper.GetPointAtTime(samples[i].Point, samples[i].T);
                RawXs[i] = point.X;
                RawYs[i] = point.Y;
                Times[i] = samples[i].T;
            }

            this.CanFilter = PreferencesManager.PlayerPreferences.EnableFiltering && samples.Count > 10;
            if (this.CanFilter)
            {
                double framerate = calibrationHelper.CaptureFramesPerSecond;

                ButterworthFilter filter = new ButterworthFilter();

                // Filter the results a hundred times and store all data along with the best cutoff frequency.
                int tests = 100;
                int bestCutoffIndexX;
                FilterResultXs = filter.FilterSamples(RawXs, framerate, tests, out bestCutoffIndexX);
                XCutoffIndex   = bestCutoffIndexX;

                int bestCutoffIndexY;
                FilterResultYs = filter.FilterSamples(RawYs, framerate, tests, out bestCutoffIndexY);
                YCutoffIndex   = bestCutoffIndexY;
            }

            BestFitCircle = CircleFitter.Fit(this);
        }