1.新建C#项目
2.在项目上右键选择管理Nuget程序包,如下安装OpenCcSharp3-AnyCPU.
using OpenCvSharp;
using OpenCvSharp.Blob;
using OpenCvSharp.UserInterface;
using OpenCvSharp.Extensions;
private void CaptureCameraCallback()
{
Mat frame = new Mat();
//videocapture后面参数为0表示获取电脑本机摄像头的内容
//如果输入rtsp地址就是获取网络摄像头的拍摄内容,rtsp地址可由摄像头厂家提供
//已大华为例 rtsp://用户名:密码@ip:port
capture = new VideoCapture(this.textBoxUrl.Text.Trim());
int sleeptime = (int)Math.Round(1000 / capture.Fps);
while (isCameraRunning)
{
capture.Read(frame);
if (frame.Empty())
{