Sensor

This module provides utilities to simulate a camera sensor and obtain its specifications (resolution, pixel size, diagonal).

On the roadmap:

  • Couple VirtualSensor with lens / mask / aperture.

  • Add noise to VirtualSensor.

  • Set object height VirtualSensor.

  • Similar class as VirtualSensor for “real” sensors to capture images.

Virtual Sensor

class lensless.hardware.sensor.VirtualSensor(pixel_size, resolution, diagonal=None, color=True, bit_depth=None, downsample=None, **kwargs)[source]

Virtual sensor class to simulate capturing a scene.

__init__(pixel_size, resolution, diagonal=None, color=True, bit_depth=None, downsample=None, **kwargs)[source]

Base constructor.

Parameters
  • pixel_size (array-like or float) – 2D pixel size in meters.

  • resolution (array-like) – 2D resolution in pixels.

  • diagonal (float, optional) – Diagonal size in meters.

  • color (bool, optional) – Whether the sensor is color or monochrome.

  • bit_depth (list, optional) – List of supported bit depths.

  • downsample (int, optional) – Downsample the sensor by this factor. Pixel size and resolution are adjusted accordingly.

capture(scene=None, bit_depth=None, bayer=False)[source]

Virtual capture of a scene (assuming perfectly focused lens).

Parameters
  • scene (ndarray, str, optional) – Scene to capture.

  • bit_depth (int, optional) – Bit depth of the image. By default, use first available.

  • bayer (bool, optional) – Whether to return a Bayer image or not. By default, return RGB (if color).

Returns

img – Captured image.

Return type

ndarray

downsample(factor)[source]

Downsample the sensor by a given factor. Pixel size and resolution are adjusted accordingly.

Parameters

factor (int) – Downsample factor.

classmethod from_name(name, downsample=None)[source]

Create a sensor from one of the available options in SensorOptions.

Parameters

name (str) – Name of the sensor.

Returns

sensor – Sensor.

Return type

VirtualSensor