海康威视WPF开发(一)——加载实时视频

本文由 @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的内容完全复制过去……

运行

如果代码没错,配置也没错,直接运行就应该没问题了:(最大张那个是真的,其他的只是图片,分屏还是没做,写了一天的文档,感觉文档比代码难写多了,唉,小公司什么都得自己做)
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值