当前位置: 首页 > news >正文

分析网站的网站演出公司网站建设

分析网站的网站,演出公司网站建设,天猫的网站建设,wordpress如何添加菜单最近由于某种原因呢#xff0c;需要做一下拍照的功能#xff0c;本来我纠结到底用AForge类库还是用WPFMediaKit.dll #xff0c;不过后来看网上说WPFMediaKit.dll 是截图而AForge是直接通过摄像头拍照#xff0c;于是乎#xff0c;我就选择了AForge类库。 首先留下发帖时我…最近由于某种原因呢需要做一下拍照的功能本来我纠结到底用AForge类库还是用WPFMediaKit.dll 不过后来看网上说WPFMediaKit.dll 是截图而AForge是直接通过摄像头拍照于是乎我就选择了AForge类库。 首先留下发帖时我所用的AForge    链接https://pan.baidu.com/s/1htmOjPi 密码tovd 第一步   将AForge中的DLL添加进引用然后添加引用System.DrawingSystem.Windows.FormsWindowsFormsIntegration 第二步   加上    xmlns:wfi clr-namespace:System.Windows.Forms.Integration;assemblyWindowsFormsIntegration        xmlns:aforge clr-namespace:AForge.Controls;assemblyAForge.Controls   还有   wfi:WindowsFormsHost Grid.Row0 HorizontalAlignmentLeft Width517 Height320 VerticalAlignmentTop            aforge:VideoSourcePlayer x:Nameplayer Height480 Width640/        /wfi:WindowsFormsHost   下面贴详细代码 MainWindow.xaml Window x:ClassFaceOne.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:FaceOnexmlns:wfi clr-namespace:System.Windows.Forms.Integration;assemblyWindowsFormsIntegrationxmlns:aforge clr-namespace:AForge.Controls;assemblyAForge.Controlsmc:IgnorabledTitleMainWindow Height600 Width800 LoadedWindow_LoadedGridwfi:WindowsFormsHost Grid.Row0 HorizontalAlignmentLeft Width517 Height320 VerticalAlignmentTopaforge:VideoSourcePlayer x:Nameplayer Height480 Width640//wfi:WindowsFormsHostButton x:NameconnectBtn Content连接 HorizontalAlignmentLeft Margin53,439,0,0 VerticalAlignmentTop Width75 ClickconnectBtn_Click/Button x:NamecaptureBtn Content拍照 HorizontalAlignmentLeft Margin180,439,0,0 VerticalAlignmentTop Width75 ClickcaptureBtn_Click/Button x:NamecloseBtn Content断开 HorizontalAlignmentLeft Margin312,439,0,0 VerticalAlignmentTop Width75 ClickcloseBtn_Click/Image x:NameimageCapture HorizontalAlignmentLeft Height210 Margin522,66,0,0 VerticalAlignmentTop Width239//Grid /Window MainWindow.xaml.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;namespace FaceOne {/// summary/// MainWindow.xaml 的交互逻辑/// /summarypublic partial class MainWindow : Window{MyCapture myCapture MyCapture.Instance();public MainWindow(){InitializeComponent();}private void Window_Loaded(object sender, RoutedEventArgs e){//myCapture.sourcePlayer player;//配置好XAML后再加上这句即可看到摄像头的视图 myCapture.getCamera();//获取摄像头myCapture.saveOk ImageSaveOk;//保存照片后触发}//连接private void connectBtn_Click(object sender, RoutedEventArgs e){myCapture.CameraConn();}//拍照private void captureBtn_Click(object sender, RoutedEventArgs e){myCapture.CaputreImage();}//断开private void closeBtn_Click(object sender, RoutedEventArgs e){myCapture.CloseDevice();}//保存照片后触发(想看预览就用不想看就不需要了)private void ImageSaveOk(string str){/*//老套的赋值方式不会释放内存BitmapImage bit new BitmapImage();bit.BeginInit();bit.UriSource new Uri(AppDomain.CurrentDomain.BaseDirectorystr);bit.EndInit();imageCapture.Source bit;*/BitmapImage bmi myCapture.InitImage(str);imageCapture.Source bmi;}} } MyCapture.cs using AForge.Controls; using AForge.Video.DirectShow; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Media.Imaging;namespace FaceOne {class MyCapture{public delegate void SaveOk(string str);public SaveOk saveOk;private static MyCapture instance;public static MyCapture Instance(){if (instance null){instance new MyCapture();}return instance;}//private static FilterInfoCollection _cameraDevices;private FilterInfoCollection videoDevices;//private static VideoCaptureDevice div null;VideoCaptureDevice videoSource;public VideoSourcePlayer sourcePlayer new VideoSourcePlayer();public void getCamera(){// 获取电脑已经安装的视频设备videoDevices new FilterInfoCollection(FilterCategory.VideoInputDevice);if (videoDevices ! null videoDevices.Count 0){foreach (FilterInfo device in videoDevices){Console.WriteLine(device.Name);}//CameraConn();}}//连接并且打开摄像头public void CameraConn(){if (videoDevices.Count 0){Console.WriteLine(请插入视频设备);return;}videoSource new VideoCaptureDevice(videoDevices[0].MonikerString);//连接到第一个设备可灵活改动//videoSource.DesiredFrameSize new System.Drawing.Size(240, 320);//videoSource.DesiredFrameRate 1; sourcePlayer.VideoSource videoSource;videoSource.Start();sourcePlayer.Start();}//截取一帧图像并保存public void CaputreImage(string filePathnull,string fileNamenull){if (sourcePlayer.VideoSource null){return;}//判断是否有这个目录如果没有则新创建这个目录/*if (!Directory.Exists(filePath)){Directory.CreateDirectory(filePath);}*/try{Image bitmap sourcePlayer.GetCurrentVideoFrame();/*if (fileName null){fileName DateTime.Now.ToString(yyyy-MM-dd-HH-mm-ss);}*///string str fileName .jpg;string str asd.jpg;//使用InitImage可以重复读写一张图不用的话就只能一直保存新的图片了bitmap.Save(str,ImageFormat.Jpeg); //想看预览就用不想看就不需要了 bitmap.Dispose();saveOk(str);}catch(Exception e){Console.WriteLine(e.Message.ToString());}}//关闭摄像头设备public void CloseDevice(){if (videoSource ! null videoSource.IsRunning){sourcePlayer.Stop();videoSource.SignalToStop();videoSource null;videoDevices null;}}//解决不同进程读取同一张图片的问题使用流来读图片public BitmapImage InitImage(string filePath){BitmapImage bitmapImage;using (BinaryReader reader new BinaryReader(File.Open(filePath, FileMode.Open))){FileInfo fi new FileInfo(filePath);byte[] bytes reader.ReadBytes((int)fi.Length);reader.Close();//image new Image();bitmapImage new BitmapImage();bitmapImage.BeginInit();bitmapImage.StreamSource new MemoryStream(bytes);bitmapImage.EndInit();bitmapImage.CacheOption BitmapCacheOption.OnLoad;//image.Source bitmapImage;reader.Dispose();}return bitmapImage;}} }  转载于:https://www.cnblogs.com/lingLuoChengMi/p/8466559.html
http://www.huolong8.cn/news/134412/

相关文章:

  • 南宁在线制作网站石家庄网络推广优化
  • dreamwear做网站步骤网站申请好了 怎么建设
  • 万网个人网站建设教程网站设计
  • 免费商城网站申请便民平台推广怎么做
  • 公司官方网站建设申请自己怎么制作企业网站
  • 网站分站如何做html基础知识思维导图
  • 崇仁网站建设推广网站空间不够用
  • 用模板搭建的网站备案吗做婚纱影楼网站的价格
  • 企业做网站需要那些条件自媒体营销代理
  • 企业设计网站公司排名西安网上注册公司流程
  • 哈尔滨建设银行网站首页企业app软件定制开发环节
  • 做网站的前途个人可以做导航网站吗
  • 找人做个网站建设制作报价方案wordpress换域名主题
  • 英语培训学校网站怎么做cms系统表单
  • 京东的网站是哪家公司做永清县建设局网站
  • h5和手机网站wordpress 自定义链接
  • 网站支付功能怎么做设计网站都有哪些
  • 电力建设期刊网站经常维护吗福州如何做百度的网站
  • 哪个网站的ps元素好网站建设需要具备
  • 网站建设多少钱 知乎网站制作咨询
  • 怎么用frontpage做网站什么网站做装修的
  • 网站seo外链平台紧固件做网站有效果吗
  • 介绍一学一做视频网站吗商城购物网站开发背景
  • 找专业公司做网站蒙阴县建设局网站
  • 网站设计素材网站合肥市城乡城乡建设局网站
  • 富阳网站制作做网站语言排名2018
  • 南阳网站建设域名公司网站集约化建设试点
  • 网站开发页面设计过程便捷的邢台做网站
  • 怎么开网页游戏平台seo建站教学
  • wordpress删除小工具英文谷歌seo