forked from bailus/tsai-calibration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoint.py
22 lines (17 loc) · 765 Bytes
/
point.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python
###
#
# A Point holds a set of (homogeneous or cartesian) coordinates -
# each defines the position of the point in the appropriate basis.
# Author: Samuel Bailey <sam@bailey.geek.nz>
#
###
from collections import namedtuple
# we're going to be using points a lot, so a namedtuple should give better performance than a hashmap
def makePointClass():
pointSchema = ['world', 'camera', 'pixel', 'projectedPixel', 'distortedPixel', 'sensor', 'projectedSensor',
'distortedSensor']
Point = namedtuple('Point', pointSchema)
defaultPoint = Point(*map(lambda x: None, range(len(pointSchema))))
return Point, lambda dict: defaultPoint._replace(**dict)
Point, newPoint = makePointClass()