在WPF中使用AForge控件
AForge.NET 是用C#写的一个关于计算机视觉和人工智能领域的框架,它包括图像处理、神经网络、遗传算法和机器学习等。
要实现视频功能,需要使用AForge.Controls命名空间中的VideoSourcePlayer控件。这是一个WinForm控件,要在WPF程序中使用,我们需要做如下4步:
1.添加WindowsFormsIntegration应用

2.添加System.Windows.Forms.Integration命名空间
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
3.添加AForge.Controls命名空间
xmlns:aforge ="clr-namespace:AForge.Controls;assembly=AForge.Controls"
4.XAML中加入VideoSourcePlayer可视控件
<wfi:WindowsFormsHost Grid.Row="0" Height="320" Width="240">
<aforge:VideoSourcePlayer x:Name="videoSourcePlayer" Dock="Fill">
</aforge:VideoSourcePlayer>
</wfi:WindowsFormsHost>
VideoSourcePlayer控件需要先引用
AForge.Controls.dll
AForge.Video.dll
AForge.Video.DirectShow.dll
具体代码如下:
public MainWindow()
{
InitializeComponent();
videoSourcePlayer.NewFrame += VideoSourcePlayer_NewFrame;
videoSourcePlayer.Height = ;
videoSourcePlayer.Width = ;
}
private void VideoSourcePlayer_NewFrame(object sender, ref System.Drawing.Bitmap image)
{ } private void Window_Loaded(object sender, RoutedEventArgs e)
{
MJPEGStream mjpegSource = new MJPEGStream("http://192.168.191.1:8080");
OpenVideoSource(mjpegSource);
} private void OpenVideoSource(IVideoSource source)
{
videoSourcePlayer.SignalToStop();
videoSourcePlayer.WaitForStop();
videoSourcePlayer.VideoSource = source;
videoSourcePlayer.Start();
} private void Window_Unloaded(object sender, RoutedEventArgs e)
{
if (videoSourcePlayer.VideoSource != null)
{
videoSourcePlayer.SignalToStop();
videoSourcePlayer.WaitForStop();
}
}
在WPF中使用AForge控件的更多相关文章
- 在WPF中使用WinForm控件方法
1. 首先添加对如下两个dll文件的引用:WindowsFormsIntegration.dll,System.Windows.Forms.dll. 2. 在要使用WinForm控 ...
- WPF中的image控件的Source赋值
WPF中的Image控件Source的设置 1.XAML中 简单的方式(Source="haha.png"); image控件的Source设置为相对路径后(Source=&quo ...
- 在WPF中调用Winform控件
最近在项目中用到了人脸识别和指纹识别,需要调用外部设备和接口,这里就用到了在WPF中调用Winform控件. 第一步,添加程序集引用.System.Windows.Forms和WindowsForms ...
- WPF中的ControlTemplate(控件模板)(转)
原文地址 http://www.cnblogs.com/zhouyinhui/archive/2007/03/28/690993.html WPF中的ControlTemplate(控件模板) ...
- [转]在WPF中使用WinForm控件方法
本文转自:http://blog.csdn.net/lianchangshuai/article/details/6415241 下面以在Wpf中添加ZedGraph(用于创建任意数据的二维线型.条型 ...
- WPF中的ControlTemplate(控件模板)
原文:WPF中的ControlTemplate(控件模板) WPF中的ControlTemplate(控件模板) ...
- [转]WPF中的ControlTemplate(控件模板)
WPF中的ControlTemplate(控件模板) ...
- WindowsXamlHost:在 WPF 中使用 UWP 控件库中的控件
在 WindowsXamlHost:在 WPF 中使用 UWP 的控件(Windows Community Toolkit) 一文中,我们说到了在 WPF 中引入简单的 UWP 控件以及相关的注意事项 ...
- 关于WPF中ItemsControl系列控件中Item不能继承父级的DataContext的解决办法
WPF中所有的集合类控件,子项都不能继承父级的DataContext,需要手动将绑定的数据源指向到父级控件才可以. <DataGridTemplateColumn Header="操作 ...
随机推荐
- 什么是NoSQL,为什么要使用NoSQL?
详见: https://blog.csdn.net/a909301740/article/details/80149552 https://baike.so.com/doc/5569749-57849 ...
- ChinaCock扫描控件介绍-使用TCCBarcodeScanner引起app闪退
好几个ChinaCock的朋友说遇到扫码时闪退,进一步总结,都是Android 8的机器上才会出现,今天我也遇到.正好有朋友说,按下面这个改配置文件就可以解决: <!-- 扫描的activity ...
- web端文件上传,预览,下载,删除
//HTML部分 <div class="item attachment attachmentNew"> <span class="name&quo ...
- php判断
<?php $str = '我是张三?'; preg_match("/张三/", $str, $match); if($match) { echo ' 张三在文本中'; } ...
- ubuntu系统搭建samba服务
安装samba服务 # apt-get install samba 创建一个samba服务的分享目录 # mkdir /share 创建一个samba服务限制的用户及组 #useradd public ...
- Linux用户组管理及用户权限4
权限管理: ls -l rwxrwxrwx: 左三位:定义user(owner)的权限 中三位:定义group的权限 ...
- Tomcat控制台日志输出到本地文件
记事本打开startup.bat文件,修改如下内容 “call “%EXECUTABLE%” start %CMD_LINE_ARGS%” 改为 call "%EXECUTABLE%&quo ...
- HTTP.SYS远程代码执行漏洞测试
简介: 在2015年4月安全补丁日,微软发布的众多安全更新中,修复了HTTP.sys中一处允许远程执行代码漏洞,编号为:CVE-2015-1635(MS15-034 ).利用HTTP.sys的安全漏洞 ...
- httpleaks及url的小技巧(http:evil)
HTTP Leak攻击简介 当前Web技术下包含了大量HTML元素和属性,这些HTML元素和属性会请求一些外部资源,而在它们的HTTP请求过程中,可能存在潜在的敏感信息泄露.为此,德国著名网络安全公司 ...
- pycharm 快捷键及一些常用设置
pycharm中的快捷键及一些常用设置 在PyCharm /opt/pycharm-3.4.1/help目录下可以找到ReferenceCard.pdf快捷键英文版说明 PyCharm Default ...