在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="操作 ...
随机推荐
- eclipse中svn从分支合并到主干及冲突解决
https://blog.csdn.net/shengqianfeng/article/details/79203156
- windows通讯之evpp
- Vue错误集
1.Component template should contain exactly one root element. If you are using v-if on multiple elem ...
- spring boot 导出 jar 配置文件的问题
网上有很多关联映射及讲解,想要说的是 主要就是 classpath 加上的话 jar就可以找到了
- python在window下环境搭建
1.Python安装包下载 地址:https://www.python.org/downloads/windows/ 然后找到对应系统版本的安装包 下载完成后,直接运行exe安装.在安装的时候开业勾选 ...
- c++实例之通讯录管理系统之清空联系人功能(七)
#include<iostream> using namespace std; constexpr auto MAX = ; //联系人结构体 struct Person { string ...
- IT行业常见职位英文缩写
1.PG Programer 程序员 2.AA ...
- jquery resize()方法 语法
jquery resize()方法 语法 作用:当调整浏览器窗口的大小时,发生 resize 事件.resize() 方法触发 resize 事件,或规定当发生 resize 事件时运行的函数.大理石 ...
- IIS+上传4G文件
最近在学习百度的开源上传组件WebUploader,写了一些示例以记录.WebUploader的缺点是没有一个比较好的现成的界面,这个界面需要自己去实现.自由度高了一些. WebUploader是由B ...
- FZU - 2103 Bin & Jing in wonderland
FZU - 2103 Bin & Jing in wonderland 题目大意:有n个礼物,每次得到第i个礼物的概率是p[i],一个人一共得到了k个礼物,然后按编号排序后挑选出r个编号最大的 ...