一、核心代码:

  

using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace OpenCVDemoService.Service
{
    class CaptureService 
    {
      public void DoSomeThing(DateTime? startTime, long count)
        {

            var cap = VideoCapture.FromCamera(CaptureDevice.Any);
            cap.Set(CaptureProperty.FrameWidth, 512);
            cap.Set(CaptureProperty.FrameHeight, 300);
            Mat mat = new Mat();
            //while ())
            {
                cap.Read(mat);
                File.WriteAllBytes(@"D:\code\cap\" + DateTime.Now.Ticks + ".png", mat.ToBytes());
                
            }
            cap.Release();
            cap.Dispose();
        }
    }
}

说明:

需要中使用OpenCVSharp3来实现,使用前请先Nuget。


相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
相关资源
相似解决方案