forked from Pranav1007/Social-Distance-Detector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
61 lines (48 loc) · 1.65 KB
/
run.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
#!/usr/bin/python3
from utilities.helper import video, image, webcam
import mimetypes
from os import path
import sys
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--media", help="Media Type (image(or i), video(or v), webcam(or w))")
parser.add_argument("-p", "--path", help="Path of the Media File (For webcam enter space)")
args = parser.parse_args()
s = args.media
p = args.path
if p is None or s is None:
print('usage: run.py [-h] [-m MEDIA] [-p PATH]')
sys.exit(2)
s = str(s).lower()
p = str(p)
if s == "i" or s == "image":
if(path.exists(p)):
if mimetypes.guess_type(p)[0].startswith('image'):
print("Hit 'q' to exit")
image(p)
else:
print("Entered Path is correct but invalid media type. Please Try Again.")
sys.exit(2)
else:
print("Entered Path is invalid. Please Try Again")
sys.exit(2)
elif s == "v" or s == "video":
if(path.exists(p)):
if mimetypes.guess_type(p)[0].startswith('video'):
print("Hit 'q' to exit")
video(p)
else:
print("Entered Path is correct but invalid media type. Please Try Again.")
sys.exit(2)
else:
print("Entered Path is invalid. Please Try Again")
sys.exit(2)
elif s == "w" or s == "webcam":
print("Hit 'q' to exit")
webcam()
else:
print("Invalid Media Type. Allowed Types: image, video, webcam")
sys.exit(2)
if __name__ == '__main__':
main()