Introduction
The Maivin Web Application uses the NNG library to provide a Message Queue API. This article covers the API and an example script to subscribe to the results queue. The library is available with support for many languages, this article demonstrates the Python support initially.
Publisher
The maivin/webapp-detection container runs a Vision Pack pipeline using GStreamer and the VAAL plugins. The model results, bounding box annotations, are captured and converted into JSON then published using NNG. By default results are published using the IPC Transport to the ipc:///tmp/results.pub URL.
Protocol
The detection service broadcasts results using the Publisher Protocol and clients should connect to the same socket using the Subscriber Protocol to receive the results.
NOTE: we do not make use of filtering but NNG expects it by default, you will need to explicitly set the filter to be empty to receive results.
JSON Format
The following is an example of the JSON output. The important field is objects which stores an array of detected objects using the format {x,y,width,height,score,label}.
{'vaal_version': '1.1.2-eval', 'timestamp': 10895960857118, 'model_status': 'valid', 'pre': 957856, 'inference': 8704459, 'post': 2767322, 'fps': 44, 'objects': [{'x': 0.325, 'y': 0.104167, 'width': 0.1, 'height': 0.0666667, 'score': 0.785807, 'label': 'six'}]}
Examples
Docker containers are provided for various language bindings along with examples to help with development.
C
We provide support for the nng library with the maivin/nng container.
The attached results.c example is packaged using Dockerfile.nng and is built and launched using the following.
docker build . -f Dockerfile.nng -t results
docker run -it --rm -v /tmp:/tmp results
Python
We provide support for the pynng library with the maivin/pynng container. The message queue receives events using the Sub0 class.
The attached results.py example script can be launched using this container as follows.
docker run -it --rm -v /tmp:/tmp -v $PWD:/work maivin/pynng results.py
Go
We provide support for the mangos library with the Dockerfile.mangos along with the results.go example. It is built and launched as follows.
docker build . -f Dockerfile.mangos -t results
docker run -it --rm -v /tmp:/tmp results
Comments
0 comments
Please sign in to leave a comment.