Skip to content
Browse files

calibrate: update params to include lens and sensor width

  • Loading branch information...
1 parent b535dee commit 5243d705ae62d69c7b370bd5573c15d661094787 @mridley mridley committed with Jul 14, 2012
Showing with 11 additions and 3 deletions.
  1. +8 −3 camera/camera.py
  2. +3 −0 uav/uav.py
View
11 camera/camera.py
@@ -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
@@ -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()
@@ -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'])
View
3 uav/uav.py
@@ -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;

0 comments on commit 5243d70

Please sign in to comment.
Something went wrong with that request. Please try again.