-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
78 lines (61 loc) · 2.11 KB
/
models.py
File metadata and controls
78 lines (61 loc) · 2.11 KB
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
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import datetime
import numpy as np
class Camera:
"""Data class to store camera details
"""
def __init__(self, cameraId: int, location: str, uri: str):
"""Initialize camera object
Args:
cameraId (int): Id for camera
location (str): Location where camera is installed
uri (str): streaming url for camera
"""
self.cameraId = cameraId
self.location = location
self.uri = uri
def get_stream(self):
return self.uri
def get_id(self):
return self.cameraId
def get_location(self):
return self.location
def __format__(self,format):
if format == 'loc':
return "{}({!r})".format(self.__class__.__name__,self.location)
else:
return "{}({!r})".format(self.__class__.__name__,self.cameraId)
def __repr__(self):
return '{}({!r})'.format(self.__class__.__name__, self.cameraId)
class Frame():
"""Data class to store frame details
"""
def __init__(self, camera: Camera, timestamp: datetime.datetime, array: np.ndarray, shape: tuple):
"""Iniitalize Frame objecct
Args:
camera (Camera): Camera from which frame was catputed
timestamp (datetime.datetime): timestamp when frame was captured
array (np.ndarray): captured frame
shape (tuple): shape of frame's array
"""
self.camera = camera
self.timestamp = timestamp
self.array = array
self.shape = shape
def get_camera(self):
return self.camera
def numpy(self):
return self.array
def datetime(self):
return self.timestamp
def get_shape(self):
return self.shape
def get_timestamp_fmt(self):
"""returns timestamp string
Returns:
str: timestamp string
"""
return self.timestamp.isoformat(sep=' ', timespec='milliseconds')
def __repr__(self):
return "{}( {}, {!r})".format(self.__class__.__name__, self.camera, self.get_timestamp_fmt())