-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (43 loc) · 1.79 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
import argparse
import yaml
from func.mark_coordinates import Coordinates
from spot_occupancy import SpotOccupancy
import logging
RED = (255, 0, 0)
def main():
args = parse_args()
image_file = args.image_config
data_file = args.coords_file
start_frame = args.start_frame
"""First, parking spaces will be marked on the frame from the video and saved in config file"""
if image_file is not None:
with open(data_file, "w+") as points:
generator = Coordinates(image_file, points, RED)
generator.generate()
"""Second, an interface will be launched to detect whether the marked parking space is free or occupied"""
with open(data_file, "r") as data:
points = yaml.load(data, yaml.FullLoader)
detector = SpotOccupancy(args.video_path, points, int(start_frame))
detector.detect_car_on_marked_spot()
def parse_args():
parser = argparse.ArgumentParser(description='Generates Coordinates File')
parser.add_argument("--image",
dest="image_config",
required=False,
help="Frame from video to generate coordinates on")
parser.add_argument("--video",
dest="video_path",
required=True,
help="Video file to detect motion on")
parser.add_argument("--data",
dest="coords_file",
required=True,
help="Data file to be used with OpenCV")
parser.add_argument("--start-frame",
dest="start_frame",
required=False,
default=1,
help="Starting frame on the video")
return parser.parse_args()
if __name__== '__main__':
main()