-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
converting fisheye to rectilinear image #27
Comments
Hello TaheraTT, Here is an example, how to do it: class PinholeLens(Projection):
def __init__(self, focal_length: typing.Union[float, list]):
self.focal_length = focal_length if isinstance(focal_length, (float, int)) else focal_length[0]
self.K = np.array([self.focal_length, self.focal_length, 1], dtype=float)
def project_3d_to_2d(self, cam_points, invalid_value=np.nan):
camera_points = ensure_point_list(cam_points, dim=3)
camera_points = camera_points * self.K
zs = camera_points[:, 2][:, np.newaxis]
uv = np.divide(camera_points[:, 0:2], zs, where=(zs != 0))
# mark points behind the camera (z <= 0) as invalid
uv[camera_points[:, 2] <= 0] = [invalid_value, invalid_value]
return uv
def project_2d_to_3d(self, image_points: np.ndarray, norms: np.ndarray):
image_points = ensure_point_list(image_points, dim=3)
norms = ensure_point_list(norms, dim=1)
xy_normed = image_points / self.K
xy_normed_norm = np.linalg.norm(np.array(xy_normed), axis=1)
z = norms / xy_normed_norm[:, np.newaxis]
return z * xy_normed Best regards, |
Thanks for the answer Christian. I am able to solve the issue now. Best Regards |
Hello Tahera, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code shared in projection.py gives cylindrical image as output. I am trying to convert the fisheye image to rectilinear image. Can someone guide me on how to do that.
The text was updated successfully, but these errors were encountered: