Как сохранить несколько изображений в панели, обнаруженной из live video C# windows forms
Я попробовал этот код, чтобы получить изображения, обнаруженные из живого видео и сохраненные на панели, но он принимает только первое обнаруженное изображение, я хочу, чтобы все изображения были обнаружены с помощью прямоугольника.
Что я уже пробовал:
private VideoCapture capture;
private void Form1_Load(object sender, EventArgs e) { capture = new VideoCapture("C://Users/srinivas/Desktop/small.mp4"); timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { Image<Bgr, Byte> CurrentFrame = capture.QueryFrame().ToImage<Bgr,Byte>(); Image<Gray, byte> bWFrame = CurrentFrame.Convert<Gray, byte>(); Rectangle rect=new Rectangle(120,100,240,350); //CurrentFrame.Draw(rect,new Bgr(Color.DarkSalmon), 1, Emgu.CV.CvEnum.LineType.EightConnected, 0); long detectionTime; List<Rectangle> faces = new List<Rectangle>(); List<Rectangle> eyes = new List<Rectangle>(); DetectFace.Detect(CurrentFrame, "haarcascade_frontalface_default.xml", "haarcascade_eye.xml",faces, eyes,out detectionTime); //DetectFace.Detect(bWFrame, "haarcascade_frontalface_default.xml", "haarcascade_eye.xml", faces, eyes, out detectionTime); List<PictureBox> pictureBoxList = new List<PictureBox>(); foreach (Rectangle rectface in faces) { CurrentFrame.Draw(rectface, new Bgr(Color.DarkSalmon), 1, Emgu.CV.CvEnum.LineType.EightConnected, 0); bWFrame.Draw(rectface, new Gray(50), 1, Emgu.CV.CvEnum.LineType.EightConnected, 0); //Rectangle ra = CurrentFrame.ROI; Bitmap RectAreaImg = CurrentFrame.ToBitmap(); Bitmap ExtractedFace = new Bitmap(rectface.Width, rectface.Height); Graphics facecanvas = Graphics.FromImage(ExtractedFace);// for a specified image new graphis vl creates facecanvas.DrawImage(RectAreaImg, 0, 0, rectface, GraphicsUnit.Pixel);// graphics type ki we r gng to draw image PictureBox pic = new PictureBox(); pic.Image = ExtractedFace; //pic.Location = new Point(x, y); pictureBoxList.Add(pic); foreach (PictureBox p in pictureBoxList) { this.panel1.Controls.Add(p); } //this.panel1.Controls.Add(pic); } imageBox1.Image = CurrentFrame; //imageBox2.Image = bWFrame; label1.Text = Convert.ToString(detectionTime); if(CurrentFrame!=null) { CurrentFrame.Dispose(); } }