class_docstr: DBNet as described in `"Real-time Scene Text Detection with Differentiable Binarization"
  <https://arxiv.org/pdf/1911.08947.pdf>`_.
  
  Args:
  ----
      feature extractor: the backbone serving as feature extractor
      fpn_channels: number of channels each extracted feature maps is mapped to
class_docstr_tok: ["DBNet","as","described","in","`","``","Real-time","Scene","Text","Detection","with","Differentiable","Binarization","''","<","https",":","\/\/arxiv.org\/pdf\/1911.08947.pdf",">","`","_",".","Args",":","--","--","feature","extractor",":","the","backbone","serving","as","feature","extractor","fpn_channels",":","number","of","channels","each","extracted","feature","maps","is","mapped","to"]
docstr: Compute the distance for each point of the map (xs, ys) to the (a, b) segment
  
  Args:
  ----
      xs : map of x coordinates (height, width)
      ys : map of y coordinates (height, width)
      a: first point defining the [ab] segment
      b: second point defining the [ab] segment
      eps: epsilon to avoid division by zero
  
  Returns:
  -------
      The computed distance
docstr_tok: ["Compute","the","distance","for","each","point","of","the","map","(","xs",",","ys",")","to","the","(","a",",","b",")","segment","Args",":","--","--","xs",":","map","of","x","coordinates","(","height",",","width",")","ys",":","map","of","y","coordinates","(","height",",","width",")","a",":","first","point","defining","the","[","ab","]","segment","b",":","second","point","defining","the","[","ab","]","segment","eps",":","epsilon","to","avoid","division","by","zero","Returns",":","--","--","--","-","The","computed","distance"]
code: def compute_distance(
      xs: np.ndarray,
      ys: np.ndarray,
      a: np.ndarray,
      b: np.ndarray,
      eps: float = 1e-6,
  ) -> float:
      """Compute the distance for each point of the map (xs, ys) to the (a, b) segment
  
      Args:
      ----
          xs : map of x coordinates (height, width)
          ys : map of y coordinates (height, width)
          a: first point defining the [ab] segment
          b: second point defining the [ab] segment
          eps: epsilon to avoid division by zero
  
      Returns:
      -------
          The computed distance
  
      """
      square_dist_1 = np.square(xs - a[0]) + np.square(ys - a[1])
      square_dist_2 = np.square(xs - b[0]) + np.square(ys - b[1])
      square_dist = np.square(a[0] - b[0]) + np.square(a[1] - b[1])
      cosin = (square_dist - square_dist_1 - square_dist_2) / (
          2 * np.sqrt(square_dist_1 * square_dist_2) + eps
      )
      cosin = np.clip(cosin, -1.0, 1.0)
      square_sin = 1 - np.square(cosin)
      square_sin = np.nan_to_num(square_sin)
      result = np.sqrt(
          square_dist_1 * square_dist_2 * square_sin / square_dist + eps
      )
      result[cosin < 0] = np.sqrt(
          np.fmin(square_dist_1, square_dist_2)
      )[cosin < 0]
      return result
  
file_path: doctr/doctr/models/detection/differentiable_binarization/base.py
imports: from typing import Dict, List, Tuple, Union
  import cv2
  import numpy
  import pyclipper
  from shapely.geometry import Polygon
  from ..core import DetectionPostProcessor
label_desc: Use image node_id 1 for calling the _DBNet obj's underlying member method code with example usage: obj.compute_distance(xs, ys, a, b, eps) and returns: result