Grab() публичный Метод

Grabs the frame from camera or file. The grabbed frame is stored internally. The purpose of this function is to grab frame fast that is important for syncronization in case of reading from several cameras simultaneously. The grabbed frames are not exposed because they may be stored in compressed format (as defined by camera/driver). To retrieve the grabbed frame, cvRetrieveFrame should be used.
public Grab ( ) : bool
Результат bool
Пример #1
0
        static void Main(string[] args)
        {
            //var vc = new OpenCvSharp.VideoCapture("./test/india.mp4");
            //var vc = new OpenCvSharp.VideoCapture("./test/Test.mov");
            //var vc = new OpenCvSharp.VideoCapture("./test/singleTest.m4v");

            //var vc = new OpenCvSharp.VideoCapture("./test/peopleTest.m4v");
            var vc = new OpenCvSharp.VideoCapture();

            vc.Open(1);
            ImageRecognizer imageRecognizer = new ImageRecognizer();
            int             key             = int.MinValue;

            using (Window window = new Window("capture"))
            {
                while (key < 0)
                {
                    vc.Grab();
                    var mat = vc.RetrieveMat();
                    if (mat.Empty())
                    {
                        return;
                    }

                    var faces = imageRecognizer.DetectFaces(mat);
                    if (faces != null)
                    {
                        foreach (var face in faces)
                        {
                            var faceCrop = new Mat(mat, face);
                            faceCrop.SaveImage($"./results/{Guid.NewGuid()}.jpg");
                        }
                    }

                    window.ShowImage(mat);
                    key = Cv2.WaitKey(10);
                }
            }
        }