-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (63 loc) · 2.04 KB
/
main.py
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
import argparse
import components
modello = [
".\\mpi\\pose_iter_160000.caffemodel",
".\\mpi\\pose_deploy_linevec_faster_4_stages.prototxt",
]
def main():
parser = argparse.ArgumentParser(description="Process images")
parser.add_argument(
"--videoIn",
"-i",
type=str,
help="relative or absolute path to an image to ingest, if omitted default to the camera",
)
parser.add_argument(
"--videoOut",
"-o",
type=str,
help="path to the output image, if omitted an image will pop up.\nIn case you have given a directory with -d it will be the (requested) output directory",
)
parser.add_argument(
"--dir",
"-d",
type=str,
help="select a directory to process (overrides -i), -o behaviour changes to the output directory's name (requested)",
)
parser.add_argument(
"-m",
default=False,
action="store_true",
help="multiple people detection, default to single detection",
)
parser.add_argument(
"-g",
default=False,
action="store_true",
help="use GPU acceleration, default CPU only",
)
parser.add_argument(
"-p",
default=False,
action="store_true",
help="private mode: cover all detected faces",
)
args = parser.parse_args()
# get Requested Model
model = components.model_factory(args.m, args.g, modello[0], modello[1])
# get Requested Painter
painter = components.painter_factory(args.p)
# run detections depending on the arguments
if args.dir:
components.dir_run(model, painter, args.dir, args.videoOut)
elif args.videoIn and args.videoOut:
components.file_run(model, painter, args.videoIn, args.videoOut)
elif args.videoIn:
components.file_run_monitor(model, painter, args.videoIn)
elif not args.videoIn and args.videoOut:
parser.print_help()
exit(-1)
else:
components.webcam_run_monitor(model, painter)
if __name__ == "__main__":
main()