Skip to content

Commit

Permalink
calibrate: update params to include lens and sensor width
Browse files Browse the repository at this point in the history
  • Loading branch information
mridley authored and Andrew Tridgell committed Jul 17, 2012
1 parent b535dee commit 5243d70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
class CameraParams:
# A default constructor based on sensor and lens specs only
def __init__(self, lens=4.0, sensorwidth=5.0, xresolution=1280, yresolution=960):
# self.sensorwidth = 5.0
self.version = 0
self.xresolution = 1280
self.yresolution = 960
self.sensorwidth = sensorwidth
self.lens = lens
self.xresolution = xresolution
self.yresolution = yresolution

# compute focal length in pixels
f_p = xresolution * lens / sensorwidth
Expand All @@ -36,6 +37,8 @@ def setParams(self, K, D):
def todict(self):
data = {}
data['version'] = self.version
data['lens'] = self.lens
data['sensorwidth'] = self.sensorwidth
data['xresolution'] = self.xresolution
data['yresolution'] = self.yresolution
data['K'] = self.K.tolist()
Expand All @@ -45,6 +48,8 @@ def todict(self):
def fromdict(self, data):
self.version = data['version']
if self.version == 0:
self.lens = data['lens']
self.sensorwidth = data['sensorwidth']
self.xresolution = data['xresolution']
self.yresolution = data['yresolution']
self.K = array(data['K'])
Expand Down
3 changes: 3 additions & 0 deletions uav/uav.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class uavxfer:

def setCameraParams(self, fu, fv, cu, cv):
K = array([[fu, 0.0, cu],[0.0, fv, cv],[0.0, 0.0, 1.0]])
self.setCameraMatrix(K)

def setCameraMatrix(self, K):
K_i = linalg.inv(K)
self.Tk = eye(4,4)
self.Tk[:3,:3] = K;
Expand Down

0 comments on commit 5243d70

Please sign in to comment.