cars.externals.otb_pipelines

OTB Pipelines module: contains functions that builds Orfeo ToolBox pipelines used by CARS Refacto: Split function in generic externals calls through functional steps interfaces (epipolar rectification, …)

Module Contents

Functions

build_extract_roi_application(img, region)

This function builds a ready to use instance of the ExtractROI application

build_mask_pipeline(input_img, input_mask, ...)

This function builds a pipeline that computes and

build_bundletoperfectsensor_pipeline(pan_img, ms_img)

This function builds the a pipeline that performs P+XS pansharpening

build_image_resampling_pipeline(img, grid, ...[, ...])

This function builds a pipeline that resamples images in epipolar geometry

get_utm_zone_as_epsg_code(lon, lat)

Returns the EPSG code of the UTM zone where the lat, lon point falls in

read_lowres_dem(startx, starty, sizex, sizey[, dem, ...])

Read an extract of the low resolution input DSM and return it as an Array

epipolar_sparse_matching(→ numpy.ndarray)

Compute SIFT using vlfeat and performs epipolar sparse matching

cars.externals.otb_pipelines.build_extract_roi_application(img, region)

This function builds a ready to use instance of the ExtractROI application

Parameters
  • img (otb::Image pointer) – Pointer to the OTB image to extract

  • region (list of 4 int (xmin, ymin, xmax, ymax)) – Extraction region

Returns

(extracted image, roi application) tuple

Return type

ready to use instance of the ExtractROI application

cars.externals.otb_pipelines.build_mask_pipeline(input_img, input_mask, input_nodata, out_nodata, out_valid_value, grid, epipolar_size_x, epipolar_size_y, roi)

This function builds a pipeline that computes and resampled image mask in epipolar geometry

Parameters
  • input_img – Path to the left input image

  • input_mask – Path to left image mask or None

  • input_nodata (float) – Pixel value to be treated as nodata in image or None

  • out_nodata (float) – Pixel value used for the ouput

  • out_valid_value – Pixel value for valid points in mask

  • grid (otb::Image pointer or string) – The stereo-rectification rectification grid

  • epipolar_size_x (int) – Size of stereo-rectified images in x

  • epipolar_size_y (int) – Size of stereo-rectified images in y

  • roi (list of 4 int (xmin, ymin, xmax, ymax)) – Region over which to compute epipolar mask or None

Typ out_valid_value

float

Returns

mask

Return type

resampled mask as numpy array

cars.externals.otb_pipelines.build_bundletoperfectsensor_pipeline(pan_img, ms_img)

This function builds the a pipeline that performs P+XS pansharpening

Parameters
  • pan_img (string) – Path to the panchromatic image

  • ms_img (string) – Path to the multispectral image

Returns

resample_image

Return type

otb application

cars.externals.otb_pipelines.build_image_resampling_pipeline(img, grid, epipolar_size_x, epipolar_size_y, roi, lowres_color=None)

This function builds a pipeline that resamples images in epipolar geometry

Parameters
  • img (string) – Path to the left image

  • grid (otb::Image pointer or string) – The stereo-rectification rectification grid

  • epipolar_size_x (int) – Size of stereo-rectified images in x

  • epipolar_size_y (int) – Size of stereo-rectified images in y

  • roi (list of 4 int (xmin, ymin, xmax, ymax)) – Region over which to compute epipolar images, or None

  • lowres_color (string) – Path to the low resolution color image

Returns

resampled image

Return type

resampled image as numpy array

cars.externals.otb_pipelines.get_utm_zone_as_epsg_code(lon, lat)

Returns the EPSG code of the UTM zone where the lat, lon point falls in TODO: refacto with externals (OTB)

Parameters
  • lon (float) – longitude of the point

  • lat (float) – lattitude of the point

Returns

The EPSG code corresponding to the UTM zone

Return type

int

cars.externals.otb_pipelines.read_lowres_dem(startx, starty, sizex, sizey, dem=None, default_alt=None, geoid=None, resolution=0.000277777777778)

Read an extract of the low resolution input DSM and return it as an Array

Parameters
  • startx (float) – Upper left x coordinate for grid in WGS84

  • starty (float) – Upper left y coordinate for grid in WGS84 (remember that values are decreasing in y axis)

  • sizex (int) – Size of grid in x direction

  • sizey (int) – Size of grid in y direction

  • dem (string) – DEM directory

  • default_alt (float) – Default altitude above ellipsoid

  • geoid (str) – path to geoid file

  • resolution (float) – Resolution (in degrees) of output raster

Returns

The extract of the lowres DEM as an xarray.Dataset

Return type

xarray.Dataset

cars.externals.otb_pipelines.epipolar_sparse_matching(ds1: xarray.Dataset, roi1: List[int], size1: List[int], origin1: List[float], ds2: xarray.Dataset, roi2: List[int], size2: List[int], origin2: List[float], matching_threshold: float, n_octave: int, n_scale_per_octave: int, dog_threshold: int, edge_threshold: int, magnification: float, backmatching: bool) numpy.ndarray

Compute SIFT using vlfeat and performs epipolar sparse matching

Parameters
  • ds1 – epipolar image 1 dataset

  • roi1 – roi to use for image 1

  • size1 – full epipolar image 1 size

  • origin1 – origin of full epipolar image 1

  • ds2 – epipolar image 2 dataset

  • roi2 – roi to use for image 2

  • size2 – full epipolar image 2 size

  • origin2 – origin of full epipolar image 2

  • matching_threshold – matching threshold to use in vlfeat

  • n_octave – number of octaves to use in vlfeat

  • n_scale_per_octave – number of scales per octave to use in vlfeat

  • dog_threshold – difference of gaussians threshold to use in vlfeat

  • edge_threshold – edge threshold to use in vlfeat

  • magnification – magnification value to use in vlfeat

  • backmatching – activation status of the back matching in vlfeat

Returns

matches as numpy array