-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRotation.py
More file actions
46 lines (40 loc) · 1.73 KB
/
Copy pathRotation.py
File metadata and controls
46 lines (40 loc) · 1.73 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
import ConfigParser
import math
import numpy as np
class Rotation():
"""Calculate Rotation"""
def __init__(self, track):
cf = ConfigParser.ConfigParser()
cf.read("VO.conf")
self.cx = cf.get("CameraParameters", "cx")
self.fx = cf.get("CameraParameters", "fx")
self.sky = int(cf.get("Boundary", "skyregionbottom"))
self.RotationIncrements = []
self.m_HeadingChange = 0
def run(self, track):
trackedF = track
featuresNum = len(trackedF)
self.RotationIncrements = []
for i in xrange(featuresNum):
if len(trackedF[i]) < 5:
continue
try:
previousFeatureLocation = trackedF[i][-1]
currentFeatureLocation = trackedF[i][0]
except IndexError:
continue
if currentFeatureLocation[1] < self.sky:
previousAngularPlacement = math.atan2(
np.float32(previousFeatureLocation[0]).item() - float(self.cx), float(self.fx))
currentAngularPlacement = math.atan2(
np.float32(currentFeatureLocation[0]).item() - float(self.cx), float(self.fx))
rotationIncrement = currentAngularPlacement - previousAngularPlacement
self.RotationIncrements.append(rotationIncrement)
if len(self.RotationIncrements) > 0:
meanRotationIncrement = self.GetRotationIncrements()
self.m_HeadingChange = meanRotationIncrement
def GetRotationIncrements(self):
self.RotationIncrements.sort()
return(math.degrees(self.RotationIncrements[len(self.RotationIncrements) // 2]) / 15)
def GetRad(self):
return(math.radians(self.m_HeadingChange))