WPF与网络摄像头集成 [英] WPF integrating with web cam

查看:152
本文介绍了WPF与网络摄像头集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么集成一个PictureBox通过WPF来显示视频?

How do you integrate a PictureBox to display a video through WPF?

推荐答案

您可能不希望使用的PictureBox因为它是一个Windows窗体控件,因此从互操作受到限制,显示在WPF图像。

You probably don't want to use PictureBox to display images in WPF because it's a Windows Forms control and therefore suffers from interop limitations.

要显示在WPF图像,使用图像元素。设置其来源是,典型地,一个的BitmapImage其UriSource是位图文件的URI(这可能是文件系统上)。 (如果这是与摄像头的接口更简单的方法,您可以使用另一种类型的ImageSource。)

To display an image in WPF, use the Image element. Set its Source to be, typically, a BitmapImage whose UriSource is the URI of the bitmap file (which might be on the file system). (You can use another ImageSource type if that's an easier way to interface with the webcam.)

要显示视频,使用MediaElement的元素。要显示的视频文件,的MediaElement的源属性设置为视频的URI(其再次可以是文件系统上)。如果你需要拉从网络摄像头图像以形成视频,您需要使用的MediaElement其中MSDN中的类MediaElement的主题中所述的时钟模式。另请参阅多媒体概述中的WPF SDK( http://msdn.microsoft。 COM / EN-US /库/ aa970915.aspx )。

To display video, use the MediaElement element. To display a video file, set MediaElement's Source property to the URI of the video (which again might be on the file system). If you need to pull images from the webcam in order to form the video, you need to use the MediaElement in "clock mode," which is described in the MediaElement class topic in MSDN. See also "Multimedia Overview" in the WPF SDK (http://msdn.microsoft.com/en-us/library/aa970915.aspx).

这篇关于WPF与网络摄像头集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆