Example #1
0
        public BitmapVector GetClosestMatch(BitmapVector v)
        {
            if (vectors.Count == 0)
            {
                throw new CaptchaSolverException("There are no patterns loaded to match a sample pattern to!");
            }

            int    index = 0;
            double best  = BitmapVector.RootMeanSquareDistance(vectors[0].Scale(), v.Scale());

            //vectors[0].GetBitmap().Save("getmatch-a--" + index.ToString() + ".bmp");
            //v.GetBitmap().Save("getmatch--b-" + index.ToString() + ".bmp");
            //(vectors[0].Scale() - v.Scale()).GetBitmap().Save("getmatch-ab-" + index.ToString() + ".bmp");

            //for (int i = 1; i < vectors.Count; i++)
            Parallel.For(1, vectors.Count, i =>
            {
                //vectors[i].GetBitmap().Save("getmatch-a--" + i.ToString() + ".bmp");
                //v.GetBitmap().Save("getmatch--b-" + i.ToString() + ".bmp");
                //(vectors[i].Scale() - v.Scale()).GetBitmap().Save("getmatch-ab-" + i.ToString() + ".bmp");

                double test = BitmapVector.RootMeanSquareDistance(vectors[i].Scale(), v.Scale());

                if (test < best)
                {
                    best  = test;
                    index = i;
                }
            });

            return(vectors[index]);
        }
Example #2
0
        public BitmapVector GetClosestMatch(BitmapVector v)
        {
            if (vectors.Count == 0)
            {
                throw new CaptchaSolverException("There are no patterns loaded to which a sample pattern may be matched!");
            }

            int    index = 0;
            double best  = BitmapVector.RootMeanSquareDistance(vectors[0].Scale(), v.Scale());

            Parallel.For(1, vectors.Count, i =>
            {
                double test = BitmapVector.RootMeanSquareDistance(vectors[i].Scale(), v.Scale());

                if (test < best)
                {
                    best  = test;
                    index = i;
                }
            });

            return(vectors[index]);
        }