How do you integrate a PictureBox to display a video through WPF?
问题:
回答1:
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.
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.)
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).
回答2:
Also try WPF MediaKit. The WPF MediaKit has a VideoCaptureElement control for WebCam support!