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(); }
private void btnMapMaskMake_Click(object sender, EventArgs e) { StopSignDetector.MaskHueLow = (int)numericUpDown1.Value; StopSignDetector.MaskHueHigh = (int)numericUpDown2.Value; Emgu.CV.Image <Bgr, byte> map = new Image <Bgr, byte>(new Bitmap(picbDiabloMap.Image)); picbDiabloMapMask.Image = StopSignDetector.GetRedPixelMask(map).ToBitmap(); }
private void btnDiabloInit_Click_1(object sender, EventArgs e) { StopSignDetector.MaskHueLow = (int)numericUpDown1.Value; StopSignDetector.MaskHueHigh = (int)numericUpDown2.Value; 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)); picbModelMask1.Image = StopSignDetector.GetRedPixelMask(diabloModels[0]).ToBitmap(); picbModelMask2.Image = StopSignDetector.GetRedPixelMask(diabloModels[1]).ToBitmap(); picbModelMask3.Image = StopSignDetector.GetRedPixelMask(diabloModels[2]).ToBitmap(); }
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(); }
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(); }
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(); }