forked from dlstreamer/dlstreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracking.sh
executable file
·72 lines (64 loc) · 2.72 KB
/
tracking.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# ==============================================================================
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==============================================================================
# "This sample demonstrates how to track people and vehicles on a video stream with GVA"
# "Tracker is especially useful for videos without frequent scene changes"
# "Usage: ./tracking.sh EVERY_NTH_FRAME FILE"
# "./traking.sh 5 /home/user/video.mp4"
# "EVERY_NTH_FRAME Detection on every nth frame only(int)"
# "FILE Path to mp4 or h264 file"
set -e
BASEDIR=$(dirname "$0")/../..
#import GET_MODEL_PATH and PROC_PATH
source $BASEDIR/scripts/path_extractor.sh
if [ -n ${GST_SAMPLES_DIR} ]; then
# set up GST environment
source $BASEDIR/scripts/setup_env.sh
fi
source $BASEDIR/scripts/setlocale.sh
# parse input parameters
EVERY_NTH_FRAME=${1}
FILE=${2}
# define the models used for detection and classification
DETECTION_MODEL=person-vehicle-bike-detection-crossroad-0078
PERSON_CLASSIFICATION_MODEL=person-attributes-recognition-crossroad-0230
VEHICLE_CLASSIFICATION_MODEL=vehicle-attributes-recognition-barrier-0039
# define parameters for inference
# tracking type: short-term, zero-term, iou
# use short-term tracker for every_nth_frame > 1
TRACKING_TYPE="short-term"
SKIP_INTERVAL=10
# pipeline scheme
# gst-launch-1.0 --gst-plugin-path ${GST_PLUGIN_PATH} \
# VIDEO_SOURCE \
# DETECTION ! queue ! \
# TRACKING ! queue ! \
# PERSON_CLASSIFICATION ! queue ! \
# VEHICLE_CLASSIFICATION ! queue ! \
# VIDEO_SINK
# launch pipeline
gst-launch-1.0 --gst-plugin-path ${GST_PLUGIN_PATH} \
filesrc location=${FILE} ! decodebin ! videoconvert ! video/x-raw,format=BGRx ! \
gvadetect model=$(GET_MODEL_PATH $DETECTION_MODEL) \
model-proc=$(PROC_PATH $DETECTION_MODEL) \
every-nth-frame=${EVERY_NTH_FRAME} \
device=CPU pre-proc=ie ! \
queue ! \
gvatrack tracking-type=${TRACKING_TYPE} ! \
queue ! \
gvaclassify model=$(GET_MODEL_PATH $PERSON_CLASSIFICATION_MODEL) \
model-proc=$(PROC_PATH $PERSON_CLASSIFICATION_MODEL) \
skip-classified-objects=yes \
skip-interval=${SKIP_INTERVAL} \
device=CPU pre-proc=ie object-class=person ! \
queue ! \
gvaclassify model=$(GET_MODEL_PATH $VEHICLE_CLASSIFICATION_MODEL) \
model-proc=$(PROC_PATH $VEHICLE_CLASSIFICATION_MODEL) \
skip-classified-objects=yes \
skip-interval=${SKIP_INTERVAL} \
device=CPU pre-proc=ie object-class=vehicle ! \
queue ! \
gvawatermark ! videoconvert ! fpsdisplaysink video-sink=xvimagesink sync=false