-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
HailoRT-Automation
committed
May 20, 2024
1 parent
e9fe4e9
commit 4341aa3
Showing
30 changed files
with
1,487 additions
and
471 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
apps/h15/gstreamer/license_plate_recognition/configs/yolov4_license_plate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"iou_threshold": 0.45, | ||
"detection_threshold": 0.3, | ||
"output_activation": "sigmoid", | ||
"label_offset": 1, | ||
"max_boxes":200, | ||
"anchors": [ | ||
[ | ||
81, | ||
82, | ||
135, | ||
169 | ||
], | ||
[ | ||
344, | ||
319, | ||
10, | ||
14 | ||
], | ||
[ | ||
23, | ||
27, | ||
37, | ||
58 | ||
] | ||
], | ||
"labels": [ | ||
"unlabeled", | ||
"license_plate" | ||
] | ||
} |
116 changes: 116 additions & 0 deletions
116
apps/h15/gstreamer/license_plate_recognition/configs/yolov5.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"iou_threshold": 0.45, | ||
"detection_threshold": 0.3, | ||
"output_activation": "none", | ||
"label_offset":1, | ||
"max_boxes":200, | ||
"anchors": [ | ||
[ | ||
116, | ||
90, | ||
156, | ||
198, | ||
373, | ||
326 | ||
], | ||
[ | ||
30, | ||
61, | ||
62, | ||
45, | ||
59, | ||
119 | ||
], | ||
[ | ||
10, | ||
13, | ||
16, | ||
30, | ||
33, | ||
23 | ||
] | ||
], | ||
"labels": [ | ||
"unlabeled", | ||
"person", | ||
"bicycle", | ||
"car", | ||
"motorcycle", | ||
"airplane", | ||
"bus", | ||
"train", | ||
"truck", | ||
"boat", | ||
"traffic light", | ||
"fire hydrant", | ||
"stop sign", | ||
"parking meter", | ||
"bench", | ||
"bird", | ||
"cat", | ||
"dog", | ||
"horse", | ||
"sheep", | ||
"cow", | ||
"elephant", | ||
"bear", | ||
"zebra", | ||
"giraffe", | ||
"backpack", | ||
"umbrella", | ||
"handbag", | ||
"tie", | ||
"suitcase", | ||
"frisbee", | ||
"skis", | ||
"snowboard", | ||
"sports ball", | ||
"kite", | ||
"baseball bat", | ||
"baseball glove", | ||
"skateboard", | ||
"surfboard", | ||
"tennis racket", | ||
"bottle", | ||
"wine glass", | ||
"cup", | ||
"fork", | ||
"knife", | ||
"spoon", | ||
"bowl", | ||
"banana", | ||
"apple", | ||
"sandwich", | ||
"orange", | ||
"broccoli", | ||
"carrot", | ||
"hot dog", | ||
"pizza", | ||
"donut", | ||
"cake", | ||
"chair", | ||
"couch", | ||
"potted plant", | ||
"bed", | ||
"dining table", | ||
"toilet", | ||
"tv", | ||
"laptop", | ||
"mouse", | ||
"remote", | ||
"keyboard", | ||
"cell phone", | ||
"microwave", | ||
"oven", | ||
"toaster", | ||
"sink", | ||
"refrigerator", | ||
"book", | ||
"clock", | ||
"vase", | ||
"scissors", | ||
"teddy bear", | ||
"hair drier", | ||
"toothbrush" | ||
] | ||
} |
37 changes: 37 additions & 0 deletions
37
apps/h15/gstreamer/license_plate_recognition/configs/yolov5_vehicle_detection.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"iou_threshold": 0.45, | ||
"detection_threshold": 0.3, | ||
"output_activation": "none", | ||
"label_offset":1, | ||
"max_boxes":200, | ||
"anchors": [ | ||
[ | ||
116, | ||
90, | ||
156, | ||
198, | ||
373, | ||
326 | ||
], | ||
[ | ||
30, | ||
61, | ||
62, | ||
45, | ||
59, | ||
119 | ||
], | ||
[ | ||
10, | ||
13, | ||
16, | ||
30, | ||
33, | ||
23 | ||
] | ||
], | ||
"labels": [ | ||
"unlabeled", | ||
"car" | ||
] | ||
} |
192 changes: 192 additions & 0 deletions
192
apps/h15/gstreamer/license_plate_recognition/debug/lpr_small_yolo_rgb.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
CURRENT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" | ||
|
||
function init_variables() { | ||
print_help_if_needed $@ | ||
|
||
# Basic Directories | ||
readonly POSTPROCESS_DIR="/usr/lib/hailo-post-processes" | ||
readonly CROPPING_ALGORITHMS_DIR="$POSTPROCESS_DIR/cropping_algorithms" | ||
readonly RESOURCES_DIR="${CURRENT_DIR}/resources" | ||
readonly DEFAULT_LICENSE_PLATE_JSON_CONFIG_PATH="$RESOURCES_DIR/configs/yolov4_license_plate.json" | ||
readonly DEFAULT_VEHICLE_JSON_CONFIG_PATH="$RESOURCES_DIR/configs/yolov5_vehicle_detection.json" | ||
|
||
# Default Video | ||
readonly DEFAULT_VIDEO_SOURCE="$RESOURCES_DIR/lpr_rgb.raw" | ||
|
||
readonly DEBUG_SO="$POSTPROCESS_DIR/libdebug.so" | ||
readonly DEBUG_FUNCTION="generate_center_detection" | ||
|
||
# Whole buffer crop | ||
readonly WHOLE_BUFFER_CROP_SO="$CROPPING_ALGORITHMS_DIR/libwhole_buffer.so" | ||
|
||
# Vehicle Detection Macros | ||
readonly VEHICLE_DETECTION_HEF="$RESOURCES_DIR/small_yolov5m_vehicles.hef" | ||
readonly VEHICLE_DETECTION_POST_SO="$POSTPROCESS_DIR/libyolo_post.so" | ||
readonly VEHICLE_DETECTION_POST_FUNC="yolov5_vehicles_only" | ||
|
||
# License Plate Detection Macros | ||
readonly LICENSE_PLATE_DETECTION_HEF="$RESOURCES_DIR/tiny_yolov4_license_plates.hef" | ||
readonly LICENSE_PLATE_DETECTION_POST_SO="$POSTPROCESS_DIR/libyolo_post.so" | ||
readonly LICENSE_PLATE_DETECTION_POST_FUNC="tiny_yolov4_license_plates" | ||
|
||
# License Plate OCR Macros | ||
readonly LICENSE_PLATE_OCR_HEF="$RESOURCES_DIR/lprnet.hef" | ||
readonly LICENSE_PLATE_OCR_POST_SO="$POSTPROCESS_DIR/libocr_post.so" | ||
|
||
# Cropping Algorithm Macros | ||
readonly LICENSE_PLATE_CROP_SO="$CROPPING_ALGORITHMS_DIR/liblpr_croppers.so" | ||
readonly LICENSE_PLATE_DETECTION_CROP_FUNC="vehicles_without_ocr" | ||
readonly LICENSE_PLATE_OCR_CROP_FUNC="license_plate_quality_estimation" | ||
|
||
# Pipeline Utilities | ||
readonly LPR_OVERLAY="$RESOURCES_DIR/liblpr_overlay.so" | ||
readonly LPR_OCR_SINK="$RESOURCES_DIR/liblpr_ocrsink.so" | ||
|
||
input_source=$DEFAULT_VIDEO_SOURCE | ||
|
||
print_gst_launch_only=false | ||
additonal_parameters="" | ||
stats_element="" | ||
debug_stats_export="" | ||
sync_pipeline=true | ||
device_id_prop="" | ||
tee_name="context_tee" | ||
internal_offset=false | ||
pipeline_1="" | ||
license_plate_json_config_path=$DEFAULT_LICENSE_PLATE_JSON_CONFIG_PATH | ||
car_json_config_path=$DEFAULT_VEHICLE_JSON_CONFIG_PATH | ||
} | ||
|
||
function print_help_if_needed() { | ||
while test $# -gt 0; do | ||
if [ "$1" = "--help" ] || [ "$1" == "-h" ]; then | ||
print_usage | ||
fi | ||
|
||
shift | ||
done | ||
} | ||
|
||
function print_usage() { | ||
echo "IMX8 LPR pipeline usage:" | ||
echo "" | ||
echo "Options:" | ||
echo " -h --help Show this help" | ||
echo " --show-fps Print fps" | ||
echo " --print-gst-launch Print the ready gst-launch command without running it" | ||
echo " --print-device-stats Print the power and temperature measured" | ||
exit 0 | ||
} | ||
|
||
function parse_args() { | ||
while test $# -gt 0; do | ||
if [ "$1" = "--print-gst-launch" ]; then | ||
print_gst_launch_only=true | ||
elif [ "$1" = "--print-device-stats" ]; then | ||
hailo_bus_id=$(hailortcli scan | awk '{ print $NF }' | tail -n 1) | ||
device_id_prop="device_id=$hailo_bus_id" | ||
stats_element="hailodevicestats $device_id_prop" | ||
debug_stats_export="GST_DEBUG=hailodevicestats:5" | ||
elif [ "$1" = "--show-fps" ]; then | ||
echo "Printing fps" | ||
additonal_parameters="-v | grep -e hailo_display -e hailodevicestats" | ||
else | ||
echo "Received invalid argument: $1. See expected arguments below:" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
shift | ||
done | ||
} | ||
|
||
init_variables $@ | ||
parse_args $@ | ||
source_element="filesrc location=$input_source name=src_0 ! rawvideoparse format=rgb width=1920 height=1080" | ||
internal_offset=true | ||
|
||
function create_lp_detection_pipeline() { | ||
pipeline_1="queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailocropper pool-size=3 so-path=$LICENSE_PLATE_CROP_SO function-name=$LICENSE_PLATE_DETECTION_CROP_FUNC internal-offset=$internal_offset drop-uncropped-buffers=true name=cropper1 \ | ||
hailoaggregator name=agg1 \ | ||
cropper1. ! \ | ||
queue leaky=no max-size-buffers=50 max-size-bytes=0 max-size-time=0 ! \ | ||
agg1. \ | ||
cropper1. ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailonet hef-path=$LICENSE_PLATE_DETECTION_HEF vdevice-key=1 scheduling-algorithm=1 ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailofilter so-path=$LICENSE_PLATE_DETECTION_POST_SO config-path=$license_plate_json_config_path function-name=$LICENSE_PLATE_DETECTION_POST_FUNC qos=false ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
agg1. \ | ||
agg1. ! queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailoexportfile location=lp_export.json ! \ | ||
hailocropper pool-size=3 so-path=$LICENSE_PLATE_CROP_SO function-name=$LICENSE_PLATE_OCR_CROP_FUNC internal-offset=$internal_offset drop-uncropped-buffers=true name=cropper2 \ | ||
hailoaggregator name=agg2 \ | ||
cropper2. ! \ | ||
queue leaky=no max-size-buffers=50 max-size-bytes=0 max-size-time=0 ! \ | ||
agg2. \ | ||
cropper2. ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailonet hef-path=$LICENSE_PLATE_OCR_HEF vdevice-key=1 scheduling-algorithm=1 ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailofilter so-path=$LICENSE_PLATE_OCR_POST_SO qos=false ! \ | ||
hailoexportfile location=lprnet_export.json ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
agg2. \ | ||
agg2. ! queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0" | ||
} | ||
create_lp_detection_pipeline $@ | ||
|
||
FPS_SINK="fpsdisplaysink fps-update-interval=2000 video-sink=fakesink name=hailo_display sync=$sync_pipeline text-overlay=false" | ||
|
||
UDPSINK="videoconvert qos=false ! video/x-raw, format=I420 ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
videoscale ! video/x-raw, width=300, height=300 ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
rtpvrawpay ! 'application/x-rtp, media=(string)video, encoding-name=(string)RAW' ! \ | ||
fpsdisplaysink fps-update-interval=2000 video-sink='udpsink host=10.0.0.2 port=5000' name=hailo_display sync=$sync_pipeline text-overlay=false" | ||
|
||
PIPELINE="${debug_stats_export} gst-launch-1.0 ${stats_element} \ | ||
$source_element ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailocropper pool-size=3 so-path=$WHOLE_BUFFER_CROP_SO function-name=create_crops internal-offset=$internal_offset drop-uncropped-buffers=true name=cropper0 \ | ||
hailoaggregator name=agg0 \ | ||
cropper0. ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
agg0. \ | ||
cropper0. ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailonet hef-path=$VEHICLE_DETECTION_HEF vdevice-key=1 scheduling-algorithm=1 ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailofilter so-path=$VEHICLE_DETECTION_POST_SO config-path=$car_json_config_path function-name=$VEHICLE_DETECTION_POST_FUNC qos=false ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
agg0. \ | ||
agg0. ! queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailotracker name=hailo_tracker keep-past-metadata=true kalman-dist-thr=.5 iou-thr=.6 keep-tracked-frames=2 keep-lost-frames=2 ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
tee name=$tee_name \ | ||
$tee_name. ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
videobox top=1 bottom=1 ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
hailooverlay line-thickness=3 font-thickness=1 qos=false ! \ | ||
hailofilter use-gst-buffer=true so-path=$LPR_OVERLAY qos=false ! \ | ||
queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \ | ||
$UDPSINK \ | ||
$tee_name. ! \ | ||
$pipeline_1 ! \ | ||
hailofilter use-gst-buffer=true so-path=$LPR_OCR_SINK qos=false ! \ | ||
fakesink sync=false async=false ${additonal_parameters}" | ||
|
||
echo "Running License Plate Recognition" | ||
echo ${PIPELINE} | ||
|
||
if [ "$print_gst_launch_only" = true ]; then | ||
exit 0 | ||
fi | ||
|
||
eval ${PIPELINE} |
Oops, something went wrong.