pyorc.CrossSection.detect_water_level_s2n#

CrossSection.detect_water_level_s2n(img: np.ndarray, bank: BANK_OPTIONS = 'far', bin_size: int = 5, length: float = 2.0, padding: float = 0.5, offset: float = 0.0, ds_max: Optional[float] = 0.5, dz_max: Optional[float] = 0.02, min_h: Optional[float] = None, max_h: Optional[float] = None, min_z: Optional[float] = None, max_z: Optional[float] = None) float[source]#

Detect water level optically from provided image, through evaluation of a vector of locations.

Water level detection is done by first detecting the water line along the cross-section by comparisons of distribution functions left and right of hypothesized water lines, and then looking up the water level associated with the water line location. Because a full vector of results is evaluated, the signal to noise ratio can be evaluated and used to understand the quality of the water level detection. Two parameters are used to control the spacing between l (location) coordinates: ds_max controls the maximum step size in horizontal direction, dz_max controls the maximum step size in vertical direction.

Parameters:
  • img (np.ndarray) – image (uint8) used to estimate water level from.

  • bank (Literal["far", "near", "both"], optional) – select from which bank to detect the water level. Use this if camera is positioned in a way that only one shore is clearly distinguishable and not obscured. Typically you will use “far” if the camera is positioned on one bank, aimed perpendicular to the flow. Use “near” if not the full cross section is visible, but only the part nearest the camera. And leave empty when both banks are clearly visible and approximately the same in distance (e.g. middle of a bridge). If not provided, the bank is detected based on the best estimate from both banks.

  • bin_size (int, optional) – Size of bins for histogram calculation of the provided image intensities, default 5.

  • length (float, optional) – length of the waterline [m], by default 2.0.

  • padding (float, optional) – amount of distance [m] to extend the polygon beyond the waterline, by default 0.5. Two polygons are drawn left and right of hypothesized water line at -padding and +padding.

  • offset (float, optional) – perpendicular offset of the waterline from the cross-section [m], by default 0.0.

  • ds_max (float, optional) – maximum step size between evaluation points in horizontal direction, by default 0.5.

  • dz_max (float, optional) – maximum step size between evaluation points in vertical direction, by default 0.02.

  • min_h (float, optional) – minimum water level to try detection [m]. If not provided, the minimum water level is taken from the cross section.

  • max_h (float, optional) – maximum water level to try detection [m]. If not provided, the maximum water level is taken from the cross section.

  • min_z (float, optional) – same as min_h but using z-coordinates instead of local datum, min_z overrules min_h.

  • max_z (float, optional) – same as max_z but using z-coordinates instead of local datum, max_z overrules max_h.

Returns:

  • float – Most likely water level, according to optimization and scoring (most distinct intensity PDF).

  • float – Signal to noise ratio, calculated as the mean of all computed scores divided by the optimum (lowest) score found in the entire l-range.