Esempio n. 1
0
        public static Point[][] getLogicalCenter(FinderPattern finderPattern)
        {
            int version = finderPattern.Version;

            Point[][] logicalCenters = new Point[1][];
            for (int i = 0; i < 1; i++)
            {
                logicalCenters[i] = new Point[1];
            }
            int[] logicalSeeds = new int[1];

            logicalSeeds   = LogicalSeed.getSeed(version);
            logicalCenters = new Point[logicalSeeds.Length][];
            for (int i2 = 0; i2 < logicalSeeds.Length; i2++)
            {
                logicalCenters[i2] = new Point[logicalSeeds.Length];
            }

            for (int col = 0; col < logicalCenters.Length; col++)
            {
                for (int row = 0; row < logicalCenters.Length; row++)
                {
                    logicalCenters[row][col] = new Point(logicalSeeds[row], logicalSeeds[col]);
                }
            }
            return(logicalCenters);
        }
Esempio n. 2
0
        public static AlignmentPattern findAlignmentPattern(bool[][] image, FinderPattern finderPattern)
        {
            Point[][] logicalCenters  = getLogicalCenter(finderPattern);
            int       logicalDistance = logicalCenters[1][0].X - logicalCenters[0][0].X;

            Point[][] centers = null;
            centers = getCenter(image, finderPattern, logicalCenters);
            return(new AlignmentPattern(centers, logicalDistance));
        }
Esempio n. 3
0
        internal static Point[][] getCenter(bool[][] image, FinderPattern finderPattern, Point[][] logicalCenters)
        {
            int moduleSize = finderPattern.getModuleSize();

            Axis axis        = new Axis(finderPattern.getAngle(), moduleSize);
            int  sqrtCenters = logicalCenters.Length;

            Point[][] centers = new Point[sqrtCenters][];
            for (int i = 0; i < sqrtCenters; i++)
            {
                centers[i] = new Point[sqrtCenters];
            }

            axis.Origin   = finderPattern.getCenter(FinderPattern.UL);
            centers[0][0] = axis.translate(3, 3);
            canvas.drawCross(centers[0][0], QRStudio.Engine.Codec.Util.Color_Fields.BLUE);

            axis.Origin = finderPattern.getCenter(FinderPattern.UR);
            centers[sqrtCenters - 1][0] = axis.translate(-3, 3);
            canvas.drawCross(centers[sqrtCenters - 1][0], QRStudio.Engine.Codec.Util.Color_Fields.BLUE);

            axis.Origin = finderPattern.getCenter(FinderPattern.DL);
            centers[0][sqrtCenters - 1] = axis.translate(3, -3);
            canvas.drawCross(centers[0][sqrtCenters - 1], QRStudio.Engine.Codec.Util.Color_Fields.BLUE);

            Point tmpPoint = centers[0][0];

            for (int y = 0; y < sqrtCenters; y++)
            {
                for (int x = 0; x < sqrtCenters; x++)
                {
                    if ((x == 0 && y == 0) || (x == 0 && y == sqrtCenters - 1) || (x == sqrtCenters - 1 && y == 0))
                    {
                        continue;
                    }
                    Point target = null;
                    if (y == 0)
                    {
                        if (x > 0 && x < sqrtCenters - 1)
                        {
                            target = axis.translate(centers[x - 1][y], logicalCenters[x][y].X - logicalCenters[x - 1][y].X, 0);
                        }
                        centers[x][y] = new Point(target.X, target.Y);
                        canvas.drawCross(centers[x][y], QRStudio.Engine.Codec.Util.Color_Fields.RED);
                    }
                    else if (x == 0)
                    {
                        if (y > 0 && y < sqrtCenters - 1)
                        {
                            target = axis.translate(centers[x][y - 1], 0, logicalCenters[x][y].Y - logicalCenters[x][y - 1].Y);
                        }
                        centers[x][y] = new Point(target.X, target.Y);
                        canvas.drawCross(centers[x][y], QRStudio.Engine.Codec.Util.Color_Fields.RED);
                    }
                    else
                    {
                        Point t1 = axis.translate(centers[x - 1][y], logicalCenters[x][y].X - logicalCenters[x - 1][y].X, 0);
                        Point t2 = axis.translate(centers[x][y - 1], 0, logicalCenters[x][y].Y - logicalCenters[x][y - 1].Y);
                        centers[x][y] = new Point((t1.X + t2.X) / 2, (t1.Y + t2.Y) / 2 + 1);
                    }
                    if (finderPattern.Version > 1)
                    {
                        Point precisionCenter = getPrecisionCenter(image, centers[x][y]);

                        if (centers[x][y].distanceOf(precisionCenter) < 6)
                        {
                            canvas.drawCross(centers[x][y], QRStudio.Engine.Codec.Util.Color_Fields.RED);
                            int dx = precisionCenter.X - centers[x][y].X;
                            int dy = precisionCenter.Y - centers[x][y].Y;
                            canvas.println("Adjust AP(" + x + "," + y + ") to d(" + dx + "," + dy + ")");

                            centers[x][y] = precisionCenter;
                        }
                    }
                    canvas.drawCross(centers[x][y], QRStudio.Engine.Codec.Util.Color_Fields.BLUE);
                    canvas.drawLine(new Line(tmpPoint, centers[x][y]), QRStudio.Engine.Codec.Util.Color_Fields.LIGHTBLUE);
                    tmpPoint = centers[x][y];
                }
            }
            return(centers);
        }