forked from sergiomsilva/alpr-unconstrained
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·106 lines (89 loc) · 1.98 KB
/
run.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
check_file()
{
if [ ! -f "$1" ]
then
return 0
else
return 1
fi
}
check_dir()
{
if [ ! -d "$1" ]
then
return 0
else
return 1
fi
}
# Check if Darknet is compiled
check_file "darknet/libdarknet.so"
retval=$?
if [ $retval -eq 0 ]
then
echo "Darknet is not compiled! Go to 'darknet' directory and 'make'!"
exit 1
fi
lp_model="data/lp-detector/wpod-net_update1.h5"
input_dir=''
output_dir=''
csv_file=''
# Check # of arguments
usage() {
echo ""
echo " Usage:"
echo ""
echo " bash $0 -i input/dir -o output/dir -c csv_file.csv [-h] [-l path/to/model]:"
echo ""
echo " -i Input dir path (containing JPG or PNG images)"
echo " -o Output dir path"
echo " -c Output CSV file path"
echo " -l Path to Keras LP detector model (default = $lp_model)"
echo " -h Print this help information"
echo ""
exit 1
}
while getopts 'i:o:c:l:h' OPTION; do
case $OPTION in
i) input_dir=$OPTARG;;
o) output_dir=$OPTARG;;
c) csv_file=$OPTARG;;
l) lp_model=$OPTARG;;
h) usage;;
esac
done
if [ -z "$input_dir" ]; then echo "Input dir not set."; usage; exit 1; fi
if [ -z "$output_dir" ]; then echo "Ouput dir not set."; usage; exit 1; fi
if [ -z "$csv_file" ]; then echo "CSV file not set." ; usage; exit 1; fi
# Check if input dir exists
check_dir $input_dir
retval=$?
if [ $retval -eq 0 ]
then
echo "Input directory ($input_dir) does not exist"
exit 1
fi
# Check if output dir exists, if not, create it
check_dir $output_dir
retval=$?
if [ $retval -eq 0 ]
then
mkdir -p $output_dir
fi
# End if any error occur
set -e
# Detect vehicles
python vehicle-detection.py $input_dir $output_dir
# Detect license plates
python license-plate-detection.py $output_dir $lp_model
# OCR
python license-plate-ocr.py $output_dir
# Draw output and generate list
python gen-outputs.py $input_dir $output_dir > $csv_file
# Clean files and draw output
rm $output_dir/*_lp.png
rm $output_dir/*car.png
rm $output_dir/*_cars.txt
rm $output_dir/*_lp.txt
rm $output_dir/*_str.txt