using AForge; using AForge.Controls; using AForge.Video; using AForge.Video.DirectShow; using Size = System.Drawing.Size;
FilterInfoCollection videoDevices;
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo device in videoDevices)
{
//可以做出处理
}
FileterInfo info; info = videoDevices[0];//选取第一个,此处可作灵活改动 VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[info.MonikerString); videoSource.DesiredFrameSize = new System.Drawing.Size(214, 281); videoSource.DesiredFrameRate = 1; videoSourcePlayer.VideoSource = videoSource; videoSourcePlayer.Start();
videoSourcePlayer.SignalToStop(); videoSourcePlayer.WaitForStop();
if (videoSourcePlayer.IsRunning)
{
string path = "e:\"
BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
videoSourcePlayer.GetCurrentVideoFrame().GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
PngBitmapEncoder pE = new PngBitmapEncoder();
pE.Frames.Add(BitmapFrame.Create(bitmapSource));
string picName = path + "paizhao" + ".jpg";
if (File.Exists(picName))
{
File.Delete(picName);
}
using (Stream stream = File.Create(picName))
{
pE.Save(stream);
}
}
BitmapImage bmi = new System.Windows.Media.Imaging.BitmapImage();
bmi.BgeinInit(); bmi.UriSource = new Uri(picName); bmi.CacheOption = BitmapCacheOption.OnLoad; bmi.EndInit();
this.image.Source = bmi;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有