Showing processed images from an IP camera

我是研究僧i 提交于 2020-01-16 04:35:06

问题


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;
    ...
}

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.

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


回答1:


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.



来源:https://stackoverflow.com/questions/5989388/showing-processed-images-from-an-ip-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!