Hi,
I would like to use face recognition (Tappas) model using Hailo 8L connected to PCIE card. I could successfully run for single stream rtsp detection. It’s working properly. I would like to include it for 2 more RTSP stream (Tried with example of Re-ID) used multistream, But didn’t work. Attached the code for reference.
#!/bin/bash
set -e
function init_variables() {
print_help_if_needed $@
readonly SRC_0="rtsp://admin:admin%40123@192.168.0.105:554/stream1.sdp"
readonly SRC_1="rtsp://admin:admin%40123@192.168.0.106:554/stream1.sdp"
readonly SRC_2="rtsp://admin:admin%40123@192.168.0.107:554/stream1.sdp"
readonly RESOURCES_DIR="$TAPPAS_WORKSPACE/apps/h8/gstreamer/general/face_recognition/resources"
readonly POSTPROCESS_DIR="$TAPPAS_WORKSPACE/apps/h8/gstreamer/libs/post_processes/"
readonly APPS_LIBS_DIR="$TAPPAS_WORKSPACE/apps/h8/gstreamer/libs/apps/vms/"
readonly CROPPER_SO="$POSTPROCESS_DIR/cropping_algorithms/libvms_croppers.so"
# Face Detection
readonly FACE_DETECTION_SO="$POSTPROCESS_DIR/libface_detection_post.so"
# Face Alignment
readonly FACE_ALIGN_SO="$APPS_LIBS_DIR/libvms_face_align.so"
# Face Recognition
readonly RECOGNITION_POST_SO="$POSTPROCESS_DIR/libface_recognition_post.so"
readonly RECOGNITION_HEF_PATH="$RESOURCES_DIR/arcface_mobilefacenet.hef"
# Face Detection and Landmarking
readonly DEFAULT_HEF_PATH="$RESOURCES_DIR/retinaface_mobilenet_v1.hef"
readonly STREAM_DISPLAY_SIZE=640
readonly FUNCTION_NAME="retinaface"
detection_network="scrfd_10g"
detection_post=$FUNCTION_NAME
recognition_hef="$RESOURCES_DIR/arcface_mobilefacenet.hef"
recognition_post="arcface_nv12"
hef_path="$RESOURCES_DIR/retinaface_mobilenet_v1.hef"
video_format="RGB"
input_source="$RESOURCES_DIR/face_recognition.mp4"
video_sink_element=$([ "$XV_SUPPORTED" = "true" ] && echo "xvimagesink" || echo "ximagesink")
additional_parameters=""
print_gst_launch_only=false
vdevice_key=1
local_gallery_file=“$RESOURCES_DIR/gallery/face_recognition_local_gallery_rgba.json”
decode_scale_elements=“decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=8 ! video/x-raw,pixel-aspect-ratio=1/1”
video_sink_element=$([ “$XV_SUPPORTED” = “true” ] && echo “xvimagesink” || echo “ximagesink”)
num_of_src=3
debug=false
gst_top_command=""
additional_parameters=""
screen_width=0
screen_height=0
fpsdisplaysink_elemet=""
rtsp_sources=""
compositor_locations="sink_0::xpos=0 sink_0::ypos=0 sink_1::xpos=640 sink_1::ypos=0 sink_2::xpos=1280 sink_2::ypos=0 sink_3::xpos=1920 sink_3::ypos=0 sink_4::xpos=0 sink_4::ypos=640 sink_5::xpos=640 sink_5::ypos=640 sink_6::xpos=1280 sink_6::ypos=640 sink_7::xpos=1920 sink_7::ypos=640"
}
function print_usage() {
echo “Face recognition - pipeline usage:”
echo “”
echo “Options:”
echo " --help Show this help"
echo " --show-fps Printing fps"
echo " -i INPUT --input INPUT Set the input source (default $input_source)"
echo " --print-gst-launch Print the ready gst-launch command without running it"
exit 0
}
function print_help_if_needed() {
while test $# -gt 0; do
if [ “$1” = “–help” ] || [ “$1” == “-h” ]; then
print_usage
fi
shift
done
}
function parse_args() {
while test $# -gt 0; do
if [ “$1” = “–debug” ]; then
echo “Setting debug mode. using gst-top to print time and memory consuming elements”
debug=true
gst_top_command=“SHOW_FPS=1 GST_DEBUG=GST_TRACER:13 GST_DEBUG_DUMP_TRACE_DIR=. gst-top-1.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” = “–num-of-sources” ]; then
shift
echo “Setting number of rtsp sources to $1”
num_of_src=$1
else
echo “Received invalid argument: $1. See expected arguments below:”
print_usage
exit 1
fi
shift
done
}
function determine_screen_size() {
if [ “$num_of_src” -lt “4” ]; then
screen_width=$(($num_of_src * $STREAM_DISPLAY_SIZE))
screen_height=$STREAM_DISPLAY_SIZE
else
screen_width=$((4 * $STREAM_DISPLAY_SIZE))
screen_height=$((2 * $STREAM_DISPLAY_SIZE))
fi
}
function create_rtsp_sources() {
for ((n = 0; n < $num_of_src; n++)); do
src_name=“SRC_${n}”
src_name=“${!src_name}”
rtsp_sources+=“rtspsrc location=$src_name name=source_$n message-forward=true !
rtph264depay !
queue name=hailo_preprocess_q_$n leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 !
$decode_scale_elements ! videoconvert n-threads=8 !
video/x-raw,pixel-aspect-ratio=1/1 !
fun.sink_$n sid.src_$n !
queue name=comp_q_$n leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 !
comp.sink_$n "
streamrouter_input_streams+=” src_$n::input-streams="<sink_$n>""
done
}
function main() {
init_variables $@
parse_args $@
streamrouter_input_streams=“”
create_rtsp_sources
determine_screen_size
if [ "$num_of_src" -le 4 ]; then
device_id_prop="0000:05:00.0"
else
device_id_prop="0000:05:00.0" # Use both devices for 4+ sources
fi
# If the video provided is from a camera
if [[ $input_source =~ "/dev/video" ]]; then
source_element="v4l2src device=$input_source name=src_0 ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=30/1 ! \
queue max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
videoflip video-direction=horiz"
else
source_element="filesrc location=$input_source name=src_0 ! decodebin"
fi
RECOGNITION_PIPELINE="queue name=hailo_pre_cropper2_q leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 !
hailocropper so-path=$CROPPER_SO function-name=create_crops internal-offset=true name=cropper2
hailoaggregator name=agg2
cropper2. ! queue name=bypess2_q leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! agg2.
cropper2. ! queue name=pre_face_align_q leaky=no max-size-buffers=10 max-size-bytes=0 max-size-time=0 !
hailofilter so-path=$FACE_ALIGN_SO name=face_align_hailofilter use-gst-buffer=true qos=false !
queue name=detector_pos_face_align_q leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hailonet hef-path=$recognition_hef scheduling-algorithm=1 vdevice-group-id=1 ! \
queue name=reid_post_q leaky=no max-size-buffers=10 max-size-bytes=0 max-size-time=0 ! \
hailofilter function-name=$recognition_post so-path=$RECOGNITION_POST_SO ! \
queue name=reid_pre_agg_q leaky=no max-size-buffers=10 max-size-bytes=0 max-size-time=0 ! \
agg2. agg2. "
FACE_DETECTION_PIPELINE="hailonet hef-path=$hef_path scheduling-algorithm=1 vdevice-group-id=1 ! \
queue name=detector_post_q leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hailofilter so-path=$FACE_DETECTION_SO name=face_detection_hailofilter qos=false function_name=retinaface"
DETECTION_PIPELINE="tee name=t hailomuxer name=hmux \
t. ! \
queue name=detector_bypass_q leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hmux. \
t. ! \
videoscale name=face_videoscale method=0 n-threads=2 add-borders=false qos=false ! \
video/x-raw, pixel-aspect-ratio=1/1 ! \
queue name=pre_face_detector_infer_q leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
$FACE_DETECTION_PIPELINE ! \
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hmux. \
hmux. "
pipeline="gst-launch-1.0 \
hailoroundrobin mode=1 name=fun ! \
queue name=hailo_pre_convert_0 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
videoconvert n-threads=1 qos=false ! video/x-raw,format=RGB ! \
$dewarp_element \
$DETECTION_PIPELINE ! \
queue name=hailo_pre_tracker leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hailotracker name=hailo_tracker hailo-objects-blacklist=hailo_landmarks,hailo_depth_mask,hailo_class_mask,hailo_matrix \
class-id=1 kalman-dist-thr=0.7 iou-thr=0.7 init-iou-thr=0.8 keep-new-frames=2 keep-tracked-frames=4 \
keep-lost-frames=8 qos=false std-weight-position-box=0.01 std-weight-velocity-box=0.001 ! \
$RECOGNITION_PIPELINE ! \
queue name=hailo_pre_gallery leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hailogallery gallery-file-path=$local_gallery_file \
load-local-gallery=true similarity-thr=.4 gallery-queue-size=20 class-id=-1 ! \
queue name=hailo_pre_draw2 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hailogallery similarity-thr=.4 gallery-queue-size=100 class-id=1 ! \
queue name=hailo_post_gallery leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
videoscale n-threads=2 add-borders=false qos=false ! video/x-raw, width=800, height=450, pixel-aspect-ratio=1/1 ! \
queue name=hailo_pre_draw leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hailofilter use-gst-buffer=true so-path=$RE_ID_OVERLAY qos=false ! \
queue name=hailo_post_draw leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
hailostreamrouter name=sid $streamrouter_input_streams \
compositor name=comp start-time-selection=0 $compositor_locations ! \
queue name=hailo_video_q_0 leaky=no max_size_buffers=30 max-size-bytes=0 max-size-time=0 ! \
videoconvert n-threads=2 qos=false ! \
queue name=hailo_display_q_0 leaky=no max_size_buffers=300 max-size-bytes=0 max-size-time=0 ! \
$video_sink name=hailo_display sync=false \
$rtsp_sources ${additional_parameters}"
echo ${pipeline}
if [ "$print_gst_launch_only" = true ]; then
exit 0
fi
echo "Running Pipeline..."
eval "${pipeline}"
}
main $@ Running this code results in following error:
(gst-launch-1.0:45320): GStreamer-WARNING **: 15:41:57.461: Trying to link elements cropper2 and pre_face_align_q that don’t share a common ancestor: pre_face_align_q hasn’t been added to a bin or pipeline, and cropper2 is in pipeline0
(gst-launch-1.0:45320): GStreamer-WARNING **: 15:41:57.461: Trying to link elements cropper2 and pre_face_align_q that don’t share a common ancestor: pre_face_align_q hasn’t been added to a bin or pipeline, and cropper2 is in pipeline0
WARNING: erroneous pipeline: syntax error.
Thanks.