[EDGEPOD-163] Add infosys deepstream app
Change-Id: Ie21df0cfe9ca40885bf884d3a2a12a4a279d619c
diff --git a/aether-apps/infosys-deepstream/Chart.yaml b/aether-apps/infosys-deepstream/Chart.yaml
new file mode 100644
index 0000000..3e7b7c6
--- /dev/null
+++ b/aether-apps/infosys-deepstream/Chart.yaml
@@ -0,0 +1,20 @@
+# Copyright 2020-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+apiVersion: v1
+description: Infosys deepstream application for Aether
+name: infosys-deepstream
+
+version: 0.1.0
diff --git a/aether-apps/infosys-deepstream/files/infer_config.txt b/aether-apps/infosys-deepstream/files/infer_config.txt
new file mode 100755
index 0000000..d3b9602
--- /dev/null
+++ b/aether-apps/infosys-deepstream/files/infer_config.txt
@@ -0,0 +1,61 @@
+[property]
+gpu-id=0
+net-scale-factor=0.0039215697906911373
+model-engine-file=/models/Primary_Detector/resnet10.caffemodel_b1_fp16.engine
+labelfile-path=/models/Primary_Detector/labels.txt
+
+batch-size=1
+process-mode=1
+model-color-format=0
+network-mode=2
+num-detected-classes=4
+interval=2
+gie-unique-id=1
+
+[class-attrs-all]
+threshold=0.2
+group-threshold=1
+eps=0.2
+roi-top-offset=0
+roi-bottom-offset=0
+detected-min-w=0
+detected-min-h=0
+detected-max-w=0
+detected-max-h=0
+
+# Per class configuration
+#Car
+[class-attrs-0]
+threshold=1.0
+group-threshold=1
+eps=0.2
+roi-top-offset=0
+roi-bottom-offset=0
+detected-min-w=0
+detected-min-h=0
+detected-max-w=0
+detected-max-h=0
+
+#Bicycle
+[class-attrs-1]
+threshold=1.0
+group-threshold=1
+eps=0.2
+roi-top-offset=0
+roi-bottom-offset=0
+detected-min-w=0
+detected-min-h=0
+detected-max-w=0
+detected-max-h=0
+
+# Roadsign
+[class-attrs-3]
+threshold=1.0
+group-threshold=1
+eps=0.2
+roi-top-offset=0
+roi-bottom-offset=0
+detected-min-w=0
+detected-min-h=0
+detected-max-w=0
+detected-max-h=0
diff --git a/aether-apps/infosys-deepstream/files/msg_config.txt b/aether-apps/infosys-deepstream/files/msg_config.txt
new file mode 100755
index 0000000..8c9bcb6
--- /dev/null
+++ b/aether-apps/infosys-deepstream/files/msg_config.txt
@@ -0,0 +1,63 @@
+## Group 0
+
+[sensor0]
+enable=1
+type=Camera
+id=CSI
+location=45.293701447;-75.8303914499;48.1557479338
+description=CSI Camera
+coordinate=5.2;10.1;11.2
+
+[place0]
+enable=1
+id=0
+type=intersection/road
+name=HWY_20_AND_LOCUST__EBA
+location=30.32;-40.55;100.0
+coordinate=1.0;2.0;3.0
+place-sub-field1=C_127_158
+place-sub-field2=Lane 1
+place-sub-field3=P1
+
+## Group 1
+
+[sensor1]
+enable=1
+type=Camera
+id=RTSP_1
+location=45.293701447;-75.8303914499;48.1557479338
+description=RTSP feed from Mobile Camera
+coordinate=5.2;10.1;11.2
+
+[place1]
+enable=1
+id=0
+type=intersection/road
+name=INT2_HWY_20_AND_LOCUST__EBA
+location=30.32;-40.55;100.0
+coordinate=1.0;2.0;3.0
+place-sub-field1=C_127_158
+place-sub-field2=Lane 1
+place-sub-field3=P1
+
+## Group 2
+
+[sensor2]
+enable=1
+type=Camera
+id=1
+location=45.293701447;-75.8303914499;48.1557479338
+description=Mobile Camera
+coordinate=5.2;10.1;11.2
+
+[place2]
+enable=1
+id=0
+type=intersection/road
+name=INT2_HWY_20_AND_LOCUST__EBA
+location=30.32;-40.55;100.0
+coordinate=1.0;2.0;3.0
+place-sub-field1=C_127_158
+place-sub-field2=Lane 1
+place-sub-field3=P1
+
diff --git a/aether-apps/infosys-deepstream/files/tracker_config.yml b/aether-apps/infosys-deepstream/files/tracker_config.yml
new file mode 100755
index 0000000..5d2b678
--- /dev/null
+++ b/aether-apps/infosys-deepstream/files/tracker_config.yml
@@ -0,0 +1,19 @@
+%YAML:1.0
+
+NvDCF:
+ maxTargetsPerStream: 50 # Max number of targets to track per stream. Recommended to set >10. Note: this value should account for the targets being tracked in shadow mode as well. Max value depends on the GPU memory capacity
+
+ filterLr: 0.11 # learning rate for DCF filter in exponential moving average. Valid Range: [0.0, 1.0]
+ gaussianSigma: 0.75 # Standard deviation for Gaussian for desired response when creating DCF filter
+
+ minDetectorConfidence: 0.0 # If the confidence of a detector bbox is lower than this, then it won't be considered for tracking
+ minTrackerConfidence: 0.6 # If the confidence of an object tracker is lower than this on the fly, then it will be tracked in shadow mode. Valid Range: [0.0, 1.0]
+
+ featureImgSizeLevel: 1 # Size of a feature image. Valid range: {1, 2, 3, 4, 5}, from the smallest to the largest
+ SearchRegionPaddingScale: 3 # Search region size. Determines how large the search region should be scaled from the target bbox. Valid range: {1, 2, 3}, from the smallest to the largest
+
+ maxShadowTrackingAge: 9 # Max length of shadow tracking (the shadow tracking age is incremented when (1) there's detector input yet no match or (2) tracker confidence is lower than minTrackerConfidence). Once reached, the tracker will be terminated.
+ probationAge: 0 # Once the tracker age (incremented at every frame) reaches this, the tracker is considered to be valid
+ earlyTerminationAge: 0 # Early termination age (in terms of shadow tracking age) during the probation period
+
+ minVisibiilty4Tracking: 0.5 # If the visibility of the bbox of a tracker gets lower, then it will be terminated
diff --git a/aether-apps/infosys-deepstream/templates/_helpers.tpl b/aether-apps/infosys-deepstream/templates/_helpers.tpl
new file mode 100644
index 0000000..8120674
--- /dev/null
+++ b/aether-apps/infosys-deepstream/templates/_helpers.tpl
@@ -0,0 +1,36 @@
+{{- /*
+# Copyright 2020-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/ -}}
+
+{{/*
+Renders a set of standardised labels
+*/}}
+{{- define "deepstream.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "deepstream.template" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $last := base $context.Template.Name }}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{ include $wtf $context }}
+{{- end -}}
diff --git a/aether-apps/infosys-deepstream/templates/config/_amqp_config.txt.tpl b/aether-apps/infosys-deepstream/templates/config/_amqp_config.txt.tpl
new file mode 100755
index 0000000..15c96bc
--- /dev/null
+++ b/aether-apps/infosys-deepstream/templates/config/_amqp_config.txt.tpl
@@ -0,0 +1,28 @@
+################################################################################
+# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+################################################################################
+[message-broker]
+password = {{ .Values.config.deepstream.amqp.password }}
+hostname = {{ .Values.config.deepstream.amqp.host }}
+username = {{ .Values.config.deepstream.amqp.username }}
+port = {{ .Values.config.deepstream.amqp.port }}
+exchange = amq.topic
+topic = jetson
diff --git a/aether-apps/infosys-deepstream/templates/config/_main_config.txt.tpl b/aether-apps/infosys-deepstream/templates/config/_main_config.txt.tpl
new file mode 100755
index 0000000..535897d
--- /dev/null
+++ b/aether-apps/infosys-deepstream/templates/config/_main_config.txt.tpl
@@ -0,0 +1,94 @@
+[application]
+enable-perf-measurement=1
+perf-measurement-interval-sec=5
+
+[tiled-display]
+enable={{ .Values.config.deepstream.display.enabled }}
+rows=1
+columns=1
+width=900
+height=500
+gpu-id=0
+nvbuf-memory-type=4
+
+[source0]
+enable=1
+#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP, 5=CSI
+type=2
+uri={{ .Values.config.deepstream.source }}
+num-sources=1
+#drop-frame-interval=5
+gpu-id=0
+cudadec-memtype=0
+
+[source1]
+enable=0
+#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP, 5=CSI
+type=2
+uri=file:/root/deepstream_sdk_v4.0.2_jetson/samples/streams/sample_1080p_h265.mp4
+num-sources=1
+gpu-id=0
+cudadec-memtype=0
+
+[sink0]
+enable=1
+#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
+type=5
+sync=0
+display-id=0
+offset-x=100
+offset-y=0
+width=900
+height=500
+overlay-id=1
+source-id=0
+
+[sink1]
+enable=1
+#Type - 1=FakeSink 2=EglSink 3=File 4=UDPSink 5=nvoverlaysink 6=MsgConvBroker
+type=6
+msg-conv-config=/configs/msg_config.txt
+msg-conv-payload-type=1
+msg-broker-proto-lib=/opt/nvidia/deepstream/deepstream-4.0/lib/libnvds_amqp_proto.so
+msg-broker-config=/configs/amqp_config.txt
+
+[osd]
+enable=1
+border-width=1
+text-size=0
+text-color=1;1;1;1;
+text-bg-color=0.3;0.3;0.3;0
+font=Serif
+show-clock=1
+clock-x-offset=10
+clock-y-offset=10
+clock-text-size=12
+clock-color=0;0;0;.8
+
+[streammux]
+live-source=1
+batch-size=1
+batched-push-timeout=40000
+width=1280
+height=720
+
+[primary-gie]
+enable=1
+batch-size=1
+bbox-border-color0=1;0;0;1
+bbox-border-color1=0;1;1;1
+bbox-border-color2=0;0;1;1
+bbox-border-color3=0;1;0;1
+interval=0
+gie-unique-id=1
+config-file=/configs/infer_config.txt
+
+[tracker]
+enable=1
+tracker-width=480
+tracker-height=272
+ll-lib-file=/opt/nvidia/deepstream/deepstream-4.0/lib/libnvds_nvdcf.so
+ll-config-file=/configs/tracker_config.yml
+gpu-id=0
+enable-batch-process=1
+
diff --git a/aether-apps/infosys-deepstream/templates/configmap-deepstream.yaml b/aether-apps/infosys-deepstream/templates/configmap-deepstream.yaml
new file mode 100644
index 0000000..5dad6ab
--- /dev/null
+++ b/aether-apps/infosys-deepstream/templates/configmap-deepstream.yaml
@@ -0,0 +1,33 @@
+{{- /*
+# Copyright 2020-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/ -}}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: deepstream
+ labels:
+{{ tuple "deepstream" . | include "deepstream.metadata_labels" | indent 4 }}
+data:
+ main_config.txt: |
+{{ tuple "config/_main_config.txt.tpl" . | include "deepstream.template" | indent 4 }}
+ amqp_config.txt: |
+{{ tuple "config/_amqp_config.txt.tpl" . | include "deepstream.template" | indent 4 }}
+ infer_config.txt: |
+{{ .Files.Get "files/infer_config.txt" | indent 4 }}
+ msg_config.txt: |
+{{ .Files.Get "files/msg_config.txt" | indent 4 }}
+ tracker_config.yml: |
+{{ .Files.Get "files/tracker_config.yml" | indent 4 }}
diff --git a/aether-apps/infosys-deepstream/templates/deployment-deepstream.yaml b/aether-apps/infosys-deepstream/templates/deployment-deepstream.yaml
new file mode 100644
index 0000000..6684fdc
--- /dev/null
+++ b/aether-apps/infosys-deepstream/templates/deployment-deepstream.yaml
@@ -0,0 +1,66 @@
+{{- /*
+# Copyright 2020-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/ -}}
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: deepstream
+ labels:
+{{ tuple "deepstream" . | include "deepstream.metadata_labels" | indent 4 }}
+spec:
+ selector:
+ matchLabels:
+{{ tuple "deepstream" . | include "deepstream.metadata_labels" | indent 6 }}
+ template:
+ metadata:
+ labels:
+{{ tuple "deepstream" . | include "deepstream.metadata_labels" | indent 8 }}
+ spec:
+ {{- if .Values.nodeSelectors.enabled }}
+ nodeSelector:
+ {{ .Values.nodeSelectors.deepstream.label }}: {{ .Values.nodeSelectors.deepstream.value }}
+ {{- end }}
+ hostNetwork: true
+ containers:
+ - name: deepstream
+ image: {{ .Values.images.tags.deepstreamTx2 }}
+ imagePullPolicy: {{ .Values.images.pullPolicy }}
+ {{- if .Values.resources.enabled }}
+ resources:
+{{ toYaml .Values.resources.deepstream | indent 10 }}
+ {{- end }}
+ env:
+ - name: DISPLAY
+ value: {{ .Values.config.deepstream.display.display }}
+ volumeMounts:
+ - name: configs
+ mountPath: /configs
+ readOnly: true
+ - name: x11-unix
+ mountPath: /tmp/.X11-unix
+ - name: argus-socket
+ mountPath: /tmp/argus_socket
+ volumes:
+ - name: configs
+ configMap:
+ defaultMode: 0644
+ name: deepstream
+ - name: x11-unix
+ hostPath:
+ path: /tmp/.X11-unix
+ - name: argus-socket
+ hostPath:
+ path: /tmp/argus_socket
diff --git a/aether-apps/infosys-deepstream/values.yaml b/aether-apps/infosys-deepstream/values.yaml
new file mode 100644
index 0000000..76f6d9c
--- /dev/null
+++ b/aether-apps/infosys-deepstream/values.yaml
@@ -0,0 +1,47 @@
+# Copyright 2020-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+images:
+ tags:
+ deepstreamTx2: registry.central.aetherproject.net/infosys/deepstream-tx2:0.1
+ pullPolicy: "IfNotPresent"
+
+nodeSelectors:
+ enabled: true
+ deepstream:
+ label: deepstream
+ value: enabled
+
+resources:
+ enabled: false
+ deepstream:
+ requests:
+ cpu: 2
+ memory: 2048Mi
+ limits:
+ cpu: 2
+ memory: 2048Mi
+
+config:
+ deepstream:
+ source: rtsp://10.251.255.241:5554/test
+ # set display to 1 to enalbe and 0 to disable
+ display:
+ display: ":1"
+ enabled: 1
+ amqp:
+ host: 172.16.0.10
+ port: 5672
+ username: admin
+ password: A3ther