Ejemplo n.º 1
0
        public static FinderPattern findFinderPattern(bool[][] image)
        {
            Line[]  lineCross = FinderPattern.FindLineCross(FinderPattern.FindLineAcross(image));
            Point[] center;
            try
            {
                center = FinderPattern.GetCenter(lineCross);
            }
            catch (FinderPatternNotFoundException ex)
            {
                throw ex;
            }
            int[]   angle      = FinderPattern.GetAngle(center);
            Point[] pointArray = FinderPattern.Sort(center, angle);
            int[]   width      = FinderPattern.GetWidth(image, pointArray, angle);
            int[]   moduleSize = new int[3]
            {
                (width[0] << QRCodeImageReader.DECIMAL_POINT) / 7,
                (width[1] << QRCodeImageReader.DECIMAL_POINT) / 7,
                (width[2] << QRCodeImageReader.DECIMAL_POINT) / 7
            };
            int version = FinderPattern.calcRoughVersion(pointArray, width);

            if (version > 6)
            {
                try
                {
                    version = FinderPattern.CalcExactVersion(pointArray, angle, moduleSize, image);
                }
                catch (VersionInformationException ex)
                {
                }
            }
            return(new FinderPattern(pointArray, version, angle, width, moduleSize));
        }