在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="操作 ...
随机推荐
- webconfig中的&符号问题解决
第一种解决方案 解决方法是将“&”,用“*”代替,取的时候再替换 第二种解决方案 用“&”替换“&”
- SocketClient
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.i ...
- dart 函数练习
import 'dart:convert'; import 'dart:html'; void main() { _getIPAddress() { final url = 'https://http ...
- 纯净CentOS搭建harbor镜像私仓
物理宿主机IP: 192.168.1.4 在官网下载 CentOS-7-x86_64-DVD-1810 用Hyper-v建立一代虚机,安装时遇分辨率问题无法继续,需要在选择启动界面按TAB键以编辑启 ...
- NETGEAR 系列路由器命令执行漏洞简析
NETGEAR 系列路由器命令执行漏洞简析 2016年12月7日,国外网站exploit-db上爆出一个关于NETGEAR R7000路由器的命令注入漏洞.一时间,各路人马开始忙碌起来.厂商忙于声明和 ...
- qunee 缩略图
<!DOCTYPE html> <html> <head> <title>Hello Qunee for HTML5</title> < ...
- NOIP2017 Day1 T3 逛公园
NOIP2017 Day1 T3 更好的阅读体验 题目描述 策策同学特别喜欢逛公园.公园可以看成一张\(N\)个点\(M\)条边构成的有向图,且没有 自环和重边.其中1号点是公园的入口,\(N\)号点 ...
- D - Nested Segments CodeForces - 652D (离散化+树桩数组)
D - Nested Segments CodeForces - 652D You are given n segments on a line. There are no ends of some ...
- da面板修改SSH端口号
进入da面板,找到管理工具菜单下的文件编辑器,点击进入,选择所要编辑的文件/etc/ssh/sshd_config 点击右侧的显示文件,即可打开该文件进行编辑,例如可以将原始端口22修改为 33 #P ...
- PassengerNginxdebian快速部署Rails
Passenger/Nginx/Debian快速部署Rails PassengerNginxdebian快速部署Rails 安装所需的linux包 sudo apt-get install ...