Created
August 1, 2018 00:40
-
-
Save stevenhao/7115a7349c89353a738f6a324f365d4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vector3(): | |
def __init__(self, x, y, z): | |
self.x = x | |
self.y = y | |
self.z = z | |
def to_obj(self): | |
return { | |
'x': self.x, | |
'y': self.y, | |
'z': self.z, | |
} | |
class Vector4(): | |
def __init__(self, x, y, z, i, is_ground = None): | |
self.x = x | |
self.y = y | |
self.z = z | |
self.i = i | |
def to_obj(self): | |
return { | |
'x': self.x, | |
'y': self.y, | |
'z': self.z, | |
'i': self.i, | |
} | |
# optional params | |
if self.is_ground != None: | |
obj['is_ground'] = self.is_ground | |
return obj | |
class Quaternion(): | |
def __init__(self, x, y, z, w): | |
self.x = x | |
self.y = y | |
self.z = z | |
self.w = w | |
def to_obj(self): | |
return { | |
'x': self.x, | |
'y': self.y, | |
'z': self.z, | |
'w': self.w, | |
} | |
class GPSPose(): | |
def __init__(self, lat, lon, bearing): | |
self.lat = lat | |
self.lon = lon | |
self.bearing = bearing | |
def to_obj(self): | |
return { | |
'lat': self.lat, | |
'lon': self.lon, | |
'bearing': self.bearing, | |
} | |
class CameraImage(): | |
def __init__(self, image_url, scale_factor, position, heading, fx, fy, cx, cy, skew, k1, k2, k3, p1, p2, priority = None, timestamp = None): | |
self.image_url = image_url | |
self.scale_factor = scale_factor | |
self.position = position | |
self.heading = heading | |
self.fx = fx | |
self.fy = fy | |
self.cx = cx | |
self.cy = cy | |
self.skew = skew | |
self.k1 = k1 | |
self.k2 = k2 | |
self.k3 = k3 | |
self.p1 = p1 | |
self.p2 = p2 | |
self.priority = priority | |
self.timestamp = timestamp | |
def to_obj(self): | |
obj = { | |
'image_url': self.image_url, | |
'scale_factor': self.scale_factor, | |
'position': self.position.to_obj(), | |
'heading': self.heading.to_obj(), | |
'fx': self.fx, | |
'fy': self.fy, | |
'cx': self.cx, | |
'cy': self.cy, | |
'skew': self.skew, | |
'k1': self.k1, | |
'k2': self.k2, | |
'k3': self.k3, | |
'p1': self.p1, | |
'p2': self.p2, | |
} | |
# optional params | |
if self.priority != None: | |
obj['priority'] = self.priority | |
if self.timestamp != None: | |
obj['timestamp'] = self.timestamp | |
return obj | |
class Frame(): | |
def __init__(self, device_position, points, radar_points = None, images = None, timestamp = None, device_heading = None, device_gps_pose = None): | |
self.device_position = device_position | |
self.points = points | |
self.radar_points = radar_points | |
self.images = images | |
self.timestamp = timestamp | |
self.device_heading = device_heading | |
self.device_gps_pose = device_gps_pose | |
def to_obj(self): | |
obj = { | |
'device_position': self.device_position.to_obj(), | |
'points': [point.to_obj() for point in self.points], | |
} | |
## optional params | |
if self.images != None: | |
obj['images'] = [image.to_obj() for image in self.images] | |
# TODO the rest of the optional params | |
return obj | |
def format(self): | |
return json.dumps(self.to_obj()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment