Example #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));
        }
Example #2
0
        public static FinderPattern findFinderPattern(bool[][] image)
        {
            Line[]  lineAcross = FinderPattern.findLineAcross(image);
            Line[]  lineCross  = FinderPattern.findLineCross(lineAcross);
            Point[] center     = null;
            try
            {
                center = FinderPattern.getCenter(lineCross);
            }
            catch (FinderPatternNotFoundException e)
            {
                throw e;
            }
            int[] sincos = FinderPattern.getAngle(center);
            center = FinderPattern.sort(center, sincos);
            int[] width      = FinderPattern.getWidth(image, center, sincos);
            int[] moduleSize = new int[]
            {
                (width[0] << QRCodeImageReader.DECIMAL_POINT) / 7,
                (width[1] << QRCodeImageReader.DECIMAL_POINT) / 7,
                (width[2] << QRCodeImageReader.DECIMAL_POINT) / 7
            };
            int version = FinderPattern.calcRoughVersion(center, width);

            if (version > 6)
            {
                try
                {
                    version = FinderPattern.calcExactVersion(center, sincos, moduleSize, image);
                }
                catch (VersionInformationException e_AC)
                {
                }
            }
            return(new FinderPattern(center, version, sincos, width, moduleSize));
        }