Beispiel #1
0
        public void processVideo()
        {
            //CUT PLATE
               Bitmap toEditVideo = pictureboxCatched.Image as Bitmap;
               List<IntPoint> corners = blob.getCorners(toEditVideo);

               if (corners.Count > 0)
               {
               int maxY, minY, maxX, minX;
               if (corners[1].Y < corners[0].Y) maxY = corners[1].Y;
               else maxY = corners[0].Y;

               if (corners[3].Y > corners[2].Y) minY = corners[3].Y;
               else minY = corners[2].Y;

               if (corners[0].X < corners[3].X) minX = corners[0].X;
               else minX = corners[3].X;

               if (corners[1].X < corners[2].X) maxX = corners[2].X;
               else maxX = corners[1].X;

               Rectangle rectangle = new Rectangle(minX, maxY, maxX - minX, minY - maxY);
               System.Drawing.Image img = (System.Drawing.Image)toEditVideo;
               System.Drawing.Image cropped = frame.cropImage(img, rectangle);
               croppedVideo = new Bitmap(cropped);
               croppedVideo = frame.scaleImage(pictureBox1.Width, pictureBox1.Height, croppedVideo);

               pictureBox1.Image = croppedVideo;

               //GREYSCALE & THRESEHOLD
               Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
               // apply the filter
               croppedVideo = filter.Apply(croppedVideo);

               OtsuThreshold thr = new OtsuThreshold();
               //   apply the filter
               thr.ApplyInPlace(croppedVideo);
               pictureBox1.Image = croppedVideo;

               croppedVideo = frame.cutCorners(croppedVideo);
               croppedVideo = frame.scaleImage(pictureBox1.Width, pictureBox1.Height, croppedVideo);
               pictureBox1.Image = croppedVideo;

               statusVideo.Text = "Plate found";

               bmp = pictureBox1.Image as Bitmap;
               frame = new ManageImage(bmp);
               frame.getBlack();

               if (frame.images.Count() > 0)
               {

                   status.Text = "Characters found and saved";

               }
               else status.Text = "No characters found";

               }
               else statusVideo.Text = "Plate not found";

               toEditVideo = blob.ProcessImage(toEditVideo);
               pictureboxCatched.Image = toEditVideo;
        }
Beispiel #2
0
        private void LoadFileButton_Click(object sender, EventArgs e)
        {
            pictureBoxCutPlate.Image = null;
               pictureboxEditPicture.Image = null;

               String input = string.Empty;
               OpenFileDialog dialog = new OpenFileDialog();

               dialog.Filter = "BMP | *.bmp";

              // dialog.InitialDirectory = "D:/Studia/BIAI/Tablice/Tablice/bin/Debug";
             //dialog.InitialDirectory = "C:";
              dialog.InitialDirectory = "C:/Users/k/Documents/GitHub/BIAI_PROJ/BIAI_PROJ/Tablice/Tablice/Images";
               dialog.Title = "Select a text file";
               if (dialog.ShowDialog() == DialogResult.OK)

               input = dialog.FileName;

               if (input == String.Empty)

               return; //user didn't select a file to opena
               toEdit = new Bitmap(dialog.FileName);
               toEdit = frame.scaleImage(pictureboxEditPicture.Width, pictureboxEditPicture.Height, toEdit);
               pictureboxEditPicture.Image = toEdit;

               //CUT PLATE
               List<IntPoint> corners = blob.getCorners(toEdit);

               if (corners.Count > 0)
               {
               int maxY, minY, maxX, minX;
               if (corners[1].Y < corners[0].Y) maxY = corners[1].Y;
               else maxY = corners[0].Y;

               if (corners[3].Y > corners[2].Y) minY = corners[3].Y;
               else minY = corners[2].Y;

               if (corners[0].X < corners[3].X) minX = corners[0].X;
               else minX = corners[3].X;

               if (corners[1].X < corners[2].X) maxX = corners[2].X;
               else maxX = corners[1].X;

               Rectangle rectangle = new Rectangle(minX, maxY, maxX - minX, minY - maxY);
               System.Drawing.Image img = (System.Drawing.Image)toEdit;
               System.Drawing.Image cropped = frame.cropImage(img, rectangle);
               croppedBmp = new Bitmap(cropped);
               croppedBmp = frame.scaleImage(pictureBoxCutPlate.Width, pictureBoxCutPlate.Height, croppedBmp);

               pictureBoxCutPlate.Image = croppedBmp;

               //GREYSCALE & THRESEHOLD
               Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
               // apply the filter
               croppedBmp = filter.Apply(croppedBmp);

               OtsuThreshold thr = new OtsuThreshold();
               //   apply the filter
               thr.ApplyInPlace(croppedBmp);
               pictureBoxCutPlate.Image = croppedBmp;

               croppedBmp = frame.cutCorners(croppedBmp);
               croppedBmp = frame.scaleImage(pictureBoxCutPlate.Width, pictureBoxCutPlate.Height, croppedBmp);
               pictureBoxCutPlate.Image = croppedBmp;
              // pictureBox1.Image = croppedBmp;

               status.Text = "Plate found";

               bmp = pictureBoxCutPlate.Image as Bitmap;
               frame = new ManageImage(bmp);
               frame.getBlack();

               if (frame.images.Count() > 0)
               {

                   status.Text = "Characters found and saved";

               }
               else status.Text = "No characters found";

               }
               else status.Text = "Plate not found";

               toEdit = blob.ProcessImage(toEdit);
               pictureboxEditPicture.Image = toEdit;
        }