Summary
This #!/bin/bash
set -e
CURRENT_DIR=“$(dirname “$(realpath “$BASH_SOURCE[0]”)”)”
function init_variables() {
readonly RESOURCES_DIR=“${CURRENT_DIR}/resources”
readonly POSTPROCESS_DIR=“/usr/lib/hailo-post-processes”
readonly DEFAULT_POSTPROCESS_SO=“$POSTPROCESS_DIR/libface_detection_post.so”
readonly DEFAULT_HEF_PATH=“${RESOURCES_DIR}/scrfd_10g.hef”
readonly DEFAULT_JSON_CONFIG_PATH=“$RESOURCES_DIR/configs/scrfd.json”
readonly DEFAULT_FRONTEND_CONFIG_FILE_PATH=“$RESOURCES_DIR/configs/frontend_config.json”
readonly DEFAULT_ENCODER_CONFIG_PATH=“$RESOURCES_DIR/configs/encoder_config.json”
readonly DEFAULT_NETWORK_NAME=“scrfd_10g”
readonly DEFAULT_VIDEO_SOURCE=“/dev/video0”
readonly DEFAULT_UDP_PORT=5000 # Changed to avoid conflict with detection.sh
readonly DEFAULT_UDP_HOST_IP=“10.0.0.2”
readonly DEFAULT_FRAMERATE=“30/1”
readonly DEFAULT_BITRATE=25000000
encoder_config_path=“$DEFAULT_ENCODER_CONFIG_PATH”
postprocess_so=“$DEFAULT_POSTPROCESS_SO”
network_name=“$DEFAULT_NETWORK_NAME”
hef_path=“$DEFAULT_HEF_PATH”
json_config_path=“$DEFAULT_JSON_CONFIG_PATH”
frontend_config_file_path=“$DEFAULT_FRONTEND_CONFIG_FILE_PATH”
udp_host_ip=“$DEFAULT_UDP_HOST_IP”
udp_port=“$DEFAULT_UDP_PORT”
sync_pipeline=false
framerate=“$DEFAULT_FRAMERATE”
max_buffers_size=5
bitrate=“$DEFAULT_BITRATE”
encoding_hdr=“hdr=false”
print_gst_launch_only=false
additional_parameters=“”
#debug_mode=false
mode=“daylight”
tuning_extension=“”
project=“hailo15h”
}
function print_usage() {
echo “Hailo15 Face Detection pipeline usage:”
echo “”
echo “Options:”
echo " --help Show this help"
echo " --show-fps Print fps"
echo " --print-gst-launch Print gst-launch command without running"
echo " --debug Enable debug mode with verbose output"
echo " --port PORT Set UDP port (default: 5001)"
echo " --mode mode (e.g., daylight)"
echo " --tuning tuning extension - relevant only for denoise (e.g., _r0225)"
echo " --project project name (e.g., hailo15h)"
exit 0
}
function parse_args() {
while test $# -gt 0; do
if [ “$1” = “–help” ] || [ “$1” == “-h” ]; then
print_usage
exit 0
elif [ “$1” = “–print-gst-launch” ]; then
print_gst_launch_only=true
elif [ “$1” = “–show-fps” ]; then
echo “Printing fps”
additional_parameters=“-v | grep hailo_display”
elif [ “$1” = “–debug” ]; then
debug_mode=true
additional_parameters=“-v”
elif [ “$1” = “–port” ]; then
shift
udp_port=“$1”
else
echo “Received invalid argument: $1. See expected arguments below:”
print_usage
exit 1
fi
shift
done
}
function check_files() {
echo “Checking required files…”
local missing_files=()
if [ ! -f “$hef_path” ]; then
missing_files+=(“HEF file: $hef_path”)
fi
if [ ! -f “$json_config_path” ]; then
missing_files+=(“JSON config: $json_config_path”)
fi
if [ ! -f “$postprocess_so” ]; then
missing_files+=(“Post-process library: $postprocess_so”)
fi
if [ ! -f “$frontend_config_file_path” ]; then
missing_files+=(“Frontend config: $frontend_config_file_path”)
fi
if [ ! -f “$encoder_config_path” ]; then
missing_files+=(“Encoder config: $encoder_config_path”)
fi
if [ ${#missing_files[@]} -gt 0 ]; then
echo “ERROR: Missing required files:”
for file in “${missing_files[@]}”; do
echo " - $file"
done
exit 1
fi
echo “All required files found.”
}
init_variables $@
parse_args $@
# Check if files exist
check_files
UDP_SINK=“udpsink host=$udp_host_ip port=$udp_port”
PIPELINE="gst-launch-1.0 \
hailofrontendbinsrc config-file-path=$frontend_config_file_path name=frontend \\
frontend. ! \\
queue leaky=no max-size-buffers=$max_buffers_size max-size-bytes=0 max-size-time=0 ! \\
hailonet hef-path=$hef_path scheduling-algorithm=1 vdevice-group-id=device0 ! \\
queue leaky=no max-size-buffers=$max_buffers_size max-size-bytes=0 max-size-time=0 ! \\
hailofilter function-name=$network_name config-path=$json_config_path so-path=$postprocess_so qos=false ! \\
queue leaky=no max-size-buffers=$max_buffers_size max-size-bytes=0 max-size-time=0 ! \\
hailooverlay qos=false ! \\
queue leaky=no max-size-buffers=$max_buffers_size max-size-bytes=0 max-size-time=0 ! \\
hailoencodebin config-file-path=$encoder_config_path ! h264parse config-interval=-1 ! \\
video/x-h264,framerate=$framerate ! \\
tee name=udp_tee \\
udp_tee. ! \\
queue leaky=no max-size-buffers=$max_buffers_size max-size-bytes=0 max-size-time=0 ! \\
rtph264pay ! 'application/x-rtp, media=(string)video, encoding-name=(string)H264' ! \\
$UDP_SINK name=udp_sink sync=$sync_pipeline \
udp_tee. ! \\
queue leaky=no max-size-buffers=$max_buffers_size max-size-bytes=0 max-size-time=0 ! \\
fpsdisplaysink fps-update-interval=2000 video-sink=fakesink name=hailo_display sync=$sync_pipeline text-overlay=false \\
${additional_parameters}"
echo “Running $network_name”
echo “UDP streaming to: $udp_host_ip:$udp_port”
echo “”
if [ “$debug_mode” = true ]; then
echo “=== DEBUG INFO ===”
echo “HEF Path: $hef_path”
echo “JSON Config: $json_config_path”
echo “Post-process SO: $postprocess_so”
echo “Frontend Config: $frontend_config_file_path”
echo “Encoder Config: $encoder_config_path”
echo “==================”
echo “”
fi
echo “Pipeline command:”
echo “${PIPELINE}”
echo “”
if [ “$print_gst_launch_only” = true ]; then
exit 0
fi
eval ${PIPELINE}text will be hidden