Emgu CV

Datetime:2016-08-22 23:36:15          Topic:          Share

摄像头

Capture _capture = new Capture(0);

_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, 30);

_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, capheight);

var frame = _capture.QueryFrame();

视频保存

VideoWriter videoWriter =new VideoWriter(filename,CvInvoke.CV_FOURCC('M', 'J', 'P', 'G'), 20, capwidth , capheight, true);

IntPtr  Fcapture = CvInvoke.cvCreateFileCapture(filename);

videoWriter.WriteFrame<Bgr, Byte>(rimage);

图片操作

Image<Bgr, byte> frameg = image.Copy(rectangle)

frameg  = frameg  .Rotate(90f, new Bgr(0,0,0), false);

frame = frameb.Flip(Emgu.CV.CvEnum.FLIP.HORIZONTAL);

Image<Bgr, byte> rimage = new Image<Bgr, byte>(capwidth , capheight);

CvInvoke.cvSetImageROI(rimage.Ptr, new Rectangle(0, 0, capwidth, capheight));

CvInvoke.cvCopy(frameg .Ptr, rimage.Ptr, IntPtr.Zero);

灰度

Image<Gray, Byte> graye = frameg.Convert<Gray, Byte>().Resize(checkper, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);、

画矩形

frameg.Draw(r, new Bgr(0, 255, 0), 2);