Pinhole Lens
In this tutorial you will get familiar with Pinhole Lens, which is a sensor that projects 3D points on the scene
to the image plane with perspective transformation. It is the most used type of lens, as its mechanism is the same
as in the human eye or commonly used cameras.
Agenda:
- PinholeLens basic usage
Scene setup
Let's use custom scene composer to set up the scene.
from skyrenderer.cases.utils import SensorSceneComposer
scene_composer = SensorSceneComposer(antialiasing_level=2048)
scene_composer.setup_scene(camera_position=[0, 0, 15])
renderer_context = scene_composer.renderer_context
2025-02-04 13:07:21,062 | skyrenderer.scene.renderer_context | INFO: Root paths:
- root path: /dli/skyenvironment/skyrenderer/skyrenderer
- assets path: /dli/mount/assets
- config path: /dli/skyenvironment/skyrenderer/skyrenderer/config
- gpu sources path: /dli/skyenvironment/skyrenderer/skyrenderer/optix_sources/sources
- cache path: /dli/mount/cache
- ptx cache path: compiled_ptx/ptx
- ocio path: ocio_configs/aces_1.2/config.ocio
PinholeLens basic usage
In this tutorial we will present only basic usage of the PinholeLens. For more information about the parameters
of the PinholeLens, check out SENSOR_PinholeLensParameters tutorial and PinholeLens class documentation.
PinholeLens setup and visualization
Lens is one of the parameters of the CameraRenderStep class which is the base class of all cameras in SkyRenderer,
thus we can easily change lens model of the camera separately from overall camera definition.
from skyrenderer.render_chain import RenderChain, VisibleLightRenderStep, Denoiser
from skyrenderer.render_chain.camera_steps.Lens.pinhole_lens import PinholeLens
lens = PinholeLens(renderer_context)
rs = VisibleLightRenderStep(
renderer_context,
lens=lens,
origin_name="camera_CAM_NUL",
target_name="top_node",
)
renderer_context.define_render_chain(
RenderChain(render_steps=[rs, Denoiser(renderer_context)], width=1400, height=900)
)
scene_composer.visualize()
2025-02-04 13:07:21,518 | skyrenderer.utils.time_measurement | INFO: Setup time: 409 ms
2025-02-04 13:07:22,122 | skyrenderer.utils.time_measurement | INFO: Context update time: 603 ms
2025-02-04 13:07:23,199 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms
2025-02-04 13:07:23,200 | skyrenderer.utils.time_measurement | INFO: Render time: 1.08 seconds
Summary
In this section you have learnt:
- Pinhole camera lens is the model of lens most commonly used in real world to transform 3D position to 2D image
coordinate. - PinholeLens in SkyRenderer is the parameter of CameraRenderStep (and, by extension, VisibleLightRenderStep).