Exemplo n.º 1
0
        private void matchClick(object sender, RoutedEventArgs e)
        {
            StylusPointCollection allPoints1 = new StylusPointCollection();
            StylusPointCollection allPoints2 = new StylusPointCollection();

            foreach (Stroke stroke in inkIn1.Strokes)
            {
                allPoints1.Add(stroke.StylusPoints);
            }
            foreach (Stroke stroke in inkIn2.Strokes)
            {
                allPoints2.Add(stroke.StylusPoints);
            }

            ComplexStroke cStroke1 = new ComplexStroke(allPoints1);
            ComplexStroke cStroke2 = new ComplexStroke(allPoints2);

            ComplexStrokeMatcher matcher = new ComplexStrokeMatcher(cStroke1, cStroke2);

            int parsedValue;

            if (!int.TryParse(matchCoefficientTextbox.Text, out parsedValue))
            {
                MessageBox.Show("This is a number only field");
                return;
            }
            if (cStroke1.DFTCoefficients != null && cStroke2.DFTCoefficients != null)
            {
                matcher.CalculateMatch(parsedValue);
                matchDistanceLabel.Content = matcher.Distance;


                cStroke2.DFTCoefficients[0] = cStroke1.DFTCoefficients[0];

                for (int k = -cStroke2.DFTCoefficients.Count / 2; k <= cStroke2.DFTCoefficients.Count / 2; k++)
                //for (int k = -parsedValue / 2; k < parsedValue/2; k++)
                {
                    double magnitude = 1 / matcher.meanR;
                    //double shift = (cStroke2.Stats.orientation - cStroke1.Stats.orientation + (2.0 * Math.PI * matcher.meanShift * (double)k)/(double)cStroke2.DFTCoefficients.Count);
                    double shift = -(matcher.meanShift * k + cStroke2.Stats.orientation - cStroke1.Stats.orientation);
                    //double shift = -matcher.meanShift;
                    Complex transform = Complex.FromPolarCoordinates(magnitude, shift);
                    int     ind       = Math.Abs(k);
                    if (k < 0)
                    {
                        cStroke2.DFTCoefficients[ind].negative *= transform;
                    }
                    else if (k > 0)
                    {
                        cStroke2.DFTCoefficients[ind].positive *= transform;
                    }
                }

                inkMatched.Children.Clear();

                DrawStrokePoints(cStroke1.ReconstructedStroke(), inkMatched, Brushes.Red);
                DrawStrokePoints(cStroke2.ReconstructedStroke(), inkMatched, Brushes.Blue);
            }
        }
Exemplo n.º 2
0
        //private void cSlide1(object sender, RoutedPropertyChangedEventArgs<double> e)
        //{
        //    StylusPointCollection allPoints = new StylusPointCollection();

        //    foreach (Stroke stroke in inkIn1.Strokes)
        //    {
        //        allPoints.Add(stroke.StylusPoints);
        //    }

        //    ComplexStroke cStroke = new ComplexStroke(allPoints);


        //    inkReconstruction1.Strokes = new StrokeCollection();
        //    inkReconstruction1.Strokes.Add(cStroke.ReconstructedStroke((int)coefficientSlider1.Value));

        //}

        private void cSlide1(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            StylusPointCollection allPoints = new StylusPointCollection();

            foreach (Stroke stroke in inkIn1.Strokes)
            {
                allPoints.Add(stroke.StylusPoints);
            }

            ComplexStroke cStroke = new ComplexStroke(allPoints);

            inkReconstruction1.Children.Clear();

            Stroke reconstruct = cStroke.ReconstructedStroke((int)coefficientSlider1.Value);

            DrawStrokePoints(reconstruct, inkReconstruction1, Brushes.Red);
            inkReconstruction1.Strokes = new StrokeCollection();
            inkReconstruction1.Strokes.Add(cStroke.ReconstructedStroke((int)coefficientSlider1.Value));
        }
Exemplo n.º 3
0
 public ComplexStrokeMatcher(ComplexStroke st1, ComplexStroke st2)
 {
     stroke1 = st1;
     stroke2 = st2;
 }