C#使用emgucv打开视频并获得各项参数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using Emgu.CV;
using System.Drawing;
namespace 截取视频
{
    class Program
    {
        public static string filePath = "";
        public static string destPath = "";
        public static bool ifPlay = true;
        public class videoParameter{
            public int videoWidth;
            public int videoHeight;
            public int videoCount;
            public int videoFps;
            public int videoInterval;
            public videoParameter(Capture cap)
            {
                videoWidth = (int)cap.GetCaptureProperty(CapProp.FrameWidth);//长
                videoHeight = (int)cap.GetCaptureProperty(CapProp.FrameHeight);//宽
                videoCount = (int)cap.GetCaptureProperty(CapProp.FrameCount);//总帧数
                videoFps = (int)cap.GetCaptureProperty(CapProp.Fps);//帧率,每秒多少张
                videoInterval = (int)(1000 / videoFps);//播放间隔
              //  videoDepth=cap.GetCaptureProperty(CapProp.De)
            }
        }static void Main(string[] args)
        {
            filePath = "D:/test/capture/cap/2.mp4";        
            Capture reader = new Capture(filePath);
            videoParameter vPara = new videoParameter(reader);
            while (ifPlay)
            {
                Mat frame = reader.QueryFrame();
                CvInvoke.NamedWindow("show", NamedWindowType.Normal);                
                CvInvoke.Imshow("show",frame);
                CvInvoke.WaitKey(vPara.videoInterval);
            }
        }
    }
}
原文地址:https://www.cnblogs.com/codeDog123/p/6591743.html