开发者

Showing processed images from an IP camera

开发者 https://www.devze.com 2023-03-05 09:37 出处:网络
I have an IP-camera that serves images. These images are then processed via EmguCV and then I want to display the processed images.

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 lea开发者_JAVA百科st show the previous image?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号