static void Main(string[] args) { //initialize capture and buffer VideoCaptureBase capture = new FileCapture("../Resources/video-vignette.mp4"); // /*or*/ capture = new CameraCapture(); Bgr <byte>[,] frame = null; //initialize devignetting alg capture.ReadTo(ref frame); var devignetting = new Devignetting(frame, optimizeVignettingCentre: true); Bgr <byte>[,] correctedIm = frame.CopyBlank(); //do the job do { capture.ReadTo(ref frame); if (frame == null) { break; } frame.Show("Original"); frame.CopyTo(correctedIm, Point.Empty); bool isDone = devignetting.DevignetteSingleStep(correctedIm); correctedIm.Show("Corrected"); Console.WriteLine("Frame: {0:000}, is done: {1}", capture.Position, isDone); }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); capture.Close(); }
static void Main() { //var reader = new CameraCapture(0); //capture from camera var reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4")); reader.Open(); var writer = new VideoWriter(@"output.avi", reader.FrameSize, /*reader.FrameRate does not work Cameras*/ 30); //TODO: bug: FPS does not work for cameras writer.Open(); Bgr <byte>[,] frame = null; do { reader.ReadTo(ref frame); if (frame == null) { break; } using (var uFrame = frame.Lock()) { writer.Write(uFrame); } frame.Show(scaleForm: true); }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); reader.Dispose(); writer.Dispose(); UI.CloseAll(); }
static void Main() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced //var reader = new CameraCapture(0); //capture from camera var reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4")); reader.Open(); var writer = new VideoWriter(@"output.avi", reader.FrameSize, /*reader.FrameRate does not work Cameras*/ 30); //TODO: bug: FPS does not work for cameras writer.Open(); Bgr <byte>[,] frame = null; do { reader.ReadTo(ref frame); if (frame == null) { break; } using (var uFrame = frame.Lock()) { writer.Write(uFrame); } frame.Show(autoSize: true); }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); reader.Dispose(); writer.Dispose(); ImageUI.CloseAll(); }
static void Main() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced Console.WriteLine("Press ESC to stop playing"); //var reader = new CameraCapture(0); //capture from camera //(reader as CameraCapture).FrameSize = new Size(640, 480); var reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4")); //capture from video //var reader = new ImageDirectoryCapture(Path.Combine(getResourceDir(), "Sequence"), "*.jpg"); reader.Open(); Bgr <byte>[,] frame = null; do { reader.ReadTo(ref frame); if (frame == null) { break; } frame.Show(autoSize: true); }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); reader.Dispose(); ImageUI.CloseAll(); }
static void Main() { Console.WriteLine("Press ESC to stop playing"); //var reader = new CameraCapture(0); //capture from camera //(reader as CameraCapture).FrameSize = new Size(640, 480); var reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4")); //capture from video //var reader = new ImageDirectoryCapture(Path.Combine(getResourceDir(), "Sequence"), "*.jpg"); reader.Open(); Bgr <byte>[,] frame = null; do { reader.ReadTo(ref frame); if (frame == null) { break; } frame.Show(scaleForm: true); }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); reader.Dispose(); }
public static void Main() { //var pipeName = new Uri("http://trailers.divx.com/divx_prod/divx_plus_hd_showcase/BigBuckBunny_DivX_HD720p_ASP.divx").NamedPipeFromVideoUri(); //web-video var pipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(); //Youtube ImageStreamReader reader = new FileCapture(String.Format(@"\\.\pipe\{0}", pipeName)); reader.Open(); Bgr <byte>[,] frame = null; do { reader.ReadTo(ref frame); if (frame == null) { break; } frame.Show(scaleForm: true); ((double)reader.Position / reader.Length).Progress(); }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); Console.WriteLine("The end."); //--------------------------------------------------------------------------- Console.WriteLine("Downloading video..."); string fileExtension; pipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(out fileExtension); //Youtube pipeName.SaveNamedPipeStream("out" + fileExtension); Console.WriteLine("Video saved."); }
public static void Main() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced var sourceName = String.Empty; //video over pipe (direct link and Youtube) (do not support seek) //var pipeName = new Uri("http://trailers.divx.com/divx_prod/divx_plus_hd_showcase/BigBuckBunny_DivX_HD720p_ASP.divx").NamedPipeFromVideoUri(); //web-video var pipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(); //Youtube sourceName = String.Format(@"\\.\pipe\{0}", pipeName); //video http link (Supports seek) //sourceName = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"; //--------------------------------------------- ImageStreamReader reader = new FileCapture(sourceName); reader.Open(); //seek if you can if (reader.CanSeek) { reader.Seek((int)(reader.Length * 0.25), System.IO.SeekOrigin.Begin); } //read video frames Bgr <byte>[,] frame = null; while (true) { reader.ReadTo(ref frame); if (frame == null) { break; } frame.Show(scaleForm: false); ((double)reader.Position / reader.Length).Progress(); } Console.WriteLine("The end."); //--------------------------------------------------------------------------- UI.CloseAll(); Console.WriteLine("Downloading video..."); string fileExtension; var downloadPipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(out fileExtension); //Youtube downloadPipeName.SaveNamedPipeStream("out" + fileExtension); Console.WriteLine("Video saved."); Process.Start("out" + fileExtension); //open local file }
public static void Main() { var sourceName = String.Empty; //video over pipe (direct link and Youtube) (do not support seek) //var pipeName = new Uri("http://trailers.divx.com/divx_prod/divx_plus_hd_showcase/BigBuckBunny_DivX_HD720p_ASP.divx").NamedPipeFromVideoUri(); //web-video var pipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(); //Youtube sourceName = String.Format(@"\\.\pipe\{0}", pipeName); //video http link (Supports seek) //sourceName = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"; //--------------------------------------------- ImageStreamReader reader = new FileCapture(sourceName); reader.Open(); //seek if you can if (reader.CanSeek) { reader.Seek((int)(reader.Length * 0.25), System.IO.SeekOrigin.Begin); } //read video frames Bgr <byte>[,] frame = null; do { reader.ReadTo(ref frame); if (frame == null) { break; } frame.Show(scaleForm: true); ((double)reader.Position / reader.Length).Progress(); }while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); Console.WriteLine("The end."); //--------------------------------------------------------------------------- Console.WriteLine("Downloading video..."); string fileExtension; var downloadPipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(out fileExtension); //Youtube downloadPipeName.SaveNamedPipeStream("out" + fileExtension); Console.WriteLine("Video saved."); Process.Start("out" + fileExtension); //open local file }