Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 22, 2024
1 parent 635b9de commit 7d5afb2
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 249 deletions.
9 changes: 7 additions & 2 deletions src/b3d/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def from_array(cls, intrinsics: Array):
def as_array(self):
"""Returns intrinsics as a float array."""
return jnp.array(self)

def downscale(self, factor):
return Intrinsics(
self.width // factor,
Expand Down Expand Up @@ -122,7 +122,9 @@ def camera_from_depth(z: DepthImage, intrinsics) -> CameraCoordinates:
unproject_depth = camera_from_depth


def screen_from_camera(xyz: CameraCoordinates, intrinsics, culling=False) -> ScreenCoordinates:
def screen_from_camera(
xyz: CameraCoordinates, intrinsics, culling=False
) -> ScreenCoordinates:
"""
Maps to sensor coordintaes `uv` from camera coordinates `xyz`, which are
defined by $(u,v) = (u'/z,v'/z)$, where
Expand Down Expand Up @@ -159,10 +161,12 @@ def screen_from_world(x, cam, intr, culling=False):
"""Maps to screen coordintaes `uv` from world coordinates `xyz`."""
return screen_from_camera(cam.inv().apply(x), intr, culling=culling)


def world_from_screen(uv, cam, intr):
"""Maps to world coordintaes `xyz` from screen coords `uv`."""
return cam.apply(camera_from_screen(uv, intr))


def camera_matrix_from_intrinsics(intr: Intrinsics) -> CameraMatrix3x3:
"""
Returns a 3x3 camera matrix following the OpenCV convention, ie.
Expand Down Expand Up @@ -219,6 +223,7 @@ def homogeneous_coordinates(xs, z=jnp.array(1.0)):
"""
return jnp.concatenate([xs, jnp.ones_like(xs[..., :1])], axis=-1) * z[..., None]


homogeneous = homogeneous_coordinates


Expand Down
1 change: 0 additions & 1 deletion src/b3d/chisight/sfm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .eight_point import *
from .epipolar import *

Loading

0 comments on commit 7d5afb2

Please sign in to comment.