コード例 #1
0
        public static ImageGrabber Create(string uri)
        {
            Console.WriteLine($"Create  {uri}");
            var vc = new VideoCapture(uri);
            var ig = new ImageGrabber(vc);

            Console.WriteLine($"CreatED {uri} with {vc.BackendName} [{ig._id}]");
            return(ig);
        }
コード例 #2
0
        public static async Task RunAsync()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            var tasks = Cams.Select(async x => await ImageGrabber.CreateAsync(x));

            Console.WriteLine($"ImageGrabber.CreateAsync collection: {watch.ElapsedMilliseconds}");

            var results = await Task.WhenAll(tasks.ToList());

            Console.WriteLine($"Task.WhenAll CreateAsync collection: {watch.ElapsedMilliseconds}");

            results.ToList().ForEach(x => x.Start());
            Console.WriteLine($"ForEach Start capturing  collection: {watch.ElapsedMilliseconds}");

            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }
コード例 #3
0
        public static async Task <ImageGrabber> CreateAsync(string uri)
        {
            try
            {
                Console.WriteLine($"Create  {uri}");
                var vc = await Task.Run(() => new VideoCapture(uri, VideoCapture.API.Ffmpeg));

                Console.WriteLine($"CreatED {uri} with {vc.BackendName}");
                var ig = new ImageGrabber(vc);
                Console.WriteLine($"CreatED {uri} with {vc.BackendName} [{ig._id}]");
                return(ig);
            }
            catch (Exception e)
            {
                Console.WriteLine($"FAULT {uri}: {e}");
                return(NullImageGrabber);
            }
        }