private void M_capture_ImageGrabbed(object sender, EventArgs e) { // Console.WriteLine("test: " + startIndex.ToString()); // startIndex++; destin = SaveRecordingLocation_textbox.Text; if (fileChanged) { // destin = SaveRecordingLocation_textbox.Text; totalFrames = m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount); fps = m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps); int fourcc = Convert.ToInt32(m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FourCC)); int frameHeight = Convert.ToInt32(m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight)); int frameWidth = Convert.ToInt32(m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth)); string destination = destin + i + ".avi"; videoWriter = new Emgu.CV.VideoWriter(destination, Emgu.CV.VideoWriter.Fourcc('I', 'Y', 'U', 'V'), fps, new System.Drawing.Size(frameWidth, frameHeight), true); fileChanged = false; } Emgu.CV.Mat m = new Emgu.CV.Mat(); m_capture.Retrieve(m); // pictureBox1.Image = m.ToImage<Bgr, byte>().Bitmap; videoWriter.Write(m); //throw new NotImplementedException(); }
public void TestCaptureFromFile() { using (VideoCapture capture = new VideoCapture(EmguAssert.GetFile( "tree.avi"))) using (VideoWriter writer = new VideoWriter("tree_invert.avi", 10, new Size(capture.Width, capture.Height), true)) { int maxCount = 10; Mat img = new Mat(); while (capture.Grab() && maxCount > 0) { capture.Retrieve(img); CvInvoke.BitwiseNot(img, img); writer.Write(img); maxCount--; } } }