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); }
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(); }
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); } }