在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="操作 ...
随机推荐
- WinForm - 不用自绘实现仿QQ2013
素材啥的都是一手整理的,绝对的原创.这是13年做的,虽然是个老项目了,可里面涉及的winform技术不会过时,所以就拿出来重温探讨下技术要点. 没使用任何自绘命令,可以说是非常容易理解与学习的. 效果 ...
- urllib.parse:很底层,但是是一个处理url路径的好模块
介绍 urllib.parse是为urllib包下面的一个模块,urllib的其它模块完全可以使用requests替代.但是urlli.parse我们是有必要了解的,因为该模块下面有很多操作url路径 ...
- 八,kubernetes集群存储卷基础。
目录 存储卷 存储的分类 emptyDir 测试及使用 hostpath实例 Pod测试挂在共享NFS 写测试清单 测试 pv, pvc 创建几个PV 创建测试的Pod 和 PVC 存储卷 pod运行 ...
- linux基础—课堂随笔07_磁盘存储和文件系统
磁盘管理 管理分区 列出块设备 lsblk parted命令 高级分区操作 用法: parted [选项]... [设备 [命令 [参数]...]...] parted /dev/sdb mkl ...
- 【获取url 问号后参数】防中文乱码
function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&] ...
- D - A or...or B Problem
题意:给定A,B,问[A,B]里取任意个数按位或,结果有多少种. 思路:这题需要找出一个分界点,即找到最高位的B是1,A是0的位置x(最低位从0开始),那么对于所有OR的结果,x处要么是1要么是0,x ...
- Web界面开发必看!Kendo UI for jQuery编辑功能指南第二弹
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- VUE-文本-事件-属性指令
一.Vue文本指令 文本指令: 1.{{ }} 2.v-text:不能解析html语法的文本,会原样输出 3.v-html:能解析html语法的文本 4.v-once:处理的标签的内容只能被解析一次 ...
- Maven 安装 与 使用
下载地址:http://maven.apache.org/download.cgi 下载完成后,配置环境变量 (前提 已经安装JDK )后才能使用. 进入 bin 目录 复制 路径 添加到环境变量中 ...
- SQL Server 删除日志文件
-- 查询日志文件名,用于下面删除 USE [data_name] GO SELECT file_id, name FROM sys.database_files /*删除指定数据库的日志文件*/ U ...