Metropolis microservices Aplication services Deepstream

Metropolis Microservices provides a sample DeepStream application for real-time video processing. The application is able to take input VST streams and do people traking using NVIDIA's PeopleNet model and object traking using the NVDCF traker plugin.
On the next image we can see the component diagram:

The sample application is mainly comprised of three componets:
- VST: provides the input streams for the application, the user can add or remove any number of streams and they will get processed by the DeepStream sample application.
- SDR: this component is able to detect new streams and add then the the DeepStream application. It polls the message bus for VST events and acts accordingly.
- DeepStream Application: this is the main component since it takes the streams that SDR adds and runs the inference algorithms on it, and publishes the results. It's able to use the DLA cores that are available on the Jetson to provide live performance on the input streams.
Internally these services use REST APIs and the Redis messaging bus to communicate and notify of any events and do any configuration.
Example
After adding two streams to NVStreamer and then using the resulting RTSP URL to add them to VST, SDR detects them and if we check the deepstream container logs, we can see our newly added sources where it even shows the processing framerate for each:
Active sources : 2 Tue Jan 30 20:33:43 2024 PERF(0): 29.56 (29.88) source_id : 2 stream_name t3 29.56 (29.65) source_id : 0 stream_name t1
And if we take a look at the sdr logs, we can verify the mensagges where it added the video source to the deepstream app container:
2024-01-30 20:33:07 __main__ - INFO - swapping 2024-01-30 20:33:07 __main__ - INFO - wl_d is None. wl_d: {'camera_id': 't3', 'camera_name': 'f0601018-a304-4b16-b373-a34a75aa9898', 'camera_url': '', 'change': 'camera_add'} 2024-01-30 20:33:07 __main__ - INFO - Commiting message id 1706646787569-0 2024-01-30 20:33:18 __main__ - INFO - id: 1706646798669-0, content: {'sensor.id': '{"alert_type":"camera_status_change","created_at":"2024-01-30T20:33:18Z","event":{"camera_id":"f0601018-a304-4b16-b373-a34a75aa9898","camera_name":"t3","camera_url":"rtsp://10.251.101.105/live/f0601018-a304-4b16-b373-a34a75aa9898","change":"camera_streaming"},"source":"vst"}\n'} 2024-01-30 20:33:18 __main__ - INFO - {'sensor.id': '{"alert_type":"camera_status_change","created_at":"2024-01-30T20:33:18Z","event":{"camera_id":"f0601018-a304-4b16-b373-a34a75aa9898","camera_name":"t3","camera_url":"rtsp://10.251.101.105/live/f0601018-a304-4b16-b373-a34a75aa9898","change":"camera_streaming"},"source":"vst"}\n'} 2024-01-30 20:33:18 __main__ - INFO - {"alert_type":"camera_status_change","created_at":"2024-01-30T20:33:18Z","event":{"camera_id":"f0601018-a304-4b16-b373-a34a75aa9898","camera_name":"t3","camera_url":"rtsp://10.251.101.105/live/f0601018-a304-4b16-b373-a34a75aa9898","change":"camera_streaming"},"source":"vst"} 2024-01-30 20:33:18 __main__ - INFO - swapping 2024-01-30 20:33:18 __main__ - INFO - provision stream 2024-01-30 20:33:18 __main__ - INFO - Provision Stream Redis 2024-01-30 20:33:18 __main__ - INFO - starting remove_streams_with_same_id 2024-01-30 20:33:18 __main__ - INFO - originalJson[event][camera_id]: t3 2024-01-30 20:33:18 __main__ - INFO - workload_spec: None 2024-01-30 20:33:18 lib.podprovisioner.kubernetes.cluster - INFO - ->>> localhost 9010 Running localhost localhost docker moj-ds-01 2024-01-30 20:33:18 lib.podprovisioner.kubernetes.cluster - INFO - ->>> localhost 9011 Running localhost localhost docker moj-ds-02 2024-01-30 20:33:18 lib.podprovisioner.kubernetes.cluster - INFO - len(podsips): 2, values: [{'podName': 'moj-ds-01', 'podIp': 'localhost', 'namespace': 'docker', 'owner': DotMap(), 'phase': 'Running', 'podPort': '9010', 'poddns': 'localhost.localhost.default'}, {'podName': 'moj-ds-02', 'podIp': 'localhost', 'namespace': 'docker', 'owner': DotMap(), 'phase': 'Running', 'podPort': '9011', 'poddns': 'localhost.localhost.default'}] 2024-01-30 20:33:18 lib.parameters.configserver - INFO - moj-ds-01 found id: t3 2024-01-30 20:33:18 __main__ - INFO - moj-ds-01 pod is already deployed 2024-01-30 20:33:18 __main__ - INFO - stream_updates - sdr-deepstream adding_stream: t3 2024-01-30 20:33:18 lib.podprovisioner.provisionconfig - INFO - Starting add call 2024-01-30 20:33:18 lib.podprovisioner.provisionconfig - INFO - adding camera at http://localhost:9010/api/v1/stream/add 2024-01-30 20:33:18 lib.podprovisioner.provisionconfig - INFO - payload: { "alert_type": "camera_status_change", "created_at": "2024-01-30T20:33:18Z", "event": { "camera_id": "t3", "camera_name": "f0601018-a304-4b16-b373-a34a75aa9898", "camera_url": "rtsp://10.251.101.105/live/f0601018-a304-4b16-b373-a34a75aa9898", "change": "camera_streaming" }, "source": "vst" } 2024-01-30 20:33:18 lib.podprovisioner.provisionconfig - INFO - add operation Response Code: 200 2024-01-30 20:33:18 lib.podprovisioner.provisionconfig - INFO - add operation text return: { "reason" : "STREAM_ADD_SUCCESS", "status" : "HTTP/1.1 200 OK" } 2024-01-30 20:33:18 __main__ - INFO - add operation success updating the Route mapping moj-ds-01: |- [ { "source": "preload", "event": { "camera_id": "t1", "camera_name": "78f67410-55ab-40ec-9c75-e46cd2d54d15", "camera_url": "rtsp://10.251.101.105/live/78f67410-55ab-40ec-9c75-e46cd2d54d15", "change": "camera_streaming", "metadata": { "bitrate": "", "codec": "H264", "framerate": "", "govlength": "", "resolution": "" } } }, { "source": "preload", "event": { "camera_id": "t2", "camera_name": "fd553c7b-05c0-489f-b30c-e32336676ea8", "camera_url": "rtsp://10.251.101.105/live/fd553c7b-05c0-489f-b30c-e32336676ea8", "change": "camera_streaming", "metadata": { "bitrate": "", "codec": "H264", "framerate": "30.000000", "govlength": "", "resolution": "" } } }, { "alert_type": "camera_status_change", "created_at": "2024-01-30T20:33:18Z", "event": { "camera_id": "t3", "camera_name": "f0601018-a304-4b16-b373-a34a75aa9898", "camera_url": "rtsp://10.251.101.105/live/f0601018-a304-4b16-b373-a34a75aa9898", "change": "camera_streaming" }, "source": "vst" } ] 2024-01-30 20:33:18 __main__ - INFO - prod provisioned no new replica added 2024-01-30 20:33:18 __main__ - INFO - Commiting message id 1706646798669-0
We can then add more streams to VST and the SDR service will be able to detect them and add them to the DeepStream application.