显示来自IP摄像机的已处理图像 [英] Showing processed images from an IP camera

查看:293
本文介绍了显示来自IP摄像机的已处理图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个提供图像的IP摄像机。然后通过 EmguCV 处理这些图片,然后我要显示处理过的图片。

I have an IP-camera that serves images. These images are then processed via EmguCV and then I want to display the processed images.

要显示图片,我使用以下代码:

To show the images, I use this code:

Window1(){
     ...
     this.Dispatcher.Hooks.DispatcherInactive 
         += new EventHandler(Hooks_DispatcherInactive);
}

Hooks_DispatcherInactive(...)
{
    Next()
}

接下来()调用调用图像处理方法并显示图像:

Next() the calls calls the image processing methods and (should) display the image:

MatchResult? result = survey.Step();
if (result.HasValue)
{
    Bitmap bit = result.Value.image.Bitmap;
    ImageSource src = ConvertBitmap(bit);
    show.Source = src;
    ...
}

30fps网络摄像头。但是,当我通过浏览器访问它们时,IPCam的图像需要一秒钟到达这里。所以,在同一时间,WPF显示什么,甚至没有处理的以前的图像。

This works fine when I hook up a normal 30fps webcam. But, the IPCam's images take over a second to get here, also when I access them via a browser. So, in the mean time, WPF shows nothing, not even the previous image that was processed.

如何让WPF至少显示上一张图片?

How can I get WPF to at least show the previous image?

推荐答案

您可以使用创建(从阵列)创建(从IntPtr)并在WPF的Image控件中显示BitmapSource
或者你可以使用DirectX来做到这一点更快(对于30fps(和1fps)BitmapSource方法应该做的)。

You can copy the image's buffer into a new BitmapSource image of the same format (PixelFormat, Height, Width, stride) using Create (from Array) or Create (from IntPtr) and display that BitmapSource in WPF's Image control, or you can use DirectX to do that faster (for 30fps (and 1fps) the BitmapSource approach should do).

视图,而是使用绑定和命令。

Also, consider NOT using events in the view, instead use bindings and commands.

这篇关于显示来自IP摄像机的已处理图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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