Beispiel #1
0
        private void signsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();
            List <string[]> limitSign       = new List <string[]>();
            List <string[]> warningSign     = new List <string[]>();
            List <string[]> prohibitionSign = new List <string[]>();

            ImageClass.Signs(img, imgUndo, out limitSign, out warningSign, out prohibitionSign, 0);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh(); // refresh image on the screen
            SignsForm signForm = new SignsForm(limitSign, warningSign, prohibitionSign);

            signForm.ShowDialog();

            Cursor = Cursors.Default; // normal cursor
        }
Beispiel #2
0
        private void DetectSignsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Bgr, Byte> imgCopy = img.Clone();

            int level = 1;

            ImageViewer.Image = ImageClass.Signs(img, imgCopy, out limitSign, out warningSign, out prohibitionSign, level).Bitmap;


            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Beispiel #3
0
        private void Identify1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo     = img.Copy();
            imgOriginal = img.Copy();

            List <Image <Bgr, Byte> > triangles = new List <Image <Bgr, Byte> >();

            for (int i = 0; i < 9; i++)
            {
                triangles.Add(new Image <Bgr, Byte>("..\\..\\Imagens-20190916\\signs\\" + i + ".png"));
            }

            //List of detected signs
            List <string[]> signs = new List <string[]>();

            //Classification results (list for each object)
            List <int> classification = new List <int>();

            //List for evaluation
            List <string[]> limitSign       = new List <string[]>();
            List <string[]> warningSign     = new List <string[]>();
            List <string[]> prohibitionSign = new List <string[]>();

            //HSV image inside imgUndo, you can change imgUndo to imgHsv to get different result (also Bgr to Hsv change needed in BgrToHsv func)
            Identify.BgrToHsv(img, imgUndo);
            List <List <int[]> > allObject     = Identify.connectedComponents(imgUndo, img);
            List <int[]>         signsObjects  = allObject[0];
            List <int[]>         numberObjects = allObject[1];

            foreach (int[] number in numberObjects)
            {
                //Scale digits image
                digits = Identify.Scale(digits, number);

                triangles = Identify.Scale(triangles, number);

                //Thresholding detected sector
                Identify.ConvertToBW_Otsu_coords(imgOriginal, number);

                //Identify digit
                classification.Add(Identify.DetectDigit(imgOriginal, digits, number));
            }

            //Creating final output of detected signs
            //signs = Identify.CreateFinalList(classification, signsObjects, numberObjects);

            foreach (string[] sign in signs)
            {
                if (sign[0].Equals("-1"))
                {
                    if (!Identify.DetectTriangle(img, triangles, new int[] { Int32.Parse(sign[1]), Int32.Parse(sign[2]), Int32.Parse(sign[3]), Int32.Parse(sign[4]) }, 0.7).Equals(-1))
                    {
                        warningSign.Add(sign);
                    }
                    else
                    {
                        prohibitionSign.Add(sign);
                    }
                }
                else
                {
                    limitSign.Add(sign);
                }
            }

            ImageClass.Signs(img, imgUndo, out limitSign, out warningSign, out prohibitionSign, 2);
            //ImageViewer.Image = imgHsv.Bitmap;
            ImageViewer.Image = img.Bitmap;

            ImageViewer.Refresh();    // refresh image on the screen
            Cursor = Cursors.Default; // normal cursor
        }