Skip to content

Commit

Permalink
Fix camera and projector extrinsics in 3dScene (#183)
Browse files Browse the repository at this point in the history
* fix camera object extrinsics

* fix camera projection

* Update rosys/vision/camera_projector.py

---------

Co-authored-by: Falko Schindler <[email protected]>
  • Loading branch information
pascalzauberzeug and falkoschindler authored Aug 27, 2024
1 parent df9a32f commit 8321a69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 5 additions & 3 deletions rosys/vision/camera_objects_.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self,
*,
px_per_m: float = 10000,
debug: bool = False,
interval: float = 1.0
) -> None:
super().__init__()

Expand All @@ -33,7 +34,7 @@ def __init__(self,
self.textures: dict[str, Texture] = {}
self.image_shrink_factor = 2

ui.timer(1.0, self.update)
ui.timer(interval, self.update)

@property
def calibrated_cameras(self) -> dict[str, CalibratableCamera]:
Expand Down Expand Up @@ -72,8 +73,9 @@ async def update_cameras(self) -> None:
camera.calibration.intrinsics.size.height / self.px_per_m,
camera.calibration.intrinsics.matrix[0][0] / self.px_per_m,
)
camera_groups[uid].move(*camera.calibration.extrinsics.translation)
camera_groups[uid].rotate_R(camera.calibration.extrinsics.resolve().rotation.R)
world_extrinsics = camera.calibration.extrinsics.resolve()
camera_groups[uid].move(*world_extrinsics.translation)
camera_groups[uid].rotate_R(world_extrinsics.rotation.R)

async def update_images(self) -> None:
newest_images = [camera.latest_captured_image
Expand Down
6 changes: 2 additions & 4 deletions rosys/vision/camera_projector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class CameraProjector:
It is mainly used for visualization purposes.
"""

def __init__(self, camera_provider: CalibratableCameraProvider) -> None:
def __init__(self, camera_provider: CalibratableCameraProvider, *, interval: float = 1.0) -> None:
self.camera_provider = camera_provider

self.projections: dict[str, Projection] = {}

rosys.on_repeat(self.step, 1.0)
rosys.on_repeat(self.step, interval)

async def step(self) -> None:
for id_ in list(self.projections):
Expand All @@ -39,8 +39,6 @@ async def step(self) -> None:
for id_, camera in self.camera_provider.cameras.items():
if not camera.calibration:
continue
if id_ in self.projections and self.projections[id_].camera_calibration == camera.calibration:
continue
self.projections[id_] = Projection(
camera_id=id_,
camera_calibration=deepcopy(camera.calibration),
Expand Down

0 comments on commit 8321a69

Please sign in to comment.