本文作者Color Space,文章未经作者允许禁止转载!
本文将介绍OpenCVSharp摄像头、视频读取与保存写入!
代码与说明:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using OpenCvSharp;namespace Lesson_04{ class Program { static void Main(string[] args) { VideoCapture cap = new VideoCapture("bike.avi"); //VideoCapture cap = new VideoCapture(0); VideoWriter writer = new VideoWriter("out.avi", FourCC.MP42, 20, new Size(320, 240)); //VideoWriter writer = new VideoWriter("out.avi", FourCC.MP42, 20, new Size(640, 480), false); if (!cap.IsOpened()) { Console.WriteLine("Open video failed!"); return; } Mat frame = new Mat(); Mat gray = new Mat();