标签:从视频中提取图片
public void VideoCatch(string filepath) { try { IntPtr CatchFrame =CvInvoke.cvCreateFileCapture(filepath); CvInvoke.cvNamedWindow("打开视频"); // 得到总帧数 CvInvoke.cvGetCaptureProperty(CatchFrame, Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT); // 视频宽度 int wd = (int)CvInvoke.cvGetCaptureProperty(CatchFrame, Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH); // 视频高度 int hg = (int) CvInvoke.cvGetCaptureProperty(CatchFrame, Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT); // 当前帧位置 CvInvoke.cvGetCaptureProperty(CatchFrame, Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES); // 帧频 CvInvoke.cvGetCaptureProperty(CatchFrame, Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS); while (true) { var FrameImg = CvInvoke.cvQueryFrame(CatchFrame); CvInvoke.cvShowImage("打开视频", FrameImg); Image<Bgr, byte> FramePic = new Image<Bgr, byte>(wd,hg); CvInvoke.cvCopy(FrameImg,FramePic,IntPtr.Zero); int c = CvInvoke.cvWaitKey(20); if (c == 13) break; if (c == 32) { Random rd = new Random(); Bitmap bt = new Bitmap(FramePic.ToBitmap()); string picname = rd.Next()+".jpg"; bt.Save(picname); Console.WriteLine("保存成功!"+picname); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
标签:从视频中提取图片
原文地址:http://blog.csdn.net/u013617144/article/details/46453829