I cannot see how you populate the viewer_list and I have a suspicion that it could be a wrong entry.
GetCurrentDisplayedImageAsBitmap will only work when an image is displayed, are you able to see that the image is displayed at the time where this is triggered?
Perhaps you can elaborate on when this is called, is it on user action when viewing something interesting or something else?
From your comment I conclude that the answer to the question: “GetCurrentDisplayedImageAsBitmap will only work when an image is displayed, are you able to see that the image is displayed at the time where this is triggered?”
Is that you do not know if an image is displayed, or some sort of error text is displayed instead. The simplest explanation is that the camera is failing at the time you use the GetCurrentDisplayedImageAsBitmap.
I hope your plugin is coded to handle a null value in a meaningful way, otherwise this might be something you need to change.
“The simplest explanation is that the camera is failing at the time you use the GetCurrentDisplayedImageAsBitmap.”
In this plugin i capture the snapshot with two way (to check for zoom):
BitmapVideoSource
BitmapVideoSource _bitmapVideoSource = new BitmapVideoSource(my_camera);
_bitmapVideoSource.Init();
BitmapData bit = (BitmapData)_bitmapVideoSource.GetNearest(my_datetime);
GetCurrentDisplayedImageAsBitmap (as written above).
BitMapVideoSource.GetNearest() is very resilient, it will find an image if anything has been recorded. Note that the resilience comes from the flexibility that the nearest image might not be very near, if the camera was failing for an hour, it will just find an image outside that period.
In comparison the ImageViewerWpfControl is designed to turn black and give an error text after a period of failure to get images, when the control is reporting error it will return null on GetCurrentDisplayedImageAsBitmap().