This tool is intended as an example for publishing decoded image frames in the (BGR HWC format) to the Nimble
source data stream.
This tool also demonstrates the feature in Nimble to ingest from a zmq source, configurable through the Nimble configuration json.
You can find it under
tools/zmq_publisher. This example also uses
tools/zmq_subscriber to listen to the Nimble output,
you can find the subscriber example here.
First you will need to make sure that you have the latest docker images:
user@host:~$ docker-compose pull
To run the example:
user@host:~$ docker-compose up
The publisher establishes a connection to the zmq publisher socket at a port (picked for this sample demo)
context = zmq.Context()
data_socket = context.socket(zmq.PUB)
The send buffer queue water marks are specifically set to sync with slow subscribers without causing queue overflows or mem leaks. The zmq publisher socket is setup to receive decoded frames in the HWC (rows x cols x channels) format, with the channels being in the BGR color order. This sample demonstrates a simple opencv videocapture from a video file source
cap = cv2.VideoCapture("videos/demo-tracking-28s.mp4")
ret, image = cap.read()
Note that a compact and fast serialization format is used to transfer image bytes over the zmq.
The Nimble zmq
source expects to receive the following multipart message:
- the image byte array in the HWC (rows x cols x channels) format, with the channels being in the BGR color order, serialized through msgpack
- the datatype of the mat/numpy representing the image, converted to str and utf-8 encoded
- the # of rows of the image mat/numpy, converted to str and utf-8 encoded
- the # of cols of the image mat/numpy, converted to str and utf-8 encoded
This sample publisher restarts on EOS and tries to publish image packets to Nimble indefinitely until termination.