Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Emgu.CV.Image <Bgr, byte>  map   = new Image <Bgr, byte>(new Bitmap(picbMap.Image));
            Emgu.CV.Image <Bgr, byte>  model = new Image <Bgr, byte>(new Bitmap(picbMask.Image));
            List <Rectangle>           detectedRectangles = new List <Rectangle>();
            List <Image <Gray, byte> > detectedImages     = new List <Image <Gray, byte> >();

            StopSignDetector detector = new StopSignDetector(model);

            detector.DetectStopSign(
                map,
                detectedImages,
                detectedRectangles
                );

            picbMapMask.Image   = StopSignDetector.GetRedPixelMask(map).ToBitmap();
            picbModelMask.Image = StopSignDetector.GetRedPixelMask(model).ToBitmap();

            using (Graphics gr = Graphics.FromImage(picbMap.Image))
            {
                Pen borderPen = new Pen(Color.Red, 1);

                for (var i = 0; i < detectedRectangles.Count; i++)
                {
                    gr.DrawImage(
                        detectedImages[i].ToBitmap(),
                        detectedRectangles[i].Location
                        );
                    gr.DrawRectangle(borderPen, detectedRectangles[i]);
                }
            }

            picbMap.Invalidate();
        }
Beispiel #2
0
        private void btnDiabloDetect_Click(object sender, EventArgs e)
        {
            StopSignDetector.MaskHueLow  = (int)numericUpDown1.Value;
            StopSignDetector.MaskHueHigh = (int)numericUpDown2.Value;

            diabloMap = new Image <Bgr, byte>(new Bitmap(picbDiabloMap.Image));

            diabloModels    = new Image <Bgr, byte> [3];
            diabloModels[0] = new Image <Bgr, byte>(new Bitmap(picbModel1.Image));
            diabloModels[1] = new Image <Bgr, byte>(new Bitmap(picbModel2.Image));
            diabloModels[2] = new Image <Bgr, byte>(new Bitmap(picbModel3.Image));

            List <Rectangle>           detectedRectangles = new List <Rectangle>();
            List <Image <Gray, byte> > detectedImages     = new List <Image <Gray, byte> >();


            for (var i = 0; i < diabloModels.Length; i++)
            {
                StopSignDetector detector = new StopSignDetector(diabloModels[2 - i]);

                detector.DetectStopSign(
                    diabloMap,
                    detectedImages,
                    detectedRectangles
                    );

                picbDiabloMapMask.Image = StopSignDetector.GetRedPixelMask(diabloMap).ToBitmap();
            }

            using (Graphics gr = Graphics.FromImage(picbDiabloResult.Image))
            {
                Pen borderPen = new Pen(Color.Red, 1);

                for (var i = 0; i < detectedRectangles.Count; i++)
                {
                    gr.DrawImage(
                        detectedImages[i].ToBitmap(),
                        detectedRectangles[i].Location
                        );
                    gr.DrawRectangle(borderPen, detectedRectangles[i]);
                }
            }


            picbDiabloResult.Invalidate();
        }
Beispiel #3
0
        private void btnDiabloDetect_Click(object sender, EventArgs e)
        {
            StopSignDetector.MaskHueLow = (int)numericUpDown1.Value;
            StopSignDetector.MaskHueHigh = (int)numericUpDown2.Value;

            diabloMap = new Image<Bgr, byte>(new Bitmap(picbDiabloMap.Image));

            diabloModels = new Image<Bgr, byte>[3];
            diabloModels[0] = new Image<Bgr, byte>(new Bitmap(picbModel1.Image));
            diabloModels[1] = new Image<Bgr, byte>(new Bitmap(picbModel2.Image));
            diabloModels[2] = new Image<Bgr, byte>(new Bitmap(picbModel3.Image));

            List<Rectangle> detectedRectangles = new List<Rectangle>();
            List<Image<Gray, byte>> detectedImages = new List<Image<Gray, byte>>();

            for (var i = 0; i < diabloModels.Length; i++)
            {
                StopSignDetector detector = new StopSignDetector(diabloModels[2 - i]);

                detector.DetectStopSign(
                    diabloMap,
                    detectedImages,
                    detectedRectangles
                );

                picbDiabloMapMask.Image = StopSignDetector.GetRedPixelMask(diabloMap).ToBitmap();
            }

            using (Graphics gr = Graphics.FromImage(picbDiabloResult.Image))
            {
                Pen borderPen = new Pen(Color.Red, 1);

                for (var i = 0; i < detectedRectangles.Count; i++)
                {
                    gr.DrawImage(
                        detectedImages[i].ToBitmap(),
                        detectedRectangles[i].Location
                    );
                    gr.DrawRectangle(borderPen, detectedRectangles[i]);
                }
            }

            picbDiabloResult.Invalidate();
        }
Beispiel #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            Emgu.CV.Image<Bgr, byte> map = new Image<Bgr, byte>(new Bitmap(picbMap.Image));
            Emgu.CV.Image<Bgr, byte> model = new Image<Bgr, byte>(new Bitmap(picbMask.Image));
            List<Rectangle> detectedRectangles = new List<Rectangle>();
            List<Image<Gray, byte>> detectedImages = new List<Image<Gray, byte>>();

            StopSignDetector detector = new StopSignDetector(model);

            detector.DetectStopSign(
                map,
                detectedImages,
                detectedRectangles
            );

            picbMapMask.Image = StopSignDetector.GetRedPixelMask(map).ToBitmap();
            picbModelMask.Image = StopSignDetector.GetRedPixelMask(model).ToBitmap();

            using (Graphics gr = Graphics.FromImage(picbMap.Image))
            {
                Pen borderPen = new Pen(Color.Red, 1);

                for (var i = 0; i < detectedRectangles.Count; i++)
                {
                    gr.DrawImage(
                        detectedImages[i].ToBitmap(),
                        detectedRectangles[i].Location
                    );
                    gr.DrawRectangle(borderPen, detectedRectangles[i]);
                }
            }

            picbMap.Invalidate();
        }