コード例 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            //image process start (process Button)

            if (this.processButtonFlag)
            {
                CascadeClassifier haarCascadeClassifier = new CascadeClassifier(@"C:\Users\user\Dataset\wider_face_yolo\benchmark\tester\C#\TraningProgramming\Xisom.FaceDetection\FaceDetector.OpenCvSharp\Resources\haarcascade_frontalface_default.xml");
                // adding all filelist to to the datagridview
                List <Rect> faceList = new List <Rect>();
                var         src      = new Mat(this.fileList[this.imageID], ImreadModes.Grayscale);
                var         dst      = new Mat(this.fileList[this.imageID], ImreadModes.Color);
                Rect[]      faces    = haarCascadeClassifier.DetectMultiScale(src, 1.1, 5);

                if (faces.Length > 0)
                {
                    for (int i = 0; i < faces.Length; i++)
                    {
                        faceList.Add(faces[i]);
                        Cv2.Rectangle(dst, faces[i], Scalar.White, 3);
                    }
                }

                this.image               = BitmapConverter.ToBitmap(dst);
                pictureBox1.Image        = (Image)image;
                pictureBox1.SizeMode     = PictureBoxSizeMode.StretchImage;
                this.processedListedface = new ListedFaces(faceList);

                //datagridview add and parse to dataset;

                DataRow dataRow = this.gridDataTable.NewRow();
                dataRow["ID"] = this.imageID.ToString();
                dataRow["File Information"] = this.fileList[this.imageID].ToString();
                dataRow["Face(s)"]          = (this.processedListedface.SerializeObject());

                this.gridDataTable.Rows.Add(dataRow);

                dataGridView1.AutoSize   = true;
                dataGridView1.DataSource = this.gridDataset.Tables[0];

                this.processButtonFlag = false;
                if (!this.hasProcessed)
                {
                    this.hasProcessed = true;
                }
                saveButton.Visible = true;
            }
        }
コード例 #2
0
        public ImageDisplay(string filename, ListedFaces listedFaces)
        {
            InitializeComponent();
            this.listedFaces = listedFaces;
            this.filename    = filename;

            var dst = new Mat(this.filename, ImreadModes.Color);

            for (int i = 0; i < listedFaces.faces.Count; i++)
            {
                Cv2.Rectangle(dst, listedFaces.faces[i], Scalar.White, 3);
            }

            this.image = BitmapConverter.ToBitmap(dst);
            displayPictureBox.Image    = (Image)image;
            displayPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            fileNameLabel.Text         = this.filename;
        }
コード例 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // showing the data as a new form
            DataGridView dgv = sender as DataGridView;

            if (dgv != null)
            {
                this.fileName = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                this.imageID  = int.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                this.image    = new Bitmap(this.fileList[imageID]);
                var dst = new Mat(this.fileList[this.imageID], ImreadModes.Color);

                XmlSerializer reader   = new XmlSerializer(typeof(ListedFaces));
                string        faceData = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();

                ListedFaces listedFaces = (ListedFaces)reader.Deserialize(new StringReader(faceData));

                try
                {
                    this.processedListedface = listedFaces;
                    for (int i = 0; i < listedFaces.faces.Count; i++)
                    {
                        Cv2.Rectangle(dst, listedFaces.faces[i], Scalar.White, 3);
                    }

                    this.image           = BitmapConverter.ToBitmap(dst);
                    pictureBox1.Image    = (Image)image;
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                catch
                {
                    MessageBox.Show("image File not found");
                }
                progressBar1.Value = this.imageID;
                label3.Text        = "Image Count " + this.imageID;

                Form imagedisplay = new ImageDisplay(this.fileName, listedFaces);
                imagedisplay.Show();
            }
        }
コード例 #4
0
        private void autoProcess_Click(object sender, EventArgs e)
        {
            autoProcess.Visible       = false;
            pauseButton.Visible       = true;
            this.autoPlayButtonActive = true;
            this.pressPauseButton     = false;;
            processButton.Visible     = false;
            saveButton.Visible        = false;


            for (int k = 0; k < this.fileList.Length; k++)
            {
                this.imageID = k;
                if (this.pressPauseButton)
                {
                    this.autoPlayButtonActive = false;
                    this.autoProcessIdx       = k;
                    break;
                }
                if (this.autoProcessIdx != 0)
                {
                    k = autoProcessIdx;
                }
                CascadeClassifier haarCascadeClassifier = new CascadeClassifier(@"C:\Users\user\Dataset\wider_face_yolo\benchmark\tester\C#\TraningProgramming\Xisom.FaceDetection\FaceDetector.OpenCvSharp\Resources\haarcascade_frontalface_default.xml");
                // adding all filelist to to the datagridview
                List <Rect> faceList = new List <Rect>();
                var         src      = new Mat(this.fileList[this.imageID], ImreadModes.Grayscale);
                var         dst      = new Mat(this.fileList[this.imageID], ImreadModes.Color);
                Rect[]      faces    = haarCascadeClassifier.DetectMultiScale(src, 1.1, 5);

                if (faces.Length > 0)
                {
                    for (int i = 0; i < faces.Length; i++)
                    {
                        faceList.Add(faces[i]);
                        Cv2.Rectangle(dst, faces[i], Scalar.White, 3);
                    }
                }

                this.image               = BitmapConverter.ToBitmap(dst);
                pictureBox1.Image        = (Image)image;
                pictureBox1.SizeMode     = PictureBoxSizeMode.StretchImage;
                this.processedListedface = new ListedFaces(faceList);
                progressBar1.Value       = this.imageID;
                //datagridview add and parse to dataset;

                DataRow dataRow = this.gridDataTable.NewRow();
                dataRow["ID"] = this.imageID.ToString();
                dataRow["File Information"] = this.fileList[this.imageID].ToString();
                dataRow["Face(s)"]          = (this.processedListedface.SerializeObject());
                this.gridDataTable.Rows.Add(dataRow);
                label3.Text = "Image Count: " + this.imageID;
                Thread.Sleep(300);
                if (this.autoPlayButtonActive)
                {
                    //impliment todo??
                }
            }



            dataGridView1.DataSource = this.gridDataset.Tables[0];

            this.processButtonFlag = true;
            saveButton.Visible     = true;
            autoProcess.Visible    = true;
            this.pressPauseButton  = false;
            processButton.Visible  = true;
        }