blenderproc.python.postprocessing.StereoGlobalMatching module

Use stereo global matching to calculate an distance image.

class blenderproc.python.postprocessing.StereoGlobalMatching._StereoGlobalMatching[source]

Bases: object

static fill_in_fast(depth_map, max_depth=100.0, custom_kernel=None, extrapolate=False, blur_type='bilateral')[source]

Fast, in-place depth completion.

Parameters:
  • depth_map (ndarray) – projected depths

  • max_depth (float) – max depth value for inversion

  • custom_kernel (Optional[ndarray]) – kernel to apply initial dilation

  • extrapolate (bool) – whether to extrapolate by extending depths to top of the frame, and applying a 31x31 full kernel dilation

  • blur_type (str) – ‘bilateral’ - preserves local structure (recommended), ‘gaussian’ - provides lower RMSE

Returns:

depth_map: dense depth map

static stereo_global_matching(left_color_image, right_color_image, baseline, depth_max, focal_length, window_size=7, num_disparities=32, min_disparity=0, disparity_filter=True, depth_completion=True)[source]

Semi global matching funciton, for more details on what this function does check the original paper https://elib.dlr.de/73119/1/180Hirschmueller.pdf

Parameters:
  • left_color_image (ndarray) – The left color image.

  • right_color_image (ndarray) – The right color image.

  • baseline (float) – The baseline that was used for rendering the two images.

  • depth_max (float) – The maximum depth value for clipping the resulting depth values.

  • focal_length (float) – The focal length that was used for rendering the two images.

  • window_size (int) – Semi-global matching kernel size. Should be an odd number.

  • num_disparities (int) – Semi-global matching number of disparities. Should be > 0 and divisible by 16.

  • min_disparity (int) – Semi-global matching minimum disparity.

  • disparity_filter (bool) – Applies post-processing of the generated disparity map using WLS filter.

  • depth_completion (bool) – Applies basic depth completion using image processing techniques.

Return type:

Tuple[ndarray, ndarray]

Returns:

depth, disparity

blenderproc.python.postprocessing.StereoGlobalMatching.stereo_global_matching(color_images, depth_max=None, window_size=7, num_disparities=32, min_disparity=0, disparity_filter=True, depth_completion=True)[source]

Does the stereo global matching in the following steps: 1. Collect camera object and its state, 2. For each frame, load left and right images and call the sgm() methode. 3. Write the results to a numpy file.

Parameters:
  • color_images (List[ndarray]) – A list of stereo images, where each entry has the shape [2, height, width, 3].

  • depth_max (Optional[float]) – The maximum depth value for clipping the resulting depth values. If None, distance_start + distance_range that were configured for distance rendering are used.

  • window_size (int) – Semi-global matching kernel size. Should be an odd number.

  • num_disparities (int) – Semi-global matching number of disparities. Should be > 0 and divisible by 16.

  • min_disparity (int) – Semi-global matching minimum disparity.

  • disparity_filter (bool) – Applies post-processing of the generated disparity map using WLS filter.

  • depth_completion (bool) – Applies basic depth completion using image processing techniques.

Return type:

Tuple[List[ndarray], List[ndarray]]

Returns:

Returns the computed depth and disparity images for all given frames.