Example #1
0
        /*private int ComputeDiff(byte[,] a, byte[,] b)
         * {
         *      int w = a.GetLength(1), h = a.GetLength(0);
         *      int r = 0;
         *      for (int j = 0; j < h; j++)
         *              for (int i = 0; i < w; i++)
         *                      r += a[j, i] - b[j, i];
         *
         *      return r * 100 / h / w;
         * }*/

        public int OldMatches(SubtitleLetter o)
        {
            // If the width or height differs by more than 2 pixels, it's probably another character
            if (Math.Abs(o.image.GetLength(1) - image.GetLength(1)) > 1 || Math.Abs(o.image.GetLength(0) - image.GetLength(0)) > 1)
            {
                return(999999);
            }

            //double translation = FindTranslation(i1, i2);
            double translation = FindTranslation(image, o.image);

            byte[,] moved = o.MoveLetter(-translation);

            // Build an array out of their differences
            DateTime t  = DateTime.Now;
            int      ad = ComputeAbsDiff(image, moved);

            Debugger.Print("diff (" + Text + ") = " + ad);
            Debugger.absDiffTime += (DateTime.Now - t).TotalMilliseconds;

            return(ad);
        }
Example #2
0
        public int Matches(SubtitleLetter o)
        {
            // If the width or height differs by more than a pixel, it's probably another character
            if (Math.Abs(o.image.GetLength(1) - image.GetLength(1)) > 1 || Math.Abs(o.image.GetLength(0) - image.GetLength(0)) > 1)
            {
                return(999999);
            }

            //double translation = FindTranslation(i1, i2);
            DateTime t           = DateTime.Now;
            double   translation = FindTranslation(image, o.image);

            byte[,] moved             = o.MoveLetter(-translation);
            Debugger.translationTime += (DateTime.Now - t).TotalMilliseconds;

            //Debugger.Print("########################################################################");
            //Debugger.Draw2DArray(image);
            //Debugger.Print("------------------------------------------------------------------------");
            //Debugger.Draw2DArray(moved);

            t = DateTime.Now;
            int diff1 = Difference(image, moved) + Difference(moved, image);

            Debugger.diffTime += (DateTime.Now - t).TotalMilliseconds;
            if (diff1 > 0)
            {
                return(diff1 + 1000);
            }

            t = DateTime.Now;
            int ad = ComputeAbsDiff(image, moved);

            Debugger.absDiffTime += (DateTime.Now - t).TotalMilliseconds;

            return(Math.Min(1000, ad / 10));
        }
Example #3
0
        /*private int ComputeDiff(byte[,] a, byte[,] b)
        {
            int w = a.GetLength(1), h = a.GetLength(0);
            int r = 0;
            for (int j = 0; j < h; j++)
                for (int i = 0; i < w; i++)
                    r += a[j, i] - b[j, i];

            return r * 100 / h / w;
        }*/
        public int OldMatches(SubtitleLetter o)
        {
            // If the width or height differs by more than 2 pixels, it's probably another character
            if (Math.Abs(o.image.GetLength(1) - image.GetLength(1)) > 1 || Math.Abs(o.image.GetLength(0) - image.GetLength(0)) > 1)
                return 999999;

            //double translation = FindTranslation(i1, i2);
            double translation = FindTranslation(image, o.image);
            byte[,] moved = o.MoveLetter(-translation);

            // Build an array out of their differences
            DateTime t = DateTime.Now;
            int ad = ComputeAbsDiff(image, moved);
            Debugger.Print("diff (" + Text + ") = " + ad);
            Debugger.absDiffTime += (DateTime.Now - t).TotalMilliseconds;

            return ad;
        }
Example #4
0
        public int Matches(SubtitleLetter o)
        {
            // If the width or height differs by more than a pixel, it's probably another character
            if (Math.Abs(o.image.GetLength(1) - image.GetLength(1)) > 1 || Math.Abs(o.image.GetLength(0) - image.GetLength(0)) > 1)
                return 999999;

            //double translation = FindTranslation(i1, i2);
            DateTime t = DateTime.Now;
            double translation = FindTranslation(image, o.image);
            byte[,] moved = o.MoveLetter(-translation);
            Debugger.translationTime += (DateTime.Now - t).TotalMilliseconds;

            //Debugger.Print("########################################################################");
            //Debugger.Draw2DArray(image);
            //Debugger.Print("------------------------------------------------------------------------");
            //Debugger.Draw2DArray(moved);

            t = DateTime.Now;
            int diff1 = Difference(image, moved) + Difference(moved, image);
            Debugger.diffTime += (DateTime.Now - t).TotalMilliseconds;
            if (diff1 > 0)
                return diff1 + 1000;

            t = DateTime.Now;
            int ad = ComputeAbsDiff(image, moved);
            Debugger.absDiffTime += (DateTime.Now - t).TotalMilliseconds;

            return Math.Min(1000, ad / 10);
        }