static void Main() { var reader = new CameraCapture(0); //capture from camera //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(); }
public CaptureWindow(int cameraIndex = -1) { InitializeComponent(); pictureBox.SizeMode = PictureBoxSizeMode.Zoom; if (cameraIndex == -1) return; reader = new CameraCapture(cameraIndex); reader.FrameSize = new Size(640, 480); reader.Open(); this.Text = "Camera " + cameraIndex; Application.Idle += capture_NewFrame; }
static void Main() { Console.WriteLine("Press ESC to stop playing"); List<CameraCapture> captures = new List<CameraCapture>(); var cameraCount = CameraCapture.CameraCount; if (cameraCount == 0) { Console.WriteLine("No camera device is present."); return; } //initialize for (int camIdx = 0; camIdx < cameraCount; camIdx++) { var cap = new CameraCapture(camIdx); cap.Open(); captures.Add(cap); } //grab frames Bgr<byte>[][,] frames = new Bgr<byte>[cameraCount][,]; do { for (int camIdx = 0; camIdx < cameraCount; camIdx++) { captures[camIdx].ReadTo(ref frames[camIdx]); if (frames[camIdx] == null) break; frames[camIdx].Show(String.Format("Camera {0}", camIdx), scaleForm: false); } } while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)); //dispose captures.ForEach(x => x.Dispose()); UI.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); //reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4")); //capture from video //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(); }