使用C#从摄像机捕获视频流的最简单,最快捷的方法是什么?
答案 0 :(得分:4)
最简单,最简单的可能就是使用Microsoft Expression Encoder SDK:
static void Main( string[] args )
{
var job = new Microsoft.Expression.Encoder.Live.LiveJob();
job.AddDeviceSource( job.VideoDevices[0],job.AudioDevices[0] );
var w = new System.Windows.Forms.Form();
w.Show();
var source = job.DeviceSources[0];
source.PreviewWindow = new Microsoft.Expression.Encoder.Live.PreviewWindow( new System.Runtime.InteropServices.HandleRef(w, w.Handle) );
Console.ReadKey();
}
答案 1 :(得分:-1)
看看Github上的DotImaging项目: https://github.com/dajuric/dot-imaging
var reader = new CameraCapture(); //create camera/file/image-directory capture
reader.Open();
var frame = reader.ReadAs<Bgr<byte>>(); //read single frame
reader.Close();
更详细的样本: https://github.com/dajuric/dot-imaging/blob/master/Samples/Capture/Program.cs
NuGet包可在以下位置获得: https://www.nuget.org/packages/DotImaging.IO/
这很容易。