Esempio n. 1
0
        //Rectangle Detection
        public static MapRectangle GetMapRectangle(Bitmap bmp)
        {
            int[] result = new int[2];

            List <Line> lines = new List <Line>();

            lines.AddRange(FindVertical(bmp));
            lines.AddRange(FindHorizontal(bmp));


            //normalize results(multiple lines due to line width)
            NormalizeResults(lines);

            //intersect lines and find rectangle corners
            List <int[]> rectanglePoints = ComputeIntersection(lines);


            /* for checking purposes
             * foreach (int[] point in rectanglePoints)
             * {
             *  Console.WriteLine(point[0] + " " + point[1]);
             * }
             */



            MapRectangle mapRectangle = new MapRectangle(rectanglePoints);

            return(mapRectangle);
        }
Esempio n. 2
0
        private static void RunProgram(String srcPath)
        {
            try
            {
                Screenshot screenshot = new Screenshot(srcPath);
                Bitmap     minimap    = screenshot.GetMinimap();

                //preprocessing
                minimap.InvertColors();
                minimap.FilterBlack();
                minimap = new Bitmap(minimap, new Size(normWidth, normWidth));

                //saving
                //minimap.Save("D:/dojo/resultat.jpg");

                //processing
                MapRectangle mapRectangle = Processing.GetMapRectangle(minimap);

                Console.WriteLine("[" + srcPath + "]          ");
                Console.WriteLine("x: " + mapRectangle.CoordX + ", y: "
                                  + mapRectangle.CoordY + ", w: " + mapRectangle.Width
                                  + ", h: " + mapRectangle.Height + ", location: (" + mapRectangle.Location[0] + ", " + mapRectangle.Location[1] + ")");
                Console.WriteLine();
            }
            catch (LineNumberException ln)
            {
                Console.WriteLine("[Rectangle Exception] Could not identify rectangle");
            }
            catch (Exception e)
            {
                NewException();
            }
        }