Пример #1
0
        internal static Point[] getCenter(Line[] crossLines)
        {
            ArrayList centers = ArrayList.Synchronized(new ArrayList(10));

            for (int i = 0; i < crossLines.Length - 1; i++)
            {
                Line compareLine = crossLines[i];
                for (int j = i + 1; j < crossLines.Length; j++)
                {
                    Line comparedLine = crossLines[j];
                    if (Line.isCross(compareLine, comparedLine))
                    {
                        int x = 0;
                        int y = 0;
                        if (compareLine.Horizontal)
                        {
                            x = compareLine.Center.X;
                            y = comparedLine.Center.Y;
                        }
                        else
                        {
                            x = comparedLine.Center.X;
                            y = compareLine.Center.Y;
                        }
                        centers.Add(new Point(x, y));
                    }
                }
            }

            Point[] foundPoints = new Point[centers.Count];

            for (int i = 0; i < foundPoints.Length; i++)
            {
                foundPoints[i] = (Point)centers[i];
                //Console.out.println(foundPoints[i]);
            }
            //Console.out.println(foundPoints.length);

            if (foundPoints.Length == 3)
            {
                canvas.drawPolygon(foundPoints, Color_Fields.RED);
                return(foundPoints);
            }
            else
            {
                throw new FinderPatternNotFoundException("Invalid number of Finder Pattern detected");
            }
        }
Пример #2
0
        internal static Point[] getCenter(Line[] crossLines)
        {
            int       num;
            ArrayList list = ArrayList.Synchronized(new ArrayList(10));

            for (num = 0; num < (crossLines.Length - 1); num++)
            {
                Line line = crossLines[num];
                for (int i = num + 1; i < crossLines.Length; i++)
                {
                    Line line2 = crossLines[i];
                    if (Line.isCross(line, line2))
                    {
                        int x = 0;
                        int y = 0;
                        if (line.Horizontal)
                        {
                            x = line.Center.X;
                            y = line2.Center.Y;
                        }
                        else
                        {
                            x = line2.Center.X;
                            y = line.Center.Y;
                        }
                        list.Add(new Point(x, y));
                    }
                }
            }
            Point[] points = new Point[list.Count];
            for (num = 0; num < points.Length; num++)
            {
                points[num] = (Point)list[num];
            }
            if (points.Length != 3)
            {
                throw new FinderPatternNotFoundException("Invalid number of Finder Pattern detected");
            }
            canvas.drawPolygon(points, Color_Fields.RED);
            return(points);
        }
Пример #3
0
        internal static Point[] getCenter(Line[] crossLines)
        {
            ArrayList arrayList = ArrayList.Synchronized(new ArrayList(10));

            for (int i = 0; i < crossLines.Length - 1; i++)
            {
                Line line = crossLines[i];
                for (int j = i + 1; j < crossLines.Length; j++)
                {
                    Line line2 = crossLines[j];
                    if (Line.isCross(line, line2))
                    {
                        int num  = 0;
                        int num2 = 0;
                        if (line.Horizontal)
                        {
                            num  = line.Center.X;
                            num2 = line2.Center.Y;
                        }
                        else
                        {
                            num  = line2.Center.X;
                            num2 = line.Center.Y;
                        }
                        arrayList.Add(new Point(num, num2));
                    }
                }
            }
            Point[] array = new Point[arrayList.Count];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (Point)arrayList[i];
            }
            if (array.Length == 3)
            {
                canvas.drawPolygon(array, Color_Fields.RED);
                return(array);
            }
            throw new FinderPatternNotFoundException("Invalid number of Finder Pattern detected");
        }