Hi,
We are integrating alarms using the MIP SDK.
We retrieve alarms using IAlarmClient.GetAlarmLines(). When an alarm is selected in the XProtect Smart Client, an associated image/video preview is displayed.
Our requirement is to retrieve this same image through the MIP SDK.
We tried using the following API:
SnapshotList snapshots = alarmClient.GetSnapshots(alarm.Id);
However, GetSnapshots() always returns an empty collection for all tested alarms such as Motion Detected and Motion Stopped.
Could you please advise on the correct way to retrieve the image associated with an alarm?
Specifically, we would like to know whether the image displayed in the Smart Client is an actual snapshot associated with the alarm that can be retrieved through the MIP SDK.
If the image is available through the MIP SDK, could you please let us know which API or approach should be used to retrieve it?
Thank you.
When you get the Alarm, you already have the camera ID and timestamp. Those two pieces of information are all you need to retrieve the image recorded at that time.
This is actually a question that comes up regularly and I have made a small sample demonstrating this. It is based on the AlarmEventViewer sample with a small addition. Please see the sample here.
Also note that Snapshots are something different. When an Analytics Event is submitted, it can optionally include one or more snapshots as metadata. These images can be anything and are not necessarily camera images. Therefore, GetSnapshots() will typically return empty for standard alarms such as Motion Detected or Motion Stopped.
PS. Perhaps you will find the answer and discussion here interesting: Camera Snapshot When Motion Detection
Hi Bo,
Thank you for the clarification.
The requirement is specifically related to Analytics Events. As mentioned, an Analytics Event can optionally include one or more snapshots as metadata.
The goal is to retrieve the image URL/path, or another image reference, that was included with the Analytics Event. The requirement is not to retrieve a recorded image using the camera ID and event timestamp.
Initially, GetSnapshots(alarm.Id) was tested with motion-detection alarms and always returned an empty collection. Since those alarms may not contain snapshot metadata, an Analytics Event generated by face detection was also tested. However, GetSnapshots(alarm.Id) still returned an empty collection.
Is any specific configuration required on the VMS side for snapshot metadata from an Analytics Event to be stored and returned by GetSnapshots(alarm.Id)?
Additionally, are there any requirements on the analytics-event source or integration side to ensure that the snapshot is included correctly and made available through GetSnapshots()?
The difficulty is in the testing. You mention that GetSnapshots() always returns an empty collection. This is actually expected behavior unless the alarm is associated with an analytics event that contains a snapshot.
To test this, make sure you submit an Analytics Event that includes a snapshot. An easy way to do that is to use the Library Event Generator sample application without modifications and trigger an event using the Image… button, which attaches an image to the event.
Once such an event generates an alarm, GetSnapshots() should return the associated snapshot(s).
The Library Event Generator sample is described here.
Hi Bo,
Thank you for the guidance.
Using the Library Event Generator sample application and attaching an image to the Analytics Event, I am now able to retrieve the associated snapshot(s) using GetSnapshots().
I have a couple of follow-up questions:
-
The sample application successfully generates Analytics Events with associated snapshots. How can the same behavior be achieved in a real VMS environment? Specifically, what configuration is required so that Analytics Events include snapshots that can be retrieved using GetSnapshots()?
-
GetSnapshots() returns the snapshot successfully, and the image bytes are available. However, the Path property of the returned Snapshot object is null. My requirement is to obtain the snapshot path (or a URL/reference to the stored image) rather than the image bytes. Is there a way to retrieve the snapshot path or another reference to the stored image through the MIP SDK?
Thank you for your help.
In a real XProtect VMS environment, this requires an integration that submits analytics events with snapshots attached, similar to what the sample demonstrates.
In practice, this is relatively uncommon. As an example, Milestone LPR does not store snapshots with events. Instead, it submits metadata/overlay information. When viewed in Smart Client, the original camera video is retrieved from the media database and the LPR information is rendered as an overlay.
The reason for this design is performance and scalability. Snapshots submitted with events are stored in the configuration/events SQL database. Since many XProtect installations run on limited SQL Server deployments, storing large numbers of images can quickly consume database capacity.
If snapshots have been submitted as image data, they can only be accessed through GetSnapshots(), which returns the image data itself. There is no built-in mechanism to retrieve a URL or reference that can later be used to request the image from the VMS, unless a custom integration has been developed for that purpose.
The REST API does allow a path to be submitted as part of an analytics event’s snapshot object. However, Smart Client does not natively resolve or display external image paths. Smart Client only supports displaying snapshots that are submitted as image data.
Based on questions I have received, I know that some analytics integrations do submit snapshots as image data, but they are in the minority. If your goal is broad analytics integration support, implementing support for bounding box metadata and overlay rendering will likely provide greater value and compatibility than focusing on event snapshots alone.
Hi Bo,
Thank you for the clarification.
Based on your recommendation, I will retrieve the image using the camera ID and alarm timestamp instead of relying on event snapshots.
Could you please advise how the bounding box/overlay information can be applied to the retrieved image? Is there an API in the MIP SDK that can be used to render the analytics overlay, or is this expected to be implemented by the integration?
Also, is there a sample application that demonstrates retrieving a recorded image and applying the corresponding analytics bounding boxes or overlay information?
Thank you.
Please have a look at the Smart Client Overlay Graph on Event sample.
The sample demonstrates how to add overlays to video in the Smart Client, including displaying graphics in response to events.
Note that this is a Smart Client plugin sample. If you are developing a standalone application, you can still use ShapesOverlayAdd through the VideoOS.Platform.Client.ImageViewerWpfControl class to draw overlays on the video stream.
Hi Bo,
Thank you for the response.
My use case is slightly different. My application is a standalone application.
The application retrieves a snapshot image using the camera ID and alarm timestamp, and the requirement is to save that image with the corresponding analytics bounding boxes rendered onto it.
Is there any MIP SDK API or sample application that demonstrates applying the analytics bounding boxes directly to a retrieved image, rather than rendering overlays on a video stream?
Thank you.
There is a helper class, VideoOS.Platform.Util.AnalyticsOverlayBuilder, which can build the analytics overlay from the alarm data.
Combining the camera image with the overlay graphics is not functionality provided by the MIP SDK itself. However, once you have both the image and the overlay, the final composition should be possible using standard image-processing libraries available for .NET.