RetrieveBgrFrame() public method

Retrieve a Bgr image frame after Grab()
public RetrieveBgrFrame ( ) : Byte>.Image
return Byte>.Image
        private void YokalmaSistemi_Load(object sender, EventArgs e)
        {
            Capture capture1 = new Capture();

            capture1.Start();
            if (capture1 == null)
            {
                MessageBox.Show("Kamera Açılamadı");
            }
            else
            {
                capture1.ImageGrabbed += (a, b) =>
                {
                    var            image      = capture1.RetrieveBgrFrame();
                    var            grayimage1 = image.Convert <Gray, byte>();
                    HaarCascade    haaryuz    = new HaarCascade("haarcascade_frontalface_default.xml");
                    MCvAvgComp[][] Yuzler     = grayimage1.DetectHaarCascade(haaryuz, 1.2, 5, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(15, 15));
                    MCvFont        font       = new MCvFont(FONT.CV_FONT_HERSHEY_COMPLEX, 0.5, 0.5);
                    foreach (MCvAvgComp yuz in Yuzler[0])
                    {
                        var sadeyuz = grayimage1.Copy(yuz.rect).Convert <Gray, byte>().Resize(100, 100, INTER.CV_INTER_CUBIC);
                        pic_kucuk_res.Image = sadeyuz.ToBitmap();
                        if (train.IsTrained)
                        {
                            name = train.Recognise(sadeyuz);
                            int match_value = (int)train.Get_Eigen_Distance;
                            image.Draw(name + " ", ref font, new Point(yuz.rect.X - 2, yuz.rect.Y - 2), new Bgr(Color.SteelBlue));
                        }
                        image.Draw(yuz.rect, new Bgr(Color.Purple), 2);
                        //  textBox1.Text = name;
                    }
                    pic_kamera.Image = image.ToBitmap();
                };
            }
        }
Example #2
0
        private void run()
        {
            Image<Bgr, Byte> image = new Image<Bgr, byte>("lena.jpg"); //Read the files as an 8-bit Bgr image
            Capture vid = new Capture("kw.avi");
            vid.FlipVertical = true;
            int x = 0;
            TimeSpan time = TimeSpan.Zero;
            MCvFont font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0);
            using (VideoWriter vw = new VideoWriter("out3.avi", 15, 640, 480, true))
            {

                while (vid.Grab())
                {
                    //if (++x % 1 != 0) continue;

                    image = vid.RetrieveBgrFrame();

                    long detectionTime;
                    List<Rectangle> faces = new List<Rectangle>();
                    List<Rectangle> eyes = new List<Rectangle>();
                    DetectFace.Detect(image, "haarcascade_frontalface_default.xml", "supersmile.xml", faces, eyes, out detectionTime);
                    foreach (Rectangle face in faces)
                        image.Draw(face, new Bgr(Color.Red), 2);
                    foreach (Rectangle eye in eyes)
                        image.Draw(eye, new Bgr(Color.Blue), 2);
                    if (eyes.Count > 0) time = time.Add(new TimeSpan(0, 0, 0, 0, 66));
                    //display the image
                    image.Draw(String.Format("{0}:{1}", time.Seconds, time.Milliseconds), ref font, new Point(50, 50), new Bgr(0, 0, 255));
                    setimage(image);
                    vw.WriteFrame<Bgr, Byte>(image);
                }
            }
        }
Example #3
0
        public OgrKayit()
        {
            InitializeComponent();
            updateComboBoxClass();
            Capture capture = new Capture();

            capture.Start();
            if (capture == null)
            {
                MessageBox.Show("Kamera Açılamadı");
            }
            else
            {
                capture.ImageGrabbed += (a, b) =>
                {
                    var            image     = capture.RetrieveBgrFrame();
                    var            grayimage = image.Convert <Gray, byte>();
                    HaarCascade    haaryuz   = new HaarCascade("haarcascade_frontalface_default.xml");
                    MCvAvgComp[][] Yuzler    = grayimage.DetectHaarCascade(haaryuz, 1.2, 5, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(15, 15));
                    MCvFont        font      = new MCvFont(FONT.CV_FONT_HERSHEY_COMPLEX, 0.5, 0.5);
                    foreach (MCvAvgComp yuz in Yuzler[0])
                    {
                        var sadeyuz = grayimage.Copy(yuz.rect).Convert <Gray, byte>().Resize(100, 100, INTER.CV_INTER_CUBIC);
                        image.Draw(yuz.rect, new Bgr(Color.Red), 2);
                        pic_kucuk_res.Image = sadeyuz.ToBitmap();
                    }
                    pic_box_kamera.Image = image.ToBitmap();
                };
            }
        }
        public YokalmaSistemi()
        {
            InitializeComponent();
            list_view_var_olanlar.Columns.Add("Adı Soyadı", 100);
            ComboBoxUpdate();
            Capture capture = new Capture();

            capture.Start();
            if (capture == null)
            {
                MessageBox.Show("Kamera Açılamadı");
            }
            else
            {
                capture.ImageGrabbed += (a, b) =>
                {
                    var            image     = capture.RetrieveBgrFrame();
                    var            grayimage = image.Convert <Gray, byte>();
                    HaarCascade    haaryuz   = new HaarCascade("haarcascade_frontalface_default.xml");
                    MCvAvgComp[][] Yuzler    = grayimage.DetectHaarCascade(haaryuz, 1.2, 5, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(15, 15));
                    MCvFont        font      = new MCvFont(FONT.CV_FONT_HERSHEY_COMPLEX, 0.5, 0.5);
                    foreach (MCvAvgComp yuz in Yuzler[0])
                    {
                        var sadeyuz = grayimage.Copy(yuz.rect).Convert <Gray, byte>().Resize(100, 100, INTER.CV_INTER_CUBIC);
                        pic_kucuk_res.Image = sadeyuz.ToBitmap();
                        if (train.IsTrained)
                        {
                            name = train.Recognise(sadeyuz);
                            int match_value = (int)train.Get_Eigen_Distance;
                            image.Draw(name + " ", ref font, new Point(yuz.rect.X - 2, yuz.rect.Y - 2), new Bgr(Color.SteelBlue));
                        }
                        image.Draw(yuz.rect, new Bgr(Color.Purple), 2);
                    }
                    pic_kamera.Image = image.ToBitmap();
                };
            }
        }