Browse Source

Initial commit

root 3 years ago
commit
4247e6390f

+ 7 - 0
LICENSE.md

@@ -0,0 +1,7 @@
+Copyright (c) 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.

+ 76 - 0
Makefile

@@ -0,0 +1,76 @@
+################################################################################
+# Copyright (c) 2019-2020, 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.
+################################################################################
+
+APP:= deepstream-test5-analytics
+
+TARGET_DEVICE = $(shell gcc -dumpmachine | cut -f1 -d -)
+
+NVDS_VERSION:=5.0
+
+LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/
+APP_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/bin/
+
+ifeq ($(TARGET_DEVICE),aarch64)
+  CFLAGS:= -DPLATFORM_TEGRA
+endif
+
+SRCS:= deepstream_test5_app_main.c 
+SRCS+= ../deepstream-test5/deepstream_utc.c
+SRCS+= ../deepstream-app/deepstream_app.c ../deepstream-app/deepstream_app_config_parser.c
+SRCS+= $(wildcard ../../apps-common/src/*.c)
+
+INCS= $(wildcard *.h)
+INC_DIR=../deepstream-test5
+
+PKGS:= gstreamer-1.0 gstreamer-video-1.0 x11 json-glib-1.0
+
+OBJS:= $(SRCS:.c=.o)
+OBJS+= deepstream_nvdsanalytics_meta.o
+
+CFLAGS+= -I../../apps-common/includes -I./includes -I../../../includes -I../deepstream-app/ -DDS_VERSION_MINOR=0 -DDS_VERSION_MAJOR=5
+CFLAGS+= -I$(INC_DIR)
+
+
+LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_meta -lnvds_meta -lnvdsgst_helper -lnvdsgst_smartrecord -lnvds_utils -lnvds_msgbroker -lm \
+       -lgstrtspserver-1.0 -ldl -Wl,-rpath,$(LIB_INSTALL_DIR)
+
+CFLAGS+= `pkg-config --cflags $(PKGS)`
+
+LIBS+= `pkg-config --libs $(PKGS)`
+
+all: $(APP)
+
+deepstream_nvdsanalytics_meta.o: deepstream_nvdsanalytics_meta.cpp $(INCS) Makefile
+	$(CXX) -c -o $@ -Wall -Werror $(CFLAGS) $<
+
+%.o: %.c $(INCS) Makefile
+	$(CC) -c -o $@  $(CFLAGS) $<
+
+$(APP): $(OBJS) Makefile
+	$(CXX) -o $(APP) $(OBJS) $(LIBS)
+
+install: $(APP)
+	cp -rv $(APP) $(APP_INSTALL_DIR)
+
+clean:
+	rm -rf $(OBJS) $(APP)
+

+ 75 - 0
README.md

@@ -0,0 +1,75 @@
+**People count application With Deepstream SDK and Transfer Learning Toolkit**
+
+* [Description](#description)
+* [Prerequisites](#prerequisites)
+* [Getting Started](#Getting Started)
+* [Build](#build)
+* [Run](#run)
+* [Output](#output)
+* [References](#references)
+<p align="center">
+  <img src="images/test.png">
+</p>
+
+## Description 
+
+This is a demo project for "People Count Application" using NVIDIA Deepstream SDK and Transfer Learning Toolkit (TLT).The application is based on deepstream-test5 application. It takes the input source data, uses PeopleNet model for inferencing and sends the people count data to cloud. 
+
+## Prerequisites
+
+
+- Install Deepstream: [https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html#page/DeepStream_Development_Guide/deepstream_quick_start.html#]
+
+- Download PeopleNet model: [https://ngc.nvidia.com/catalog/models/nvidia:tlt_peoplenet]
+
+- This application is based on deepstream-test5 application. More about test5 application: [https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html#page/DeepStream_Development_Guide/deepstream_reference_app_test5.html]
+
+- Install Kafka: [https://kafka.apache.org/quickstart] and create the kafka topic:
+
+  `tar -xzf kafka_2.13-2.6.0.tgz`
+
+  `cd kafka_2.13-2.6.0` 
+
+  `bin/zookeeper-server-start.sh config/zookeeper.properties`
+
+  `bin/kafka-server-start.sh config/server.properties`
+
+  `bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092`
+
+## Getting Started
+
+- Preferably clone the repo in $DS_SDK_ROOT/sources/apps/sample_apps/ 
+- Download peoplnet model: `cd demo/config && ./model.sh`
+- For Jetson use:  bin/jetson/libnvds_msgconv.so
+- For x86 use: bin/x86/libnvds_msgconv.so
+	 
+
+## Build
+
+ `cd demo && make`
+
+## Run 
+
+ `./deepstream_test5 -c configs/test5_config_file_src_infer_tlt.txt`
+
+  In another terminal run this command to see the kafka messages:
+
+ `bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092`
+
+
+## Output
+
+  The output will look like this: 
+
+  ![alt-text](https://gitlab-master.nvidia.com/mjhuria/demo/-/raw/master/images/kafka_messages.gif)
+
+  Where you can see the kafka messages for entry and exit count.
+  
+
+## References
+
+- CREATE INTELLIGENT PLACES USING NVIDIA PRE-TRAINED VISION MODELS AND DEEPSTREAM SDK: [https://info.nvidia.com/iva-occupancy-webinar-reg-page.html?ondemandrgt=yes]
+- Deepstream SDK: [https://developer.nvidia.com/deepstream-sdk]
+- Deepstream Quick Start Guide: [https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html#page/DeepStream_Development_Guide/deepstream_quick_start.html#]
+- Transfer Learning Toolkit: [https://developer.nvidia.com/transfer-learning-toolkit]
+

BIN
bin/jetson/libnvds_msgconv.so


BIN
bin/x86/libnvds_msgconv.so


+ 58 - 0
config/config_infer_primary_peoplenet.txt

@@ -0,0 +1,58 @@
+################################################################################
+# Copyright (c) 2020, 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.
+################################################################################
+[property]
+gpu-id=0
+net-scale-factor=0.0039215697906911373
+tlt-model-key=tlt_encode
+tlt-encoded-model=peoplenet/resnet34_peoplenet_pruned.etlt
+labelfile-path=peoplenet/labels.txt
+model-engine-file=../resnet34_peoplenet_pruned.etlt_b1_gpu0_int8.engine
+int8-calib-file=resnet34_peoplenet_int8_update.txt
+input-dims=3;544;960;0
+uff-input-blob-name=input_1
+batch-size=1
+process-mode=1
+model-color-format=0
+## 0=FP32, 1=INT8, 2=FP16 mode
+network-mode=1
+num-detected-classes=3
+cluster-mode=1
+interval=0
+gie-unique-id=1
+output-blob-names=output_bbox/BiasAdd;output_cov/Sigmoid
+
+[class-attrs-all]
+pre-cluster-threshold=0.4
+## Set eps=0.7 and minBoxes for cluster-mode=1(DBSCAN)
+eps=0.7
+minBoxes=1
+
+[class-attrs-1]
+pre-cluster-threshold=1.4
+## Set eps=0.7 and minBoxes for cluster-mode=1(DBSCAN)
+eps=0.7
+minBoxes=1
+[class-attrs-2]
+pre-cluster-threshold=1.4
+## Set eps=0.7 and minBoxes for cluster-mode=1(DBSCAN)
+eps=0.7
+minBoxes=1

+ 103 - 0
config/config_nvdsanalytics.txt

@@ -0,0 +1,103 @@
+################################################################################
+# Copyright (c) 2020, 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.
+################################################################################
+
+# The values in the config file are overridden by values set through GObject
+# properties.
+
+[property]
+enable=1
+#Width height used for configuration to which below configs are configured
+config-width=1920
+config-height=1080
+#osd-mode 0: Dont display any lines, rois and text
+#         1: Display only lines, rois and static text i.e. labels
+#         2: Display all info from 1 plus information about counts
+osd-mode=2
+#Set OSD font size that has to be displayed
+display-font-size=12
+
+## Per stream configuration
+[roi-filtering-stream-0]
+#enable or disable following feature
+enable=0
+#ROI to filter select objects, and remove from meta data
+roi-RF=295;643;579;634;642;913;56;828
+#remove objects in the ROI
+inverse-roi=0
+class-id=-1
+
+## Per stream configuration
+[roi-filtering-stream-1]
+#enable or disable following feature
+enable=0
+#ROI to filter select objects, and remove from meta data
+roi-RF=295;643;579;634;642;913;56;828
+#remove objects in the ROI
+inverse-roi=0
+class-id=0
+
+
+[overcrowding-stream-1]
+enable=0
+roi-OC=0;0;579;400;642;900;0;900
+#no of objects that will trigger OC
+object-threshold=3
+class-id=-1
+
+[line-crossing-stream-0]
+enable=1
+#Label;direction;lc
+line-crossing-Exit=900;1000;850;900;300;1000;1350;800;
+line-crossing-Entry=750;670;800;750;300;850;1350;650
+#line_color=0.75;0.25;0;1
+class-id=0
+#extended when 0- only counts crossing on the configured Line
+#              1- assumes extended Line crossing counts all the crossing
+extended=0
+#LC modes supported:
+#loose   : counts all crossing without strong adherence to direction
+#balanced: Strict direction adherence expected compared to mode=loose
+#strict  : Strict direction adherence expected compared to mode=balanced
+mode=balanced
+
+[line-crossing-stream-1]
+enable=1
+#Label;direction;lc
+line-crossing-Exit=900;1000;850;900;300;1000;1350;800;
+line-crossing-Entry=750;670;800;750;300;850;1350;650
+class-id=0
+#extended when 0- only counts crossing on the configured Line
+#              1- assumes extended Line crossing counts all the crossing
+extended=1
+#LC modes supported:
+#loose   : counts all crossing without strong adherence to direction
+#balanced: Strict direction adherence expected compared to mode=loose
+#strict  : Strict direction adherence expected compared to mode=balanced
+mode=balanced
+
+[direction-detection-stream-0]
+enable=0
+#Label;direction;
+direction-South=284;840;360;662;
+direction-North=1106;622;1312;701;
+class-id=0
+

File diff suppressed because it is too large
+ 1947 - 0
config/dstest5_msgconv_sample_config.txt


+ 8 - 0
config/model.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+mkdir peoplenet && cd peoplenet
+echo "Downloading pruned tlt peoplenet model.... "
+wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/tlt_peoplenet/versions/pruned_v2.0/zip -O peoplenet.zip 
+unzip peoplenet.zip
+rm -r peoplenet.zip
+

+ 218 - 0
config/test5_config_file_src_infer_tlt.txt

@@ -0,0 +1,218 @@
+################################################################################
+# Copyright (c) 2018-2020, 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.
+################################################################################
+
+[application]
+enable-perf-measurement=1
+perf-measurement-interval-sec=5
+#gie-kitti-output-dir=streamscl
+
+[tiled-display]
+enable=1
+rows=1
+columns=1
+width=1280
+height=720
+gpu-id=0
+#(0): nvbuf-mem-default - Default memory allocated, specific to particular platform
+#(1): nvbuf-mem-cuda-pinned - Allocate Pinned/Host cuda memory, applicable for Tesla
+#(2): nvbuf-mem-cuda-device - Allocate Device cuda memory, applicable for Tesla
+#(3): nvbuf-mem-cuda-unified - Allocate Unified cuda memory, applicable for Tesla
+#(4): nvbuf-mem-surface-array - Allocate Surface Array memory, applicable for Jetson
+nvbuf-memory-type=0
+
+
+[source0]
+enable=1
+#Type - 1=CameraV4L2 2=URI 3=MultiURI
+type=3
+uri=file:///opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/demo/out.mp4
+num-sources=1
+gpu-id=0
+nvbuf-memory-type=0
+
+[source1]
+enable=1
+#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP
+type=3
+uri=file:///opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_1080p_h264.mp4
+num-sources=1
+gpu-id=0
+nvbuf-memory-type=0
+# smart record specific fields, valid only for source type=4
+# 0 = disable, 1 = through cloud events, 2 = through cloud + local events
+smart-record=2
+# 0 = mp4, 1 = mkv
+#smart-rec-container=0
+smart-rec-start-time=1
+smart-rec-start-time=1
+smart-rec-file-prefix=smart_record
+#smart-rec-dir-path=/home/monika/record
+# video cache size in seconds
+smart-rec-video-cache=10
+
+
+
+[sink0]
+enable=1
+type=2
+#1=mp4 2=mkv./bin/kafka-topics --create --bootstrap-server localhost:9092 \
+#--replication-factor 1 --partitions 1 --topic users
+container=1
+#1=h264 2=h265
+codec=1
+#encoder type 0=Hardware 1=Software
+enc-type=0
+sync=0
+#iframeinterval=10
+bitrate=100000
+#H264 Profile - 0=Baseline 2=Main 4=High
+#H265 Profile - 0=Main 1=Main10
+profile=0
+output-file=resnet.mp4
+source-id=0
+
+[sink1]
+enable=1
+#Type - 1=FakeSink 2=EglSink 3=File 4=UDPSink 5=nvoverlaysink 6=MsgConvBroker
+type=6
+msg-conv-config=dstest5_msgconv_sample_config.txt
+#(0): PAYLOAD_DEEPSTREAM - Deepstream schema payload
+#(1): PAYLOAD_DEEPSTREAM_MINIMAL - Deepstream schema payload minimal
+#(256): PAYLOAD_RESERVED - Reserved type
+#(257): PAYLOAD_CUSTOM   - Custom schema payload
+msg-conv-payload-type=0
+msg-broker-proto-lib=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_kafka_proto.so
+#Provide your msg-broker-conn-str here
+msg-broker-conn-str=localhost;9092;quickstart-events
+#topic=<topic>
+#Optional:
+#msg-broker-config=../../deepstream-test4/cfg_kafka.txt
+
+[sink2]
+enable=1
+type=1
+#1=mp4 2=mkv
+container=1
+#1=h264 2=h265 3=mpeg4
+## only SW mpeg4 is supported right now.
+codec=3
+sync=1
+bitrate=2000000
+output-file=out.mp4
+source-id=0
+
+# sink type = 6 by default creates msg converter + broker.
+# To use multiple brokers use this group for converter and use
+# sink type = 6 with disable-msgconv = 1
+[message-converter]
+enable=0
+msg-conv-config=dstest5_msgconv_sample_config.txt
+#(0): PAYLOAD_DEEPSTREAM - Deepstream schema payload
+#(1): PAYLOAD_DEEPSTREAM_MINIMAL - Deepstream schema payload minimal
+#(256): PAYLOAD_RESERVED - Reserved type
+#(257): PAYLOAD_CUSTOM   - Custom schema payload
+msg-conv-payload-type=0
+# Name of library having custom implementation.
+#msg-conv-msg2p-lib=<val>
+# Id of component in case only selected message to parse.
+#msg-conv-comp-id=<val>
+
+# Configure this group to enable cloud message consumer.
+[message-consumer0]
+enable=0
+proto-lib=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_kafka_proto.so
+conn-str=localhost;9092
+#config-file=<broker config file e.g. cfg_kafka.txt>
+subscribe-topic-list=quickstart-events
+# Use this option if message has sensor name as id instead of index (0,1,2 etc.).
+sensor-list-file=dstest5_msgconv_sample_config.txt
+
+[osd]
+enable=1
+gpu-id=0
+border-width=1
+text-size=10
+text-color=1;1;1;1;
+text-bg-color=0.3;0.3;0.3;1
+font=Arial
+show-clock=0
+clock-x-offset=800
+clock-y-offset=820
+clock-text-size=12
+clock-color=1;0;0;0
+nvbuf-memory-type=0
+
+[streammux]
+gpu-id=0
+##Boolean property to inform muxer that sources are live
+live-source=0
+batch-size=1
+##time out in usec, to wait after the first buffer is available
+##to push the batch even if the complete batch is not formed
+batched-push-timeout=40000
+## Set muxer output width and height
+width=1920
+height=1080
+##Enable to maintain aspect ratio wrt source, and allow black borders, works
+##along with width, height properties
+enable-padding=0
+nvbuf-memory-type=0
+## If set to TRUE, system timestamp will be attached as ntp timestamp
+## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
+# attach-sys-ts-as-ntp=1
+
+[primary-gie]
+enable=1
+gpu-id=0
+batch-size=1
+## 0=FP32, 1=INT8, 2=FP16 mode
+bbox-border-color0=1;0;0;1
+#bbox-border-color1=0;1;1;1
+#bbox-border-color2=0;1;1;1
+#bbox-border-color3=0;1;0;1
+nvbuf-memory-type=0
+interval=0
+gie-unique-id=1
+model-engine-file=peoplenet/resnet34_peoplenet_pruned.etlt_b1_gpu0_int8.engine
+labelfile-path=peoplenet/labels.txt
+config-file=config_infer_primary_peoplenet.txt
+#infer-raw-output-dir=../../../../../samples/primary_detector_raw_output/
+
+[tracker]
+enable=1
+tracker-width=640
+tracker-height=288
+ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_nvdcf.so
+#ll-config-file required for DCF/IOU only
+ll-config-file=tracker_config.yml
+#ll-config-file=iou_config.txt
+gpu-id=0
+#enable-batch-process applicable to DCF only
+enable-batch-process=0
+
+
+[nvds-analytics]
+enable=1
+config-file=config_nvdsanalytics.txt
+
+[tests]
+file-loop=0

+ 55 - 0
deepstream_nvdsanalytics_meta.cpp

@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2020, 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.
+ */
+
+#include <gst/gst.h>
+#include <glib.h>
+#include <iostream>
+#include <vector>
+#include <unordered_map>
+#include <sstream>
+#include "gstnvdsmeta.h"
+#include "nvds_analytics_meta.h"
+#include "analytics.h"
+
+/* custom_parse_nvdsanalytics_meta_data 
+ * and extract nvanalytics metadata */
+	extern "C" void
+analytics_custom_parse_nvdsanalytics_meta_data (NvDsMetaList *l_user, AnalyticsUserMeta *data)
+{
+	std::stringstream out_string;
+	NvDsUserMeta *user_meta = (NvDsUserMeta *) l_user->data;
+	/* convert to  metadata */
+	NvDsAnalyticsFrameMeta *meta =
+		(NvDsAnalyticsFrameMeta *) user_meta->user_meta_data;
+	/* Fill the data for entry, exit,occupancy */
+	data->lcc_cnt_entry = 0;
+	data->lcc_cnt_exit = 0;
+	data->lccum_cnt = 0;
+	data->lcc_cnt_entry = meta->objLCCumCnt["Entry"];
+	data->lcc_cnt_exit = meta->objLCCumCnt["Exit"];
+
+	if (meta->objLCCumCnt["Entry"]> meta->objLCCumCnt["Exit"])
+		data->lccum_cnt = meta->objLCCumCnt["Entry"] - meta->objLCCumCnt["Exit"];
+	// g_print("Enter: %d, Exit: %d\n", data->lcc_cnt_entry,data->lcc_cnt_exit);
+}
+
+

File diff suppressed because it is too large
+ 1264 - 0
deepstream_test5_app_main.c


BIN
images/kafka_messages.gif


BIN
images/test.png


+ 17 - 0
includes/analytics.h

@@ -0,0 +1,17 @@
+#ifndef _ANALYTICS_H_
+#define _ANALYTICS_H_
+
+#include <gst/gst.h>
+
+/* User defined */
+typedef struct 
+{
+
+    guint32 lcc_cnt_exit;
+    guint32 lccum_cnt;
+    guint32 lcc_cnt_entry;
+    guint32 source_id;
+
+} AnalyticsUserMeta;
+
+#endif

+ 265 - 0
includes/nvdsmeta_schema.h

@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2018-2020, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * NVIDIA Corporation and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto.  Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA Corporation is strictly prohibited.
+ *
+ */
+
+/**
+ * @file
+ * <b>NVIDIA DeepStream: Metadata Extension Structures</b>
+ *
+ * @b Description: This file defines the NVIDIA DeepStream metadata structures
+ * used to describe metadata objects.
+ */
+
+/**
+ * @defgroup  metadata_extensions  Metadata Extension Structures
+ *
+ * Defines metadata structures used to describe metadata objects.
+ *
+ * @ingroup NvDsMetaApi
+ * @{
+ */
+
+#ifndef NVDSMETA_H_
+#define NVDSMETA_H_
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * Defines event type flags.
+ */
+typedef enum NvDsEventType {
+  NVDS_EVENT_ENTRY,
+  NVDS_EVENT_EXIT,
+  NVDS_EVENT_MOVING,
+  NVDS_EVENT_STOPPED,
+  NVDS_EVENT_EMPTY,
+  NVDS_EVENT_PARKED,
+  NVDS_EVENT_RESET,
+
+  /** Reserved for future use. Custom events must be assigned values
+   greater than this. */
+  NVDS_EVENT_RESERVED = 0x100,
+  /** Specifies a custom event. */
+  NVDS_EVENT_CUSTOM = 0x101,
+  NVDS_EVENT_FORCE32 = 0x7FFFFFFF
+} NvDsEventType;
+
+/**
+ * Defines object type flags.
+ */
+typedef enum NvDsObjectType {
+  NVDS_OBJECT_TYPE_VEHICLE,
+  NVDS_OBJECT_TYPE_PERSON,
+  NVDS_OBJECT_TYPE_FACE,
+  NVDS_OBJECT_TYPE_BAG,
+  NVDS_OBJECT_TYPE_BICYCLE,
+  NVDS_OBJECT_TYPE_ROADSIGN,
+  /** Reserved for future use. Custom objects must be assigned values
+   greater than this. */
+  NVDS_OBJECT_TYPE_RESERVED = 0x100,
+  /** Specifies a custom object. */
+  NVDS_OBJECT_TYPE_CUSTOM = 0x101,
+  /** "object" key will be missing in the schema */
+  NVDS_OBJECT_TYPE_UNKNOWN = 0x102,
+  NVDS_OBEJCT_TYPE_FORCE32 = 0x7FFFFFFF
+} NvDsObjectType;
+
+/**
+ * Defines payload type flags.
+ */
+typedef enum NvDsPayloadType {
+  NVDS_PAYLOAD_DEEPSTREAM,
+  NVDS_PAYLOAD_DEEPSTREAM_MINIMAL,
+  /** Reserved for future use. Custom payloads must be assigned values
+   greater than this. */
+  NVDS_PAYLOAD_RESERVED = 0x100,
+  /** Specifies a custom payload. You must implement the nvds_msg2p_*
+   interface. */
+  NVDS_PAYLOAD_CUSTOM = 0x101,
+  NVDS_PAYLOAD_FORCE32 = 0x7FFFFFFF
+} NvDsPayloadType;
+
+/**
+ * Holds a rectangle's position and size.
+ */
+typedef struct NvDsRect {
+  float top;     /**< Holds the position of rectangle's top in pixels. */
+  float left;    /**< Holds the position of rectangle's left side in pixels. */
+  float width;   /**< Holds the rectangle's width in pixels. */
+  float height;  /**< Holds the rectangle's height in pixels. */
+} NvDsRect;
+
+/**
+ * Holds geolocation parameters.
+ */
+typedef struct NvDsGeoLocation {
+  gdouble lat;      /**< Holds the location's latitude. */
+  gdouble lon;      /**< Holds the location's longitude. */
+  gdouble alt;      /**< Holds the location's altitude. */
+} NvDsGeoLocation;
+
+/**
+ * Hold a coordinate's position.
+ */
+typedef struct NvDsCoordinate {
+  gdouble x;        /**< Holds the coordinate's X position. */
+  gdouble y;        /**< Holds the coordinate's Y position. */
+  gdouble z;        /**< Holds the coordinate's Z position. */
+} NvDsCoordinate;
+
+/**
+ * Holds an object's signature.
+ */
+typedef struct NvDsObjectSignature {
+  /** Holds a pointer to an array of signature values. */
+  gdouble *signature;
+  /** Holds the number of signature values in @a signature. */
+  guint size;
+} NvDsObjectSignature;
+
+/**
+ * Holds a vehicle object's parameters.
+ */
+typedef struct NvDsVehicleObject {
+  gchar *type;      /**< Holds a pointer to the type of the vehicle. */
+  gchar *make;      /**< Holds a pointer to the make of the vehicle. */
+  gchar *model;     /**< Holds a pointer to the model of the vehicle. */
+  gchar *color;     /**< Holds a pointer to the color of the vehicle. */
+  gchar *region;    /**< Holds a pointer to the region of the vehicle. */
+  gchar *license;   /**< Holds a pointer to the license number of the vehicle.*/
+} NvDsVehicleObject;
+
+/**
+ * Holds a person object's parameters.
+ */
+typedef struct NvDsPersonObject {
+  gchar *gender;    /**< Holds a pointer to the person's gender. */
+  gchar *hair;      /**< Holds a pointer to the person's hair color. */
+  gchar *cap;       /**< Holds a pointer to the type of cap the person is
+                     wearing, if any. */
+  gchar *apparel;   /**< Holds a pointer to a description of the person's
+                     apparel. */
+  guint age;        /**< Holds the person's age. */
+} NvDsPersonObject;
+
+/**
+ * Holds a face object's parameters.
+ */
+typedef struct NvDsFaceObject {
+  gchar *gender;    /**< Holds a pointer to the person's gender. */
+  gchar *hair;      /**< Holds a pointer to the person's hair color. */
+  gchar *cap;       /**< Holds a pointer to the type of cap the person
+                     is wearing, if any. */
+  gchar *glasses;   /**< Holds a pointer to the type of glasses the person
+                     is wearing, if any. */
+  gchar *facialhair;/**< Holds a pointer to the person's facial hair color. */
+  gchar *name;      /**< Holds a pointer to the person's name. */
+  gchar *eyecolor;  /**< Holds a pointer to the person's eye color. */
+  guint age;        /**< Holds the person's age. */
+} NvDsFaceObject;
+
+/**
+ * Holds event message meta data.
+ *
+ * You can attach various types of objects (vehicle, person, face, etc.)
+ * to an event by setting a pointer to the object in @a extMsg.
+ *
+ * Similarly, you can attach a custom object to an event by setting a pointer to the object in @a extMsg.
+ * A custom object must be handled by the metadata parsing module accordingly.
+ */
+typedef struct NvDsEventMsgMeta {
+  /** Holds the event's type. */
+  NvDsEventType type;
+  /** Holds the object's type. */
+  NvDsObjectType objType;
+  /** Holds the object's bounding box. */
+  NvDsRect bbox;
+  /** Holds the object's geolocation. */
+  NvDsGeoLocation location;
+  /** Holds the object's coordinates. */
+  NvDsCoordinate coordinate;
+  /** Holds the object's signature. */
+  NvDsObjectSignature objSignature;
+  /** Holds the object's class ID. */
+  gint objClassId;
+  /** Holds the ID of the sensor that generated the event. */
+  gint sensorId;
+  /** Holds the ID of the analytics module that generated the event. */
+  gint moduleId;
+  /** Holds the ID of the place related to the object. */
+  gint placeId;
+  /** Holds the ID of the component (plugin) that generated this event. */
+  gint componentId;
+  /** Holds the video frame ID of this event. */
+  gint frameId;
+  /** Holds the confidence level of the inference. */
+  gdouble confidence;
+  /** Holds the object's tracking ID. */
+  gint trackingId;
+  /** Holds a pointer to the generated event's timestamp. */
+  gchar *ts;
+  /** Holds a pointer to the detected or inferred object's ID. */
+  gchar *objectId;
+
+  /** Holds a pointer to a string containing the sensor's identity. */
+  gchar *sensorStr;
+  /** Holds a pointer to a string containing other attributes associated with
+   the object. */
+  gchar *otherAttrs;
+  /** Holds a pointer to the name of the video file. */
+  gchar *videoPath;
+  /** Holds a pointer to event message meta data. This can be used to hold
+   data that can't be accommodated in the existing fields, or an associated
+   object (representing a vehicle, person, face, etc.). */
+  gpointer extMsg;
+  /** Holds the size of the custom object at @a extMsg. */
+  guint extMsgSize;
+  
+  /*My data*/
+  guint occupancy;
+  guint source_id;
+  guint lccum_cnt_entry;
+  guint lccum_cnt_exit;
+} NvDsEventMsgMeta;
+
+/**
+ * Holds event information.
+ */
+typedef struct _NvDsEvent {
+  /** Holds the type of event. */
+  NvDsEventType eventType;
+  /** Holds a pointer to event metadata. */
+  NvDsEventMsgMeta *metadata;
+} NvDsEvent;
+
+/**
+ * Holds payload metadata.
+ */
+typedef struct NvDsPayload {
+  /** Holds a pointer to the payload. */
+  gpointer payload;
+  /** Holds the size of the payload. */
+  guint payloadSize;
+  /** Holds the ID of the component (plugin) which attached the payload
+   (optional). */
+  guint componentId;
+} NvDsPayload;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* NVDSMETA_H_ */
+
+/** @} */