使用表达式编码的 WPF 网络摄像头捕获
我正在制作一个将在内置两个网络摄像头的平板电脑设备上运行的应用程序。要求之一是能够捕获图像并保存它们。
到目前为止,我已经能够使用此代码获取网络摄像头输出的预览,
Dim Job As New LiveJob
Dim source As LiveDeviceSource
source = Job.AddDeviceSource(EncoderDevices.FindDevices(EncoderDeviceType.Video).Item(0), Nothing)
source.PreviewWindow = New PreviewWindow(New HandleRef(Me.panPreview, Me.panPreview.Handle))
Job.ActivateSource(source)
这会在托管 winforms 面板中显示预览。问题是如何从该流中捕获图像并返回新的图像对象以供以后处理?
我尝试使用 RenderTargetBitmap 捕获 winforms 主机,但只返回一个黑色矩形,它不会让我渲染 winforms 面板。
I’m making an application that will run on a tablet device that has two webcams built in. One of the requirements is to be able to capture images and save them.
So far I have been able to get the preview of the webcam’s output using this code
Dim Job As New LiveJob
Dim source As LiveDeviceSource
source = Job.AddDeviceSource(EncoderDevices.FindDevices(EncoderDeviceType.Video).Item(0), Nothing)
source.PreviewWindow = New PreviewWindow(New HandleRef(Me.panPreview, Me.panPreview.Handle))
Job.ActivateSource(source)
This displays the preview in a hosted winforms panel. The question is how do I capture an image from this stream and return a new image object for later processing?
I have tried capturing the winforms host using RenderTargetBitmap but just returns a black rectangle and it wont let me render the winforms panel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
刚刚在代码项目中找到了这块宝石。这是代码。这里的 panelVideoPreview 是您的预览,即 panPreview 窗口。希望这有帮助。
Just found this piece of gem on code project. Here goes the code. Here panelVideoPreview is your preview i.e. panPreview window. hope this helps.
如果您想要捕获的窗口上方有一个窗口,那么捕获的将是窗口上方的图像,或者如果您最小化窗口,则同样会捕获坐标的屏幕截图。此方法是使用坐标捕获屏幕。
流媒体的捕获图像如何?
If you have a window over the window you want to capture the capture will be an image of the over window or if you minimize the window occurs the same, you'll capture a screenshot of the coordenates. This method is a capture of screen with coordenates.
How it would be the capture image of the streaming?