Skip to content
Snippets Groups Projects
Commit 8f16831f authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

python: params from K

parent 50ddf5c9
No related branches found
No related tags found
No related merge requests found
import numpy as np import numpy as np
from . ftltype import Camera
def get_camera_matrix(calib): def get_camera_matrix(calib):
K = np.identity(3, dtype=np.float64) K = np.identity(3, dtype=np.float64)
...@@ -41,6 +42,12 @@ def depth_to_disparity(depth, camera, invalid_value=0.0): ...@@ -41,6 +42,12 @@ def depth_to_disparity(depth, camera, invalid_value=0.0):
return disparity return disparity
class Calibration: class Calibration:
@staticmethod
def from_K(K, size, min_depth=0.0, max_depth=100.0, baseline=0.0, doff=0.0):
calib = Camera._make([K[0,0], K[1,1], K[0,2], K[1,2], size[1], size[0],
min_depth, max_depth, baseline, doff])
return Calibration(calib, None, None)
def __init__(self, calib, channel, capabilities): def __init__(self, calib, channel, capabilities):
self._calib = calib self._calib = calib
self._capabilities = capabilities self._capabilities = capabilities
...@@ -64,7 +71,7 @@ def point3d(calib, u, v, d): ...@@ -64,7 +71,7 @@ def point3d(calib, u, v, d):
return np.array([(u+calib.cx)*d/calib.fx, (v+calib.cy)*d / calib.fy, d], dtype=np.float) return np.array([(u+calib.cx)*d/calib.fx, (v+calib.cy)*d / calib.fy, d], dtype=np.float)
def depth_image_to_3D(depth, calib): def depth_image_to_3d(depth, calib):
""" Calculate 3D points from depth image and calibration paramters """ Calculate 3D points from depth image and calibration paramters
@param depth depth image @param depth depth image
@param calib calibration paramters @param calib calibration paramters
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment