detect_single_face(image, [cascade], [sampler], [minimum_overlap], [relative_prediction_threshold]) -> bounding_box, quality

  Detects a single face in the given image, i.e., the one with the highest prediction value.

  **Parameters:**

  ``image`` : array_like (2D aka gray or 3D aka RGB)
    The image to detect a face in.

  ``cascade`` : str or :py:class:`Cascade` or ``None``
    If given, the cascade file name or the loaded cascade to be used.
    If not given, the :py:func:`default_cascade` is used.

  ``sampler`` : :py:class:`Sampler` or ``None``
    The sampler that defines the sampling of bounding boxes to search for the face.
    If not specified, a default Sampler is instantiated, which will perform a tight sampling.

  ``minimum_overlap`` : float between 0 and 1
    Computes the best detection using the given minimum overlap, see :py:func:`best_detection`

  ``relative_prediction_threshold`` : float between 0 and 1
    Limits the bounding boxes to those that have a prediction value higher then ``relative_prediction_threshold * max(predictions)``

  **Returns:**

  ``bounding_box`` : :py:class:`BoundingBox`
    The bounding box containing the detected face.

  ``quality`` : float
    The quality of the detected face, a value greater than 0.

def detect_single_face(image, cascade = None, sampler = None, minimum_overlap=0.2, relative_prediction_threshold = 0.25):
  """detect_single_face(image, [cascade], [sampler], [minimum_overlap], [relative_prediction_threshold]) -> bounding_box, quality

  Detects a single face in the given image, i.e., the one with the highest prediction value.

  **Parameters:**

  ``image`` : array_like (2D aka gray or 3D aka RGB)
    The image to detect a face in.

  ``cascade`` : str or :py:class:`Cascade` or ``None``
    If given, the cascade file name or the loaded cascade to be used.
    If not given, the :py:func:`default_cascade` is used.

  ``sampler`` : :py:class:`Sampler` or ``None``
    The sampler that defines the sampling of bounding boxes to search for the face.
    If not specified, a default Sampler is instantiated, which will perform a tight sampling.

  ``minimum_overlap`` : float between 0 and 1
    Computes the best detection using the given minimum overlap, see :py:func:`best_detection`

  ``relative_prediction_threshold`` : float between 0 and 1
    Limits the bounding boxes to those that have a prediction value higher then ``relative_prediction_threshold * max(predictions)``

  **Returns:**

  ``bounding_box`` : :py:class:`BoundingBox`
    The bounding box containing the detected face.

  ``quality`` : float
    The quality of the detected face, a value greater than 0.
  """

  if cascade is None:
    cascade = default_cascade()
  elif isinstance(cascade, str):
    cascade = Cascade(bob.io.base.HDF5File(cascade))

  if sampler is None:
    sampler = Sampler(patch_size = cascade.extractor.patch_size, distance=2, scale_factor=math.pow(2.,-1./16.), lowest_scale=0.125)

  if image.ndim == 3:
    image = bob.ip.color.rgb_to_gray(image)

  detections = []
  predictions = []
  # get the detection scores for the image
  for prediction, bounding_box in sampler.iterate_cascade(cascade, image, None):
    detections.append(bounding_box)
    predictions.append(prediction)

  if not detections:
    return None

  # compute average over the best locations
  bb, quality = best_detection(detections, predictions, minimum_overlap, relative_prediction_threshold)

  return bb, quality