simsense_depth

Get depth image from stereo IR images using simsense

class real_robot.sensors.simsense_depth.SimsenseDepth(ir_size: tuple[int, int], k_l: ndarray, k_r: ndarray, l2r: ndarray, k_rgb: ndarray | None = None, rgb_size: tuple[int, int] | None = None, l2rgb: ndarray | None = None, min_depth: float = 0.0, max_depth: float = 10.0, ir_noise_seed: int = 0, speckle_shape: float = 0.0, speckle_scale: float = 0.0, gaussian_mu: float = 0.0, gaussian_sigma: float = 0.0, rectified: bool = False, census_width: int = 7, census_height: int = 7, max_disp: int = 128, block_width: int = 7, block_height: int = 7, p1_penalty: int = 7, p2_penalty: int = 86, uniqueness_ratio: int = 15, lr_max_diff: int = 1, median_filter_size: int = 3, depth_dilation: bool = False)[source]

Bases: object

compute(img_l: ndarray, img_r: ndarray) ndarray[source]

Take two images captured by a pair of nearby parallel cameras, and output the computed depth map in meters.

Parameters:
  • img_l – Grayscale/infrared image (uint8) captured by left camera.

  • img_r – Grayscale/infrared image (uint8) captured by right camera.

Returns:

Computed depth map (in meters) from left camera’s view or rgb camera’s view.

set_census_window_size(census_width: int, census_height: int) None[source]
Parameters:
  • census_width – Width of the center-symmetric census transform window. This must be an odd number.

  • census_height – Height of the center-symmetric census transform window. This must be an odd number.

set_ir_noise_parameters(speckle_shape: float, speckle_scale: float, gaussian_mu: float, gaussian_sigma: float) None[source]
Parameters:
  • speckle_shape – Shape parameter for simulating infrared speckle noise (Gamma distribution). Set to 0 to disable noise simulation

  • speckle_scale – Scale parameter for simulating infrared speckle noise (Gamma distribution).

  • gaussian_mu – Mean for simulating infrared thermal noise (Gaussian distribution).

  • gaussian_sigma – Standard deviation for simulating infrared thermal noise (Gaussian distribution).

set_lr_max_diff(lr_max_diff: int) None[source]
Parameters:

lr_max_diff – Maximum allowed difference in the left-right consistency check. Set it to 255 to disable the check.

set_matching_block_size(block_width: int, block_height: int) None[source]
Parameters:
  • block_width – Width of the matched block. This must be an odd number.

  • block_height – Height of the matched block. This must be an odd number.

set_penalties(p1_penalty: int, p2_penalty: int) None[source]
Parameters:
  • p1_penalty – P1 penalty for semi-global matching algorithm.

  • p2_penalty – P2 penalty for semi-global matching algorithm.

set_uniqueness_ratio(uniqueness_ratio: int) None[source]
Parameters:

uniqueness_ratio – Margin in percentage by which the minimum computed cost should win the second best (not considering best match’s adjacent pixels) cost to consider the found match valid.