Пример #1
0
        public void Do(PictureBox pictureBox, Action callback)
        {
            using (var imageFrame = _capture.QueryFrame().ToImage <Bgr, Byte>())
            {
                if (imageFrame != null)
                {
                    var grayframe = imageFrame.Convert <Gray, byte>();
                    var faces     = _cascadeClassifier.DetectMultiScale(grayframe, 1.1, 10,
                                                                        Size.Empty); //the actual face detection happens here

                    foreach (var face in faces)
                    {
                        var c = CenterRect(face);
                        if (Helper.IsPointInPolygon(c, _points))
                        {
                            imageFrame.Draw(face, new Bgr(Color.Chartreuse),
                                            1); //the detected face(s) is highlighted here using a box that is drawn around it/them

                            if (callback != null)
                            {
                                callback();
                            }
                        }
                    }


                    imageFrame.DrawPolyline(_points, true, new Bgr(Color.Crimson), 1);
                    var bmp = EmguHelper.ResizeImage(imageFrame.ToBitmap(), new Size(pictureBox.Width, pictureBox.Height));

                    pictureBox.Image = bmp;
                }
            }
        }
Пример #2
0
        private void RenderPolygon()
        {
            using (var imageFrame = _capture.QueryFrame().ToImage <Bgr, Byte>())
            {
                if (imageFrame != null)
                {
                    _frameSize = imageFrame.Size;


                    if (_done)
                    {
                        imageFrame.DrawPolyline(_points.ToArray(), true, new Bgr(Color.Green), 1);
                    }
                    else
                    {
                        for (int i = 0; i < _points.Count; i++)
                        {
                            imageFrame.Draw(new CircleF(_points[i], 1), new Bgr(Color.Orange),
                                            1);
                        }
                    }
                    var bmp = EmguHelper.ResizeImage(imageFrame.ToBitmap(), new Size(pictureBox1.Width, pictureBox1.Height));
                    pictureBox1.Image = bmp;
                }
            }
        }
Пример #3
0
        public void Do(PictureBox pictureBox, Action callback)
        {
            using (var imageFrame = _capture.QueryFrame().ToImage <Bgr, Byte>())
            {
                if (imageFrame != null)
                {
                    var grayframe = imageFrame.Convert <Gray, byte>();
                    using (HOGDescriptor des = new HOGDescriptor())
                    {
                        des.SetSVMDetector(HOGDescriptor.GetDefaultPeopleDetector());

                        MCvObjectDetection[] results = des.DetectMultiScale(grayframe);
                        var faces = new Rectangle[results.Length];
                        for (int i = 0; i < results.Length; i++)
                        {
                            faces[i] = results[i].Rect;
                        }



                        foreach (var face in faces)
                        {
                            var c = CenterRect(face);
                            if (Helper.IsPointInPolygon(c, _points))
                            {
                                imageFrame.Draw(face, new Bgr(Color.Chartreuse),
                                                1); //the detected face(s) is highlighted here using a box that is drawn around it/them

                                if (callback != null)
                                {
                                    callback();
                                }
                            }
                        }


                        imageFrame.DrawPolyline(_points, true, new Bgr(Color.Crimson), 1);
                        var bmp = EmguHelper.ResizeImage(imageFrame.ToBitmap(), new Size(pictureBox.Width, pictureBox.Height));

                        pictureBox.Image = bmp;
                    }
                }
            }
        }