本文由 @EGWriket出品,转载请注明出处。
http://blog.csdn.net/egwriket/article/details/53002107
环境
硬件:首先你还是得有一台海康的摄像机
软件:windows-x64、vs2012、hkvision5114-x32(x64也可以,看你需要)版本库
配置
参考上一篇:http://blog.csdn.net/egwriket/article/details/52988336
编辑
XAML中使用Winform中的控件PictureBox
1.XAML代码:(注意**部分,另外只是部分代码,仅供参考)
<Window x:Class="WindowsApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="picturebox与WPF结合" Height="400" Width="600"
**xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms**>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
**<WindowsFormsHost Grid.Column="1" MaxHeight="300" Name="pictureHost" >
<wf:PictureBox />
</WindowsFormsHost>**
</Grid>
</Window>
2.c#:改demo的btnPreview_Click(object sender, System.EventArgs e)代码(我参考的是Preview,另外只是部分代码,仅供参考)
public MainWindow()
{
InitializeComponent();
}
System.Windows.Forms.PictureBox pl_camer = null;
private void btnPreview_Click(object sender, System.EventArgs e)
{
……
pl_camer = pictureHost.Child as System.Windows.Forms.PictureBox;
lpPreviewInfo.hPlayWnd = pl_camer.Handle;//预览窗口
……
}
3.添加引用:
右键项目
给红框处打钩
引用sdk
项目下新建 CHCNetSDK.cs,把demo的内容完全复制过去……
运行
如果代码没错,配置也没错,直接运行就应该没问题了:(最大张那个是真的,其他的只是图片,分屏还是没做,写了一天的文档,感觉文档比代码难写多了,唉,小公司什么都得自己做)